处理器型号 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
处理器型号 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
上述两张幻灯片是在 x86/MIPS 讲座期间展示的。我没太明白。
我唯一理解的是,有两种使用堆栈调用函数的模型,以及分配/释放堆。一个使用PC,另一个使用SP。
它是在谈论两个不同处理器(x86/MIPS)的模型吗?哪个是给谁的?
任何人都可以解释一下吗?