Lab 4 - anyone who needs to finish up any wiring can see me
today. Please put away what you take out. Otherwise, it's all due
(on paper) at the start of class on Wednesday.
Lab 5 - we had no formal lab meetings, but there is a
programming assignment. Back to the palm emulators. You should know
enough by the end of today to do this lab. Please at least read it
over carefully by Friday morning so you can ask questions.
Exam 1 Back
Wrapup of Encoders
Subroutines in 68000 Assembly
Branching is not enough! We need to remember a return
address somewhere - the stack!
The 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 (BSR) 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
(We 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 address register indirect with
displacement mode
This protocol makes recursion a natural feature of the machine