Processor model I
● Registers
PC – Program Counter
Single data register (accumulator) without name
We will use symbol A to describe operations on this register
● Stack with an unspecified implementation
● Data specified by name or value
More realistic model will follow later
Instruction Action Description
---------------------------------------------------------------------
load data A = data Load data to accumulator
store data data = A Store data from accumulator to memory
add data A += data Add data to accumulator
push data Push data onto stack
call addr Push PC Jump and store return trace on the stack
PC = addr
Pop PC
return Pop PC Return – jump to the previously stored trace addr
create data Allocate data on stack
destroy data Deallocate data from stack
Processor model II
● More realistic version of model I
● Stack explicitly implemented in memory
● Stack Pointer register - SP
● Stack operations defined explicitly using SP
● Allocation and deallocation of local data implemented
by changing the value of SP (no data transfer occurs)
● Arguments and local variables accessed by names
Still unrealistic
Instruction Action Description
---------------------------------------------------------------------
load data A = data Load data to accumulator (constant or variable)
store data data = A Store data from accumulator to memory
add data A += data Add data to accumulator (constant of variable)
push data *--SP = data Place data on the stack (constant of variable)
call addr *--SP = data Jump storing the return trace on the stack
PC = addr
return PC = *SP++ Return to the previously stored trace address
Create data SP -= sizeof(data) Allocate data on the stack
Destroy data SP += sizeof(data) Deallocate data from the stack
The above two slides were presented during a lecture wrt x86/MIPS. I haven't understood much.
Only thing I understood is, there are two models of calling functions using stacks, and allocating/freeing heaps. One uses PC and another uses SP.
Is it talking about models for two different processors (x86/MIPS)? Which one is for whom?
Can anyone kindly explain?