Simple Stack Machine |
||||||||||||||||||||||||
|
Machine
Model
|
|||||||||||||||||||||||
|
Memory and RegistersThe SSM machine model contains memory and registers, see figure below. Memory contains code at its lower address range, starting at 0. The stack immediately follows thereafter. Memory consists of an array of 32 bit words. Each word is addressed by an integer index value, its address. Memory starts at address 0. Four registers are available, the Program Counter (PC), pointing to the current next instruction, the Stack Pointer (SP), pointing to the top of the stack, the Mark Pointer (MP), pointing to the current stackframe and a Return Register (RR) for holding return values. Initially, when starting with the execution of code, the Program Counter equals 0. The Stack Pointer and Mark Pointer are set to a location after the loaded code. The Stack Pointer always points to the topmost element and grows from low to high addresses. Instruction executionThe value of PC is used as the address to fetch the next instruction from. The loop executed by SSM thus looks like: while ...
|