Lab 4 - anyone who needs to finish up any wiring can see me
when I'm around to get equipment. Or, if you'd like, just go back and
set up. Please put away what you take out. Otherwise, it's all due
(on paper) at the start of class on Wednesday.
Lab 5 out, but no formal lab meetings next week. Back to the
palm emulators.
Stack is also used to carry parameters and local variables.
The entire state of a subroutine call, as saved on the stack,
is a call frame. The current frame is pointed to by the
frame pointer, or A6 on the M68K. The call frame also
includes the pointer to the old call frame.
Call frame format is "sedimentary," due to LIFO structure
of the call stack.
Before calling a routine, push arguments in reverse
order. Necessary for some languages, including C.
Calling pushes on return address.
LINK instruction (strange format) pushes on frame
pointer, generates new frame pointer to current stack top, then
updates stack pointer to include locals.
UNLK instruction undoes LINK.
RTS instruction undoes BSR.
ADD instruction undoes actual parameter pushes.
NEVER recover these values.
Particulars:
Each local and parameter assigned to byte offset from a6.
Assignments are global; watch name space collisions.
Link instruction takes final offset to a7 for
holding locals. This value is never greater than zero.
Accesses occur through add. reg. indirect with
displacement mode.
Note this method now makes recursion a natural feature of the machine.