Java Reference
In-Depth Information
$t0 { $t7 (8{15) are meant to hold temporary values that need not be preserved across
routine calls. If they must be preserved, it is up to the caller (the routine making the
call) to save them; hence they are called caller-saved registers.
$s0 { $s7 (16{23) are meant to hold values that must be preserved across routine calls.
It is up to the callee (the routine being called) to save these registers; hence they are
called callee-saved registers.
$t8 and $t9 (24 and 25) are caller-saved temporaries.
$k0 and $k1 (26 and 27) are reserved for use by the operating system kernel and so should
not be used by programmers or in code generated by compilers.
$gp (28) is a global pointer; it points to the middle of a 64K block of memory in the static
data segment.
$sp (29) is the stack pointer, pointing to the last location on the stack.
$fp (30) is the stack frame pointer, pointing to the latest frame on the stack.
$ra (31) is the return address register, holding the address to which execution should
continue upon return from the latest routine.
It is a good idea to follow these conventions when generating code; this allows our code to
cooperate with code produced elsewhere.
6.2.4 Routine Call and Return Convention
SPIM assumes we follow a particular protocol in implementing routine calls when one
routine (the caller) invokes another routine (the callee).
Most bookkeeping for routine invocation is recorded in a stack frame on the run-time
stack segment, much as like is done in the JVM; but here we must also deal with registers.
The stack frame for an invoked (callee) routine is illustrated in Figure 6.5.
SPIM has pretty well defined protocols for preparing for a call in the calling code, making
a call, saving registers in the frame at the start of a method, restoring the saved registers
from the frame at the end of a method, and executing a return to the calling code. We follow
these protocols closely in our run-time stack management and they are described where we
discuss our run-time stack in Section 6.3.5.
6.2.5 Input and Output
The MIPS computer is said to have memory-mapped IO, meaning the input and output
device registers are referred to as special, reserved addresses in memory. Although SPIM
does simulate this for a simple console, it also provides a set of system calls for accessing
simple input and output functions. We shall use these system calls for our work.
 
Search WWH ::




Custom Search