Explaining the code: getting ready
The next few instructions look like this:
mem[4] = 0x1432
mem[5] = 0x1333
mem[6] = 0x1008
and translate to:
LDI A, 0x32
LDI IP, 0x33
LDI PC, 0x08
Register A
is keeping track of the currently executed (Forth) word and register IP
point to the instruction in that word that is going to be executed next.
Here is the memory content of this part:
A ---> 0x32: 0x0007
IP ---> 0x33: 0x0003
0x34: 0x002E
0x35: 0x0020
… …
The last instruction, LDI PC, 0x08
, sets the program counter which could also be expressed as a jump (JMP
) instruction.