The ICode Machine consists of three registers and memory. The registers are
The program counter points to the current instruction in the memory. The stack pointer points to the highest occupied stack cell. The activation record pointer points to the `static link' field of the current activation record.
The memory is divided in two parts, one containing the program (Code) and the other containing data (Store). Code is an array of ICode instructions. Store is organized as stack (growing upwards) which contains the data of the program executed. Each activation of a procedure results in pushing an activation record on the stack, which contains storage for parameters and local data.
An activation record has the following layout:
|------------------------| | | store for | | local data |------------------------| | - values of | | value parameters | store for | - addresses of | parameters | reference parameters | |------------------------| | return address | |------------------------| procedure call | dynamic link | |------------------------| information AP --> | static link | |------------------------|At initialization time, the static and dynamic links and the return address of the main program are all set to 0. The registers are initialized as follows: PC := 0, SP := 3, and AP := 1. The start address is 0, i.e. Code [0] contains the first ICode instruction to be executed. PC is incremented before the according instruction is executed. The interpreter stops at return from the main program. The stop condition is: (PC = 0).
A procedure call enforces
A return from a procedure enforces