Tom Jennings asks of the HP-41C calculator:
But is it STORED PROGRAM, eg. can it do self-modifying
code. vonNeumann
(one store for program and data; programs ARE data)
The "Nut" microprocessor used in the HP-41C family (and the HP-10C,
-11C, -12C, -15C, and -16C) uses a modified Harvard architecture. It's
an unusual case, in that the processor has an instruction to read program
memory, but it doesn't explicitly have an instruction to write program
memory. However, many opcodes are interpreted by the memory and I/O
devices rather than the processor, and one of those was designated to
write to program memory. None of the memory found in the base HP-41C
machines will respond to that opcode, but some third party products such
as the MLDL and HEPAX do.
The machine code of the HP-41C was not normally exposed to the HP customer.
Rather, the code in the ROM implements an interpreter for the user-level
instruction set, which PPC members nicknamed "Fourty-One CAlculator
Language", or FOCAL for short (not to be confused with the computer
programming language FOCAL commonly found on DEC machines).
The base HP-41C was not intended to allow user programs to read or modify
user programs. However, there are several ways in which this can be
accomplished in practice. Two of them are:
1) "Synthetic Programming" - taking advantage of bugs in the HP-41C
firmware to access memory locations containing program steps (or
internal working registers) as data, allowing program modification
as well as creating synthetic program lines which cannot normally
be entered from the keyboard in the usual manner.
Using the LB program in the PPC ROM, it becomes very easy for
one program to create another.
2) Using peripherals, such as the HP 82162A tape drive or HP 9114A/B
disk drive (either of which must be interfaced by the HP 82160A
HP-IL interface), and the HP 82183A Extended I/O ROM or the HP-IL
Development ROM, programs can directly read and write program files
stored on disc or tape.
I'm sure there are other ways to do this as well.
Eric