Java Reference
In-Depth Information
$fp register (30) to point to the current stack frame and the $sp register (29) to point
to the last element on the stack.
MIPS and SPIM require that quantities be aligned on byte addresses that are multiples of
their size; for example, 32-bit words must be at addresses that are multiples of four, and 64-
bit doubles must be at addresses that are multiples of eight. Fortunately, the MIPS assembler
(and thus SPIM) provides program directives for correctly aligning data quantities. For
example, in
b: .byte 10
w: .word 324
the byte 10 is aligned on a byte boundary and may be addressed using the label b , and
the word 324 is aligned on a 4-byte boundary and may be addressed as w ; w is guaranteed
to address a word whose address is evenly divisible by 4. There are assembler directives
for denoting and addressing data items of several types in the static data segment. See
Appendix E and [Larus, 2009].
Interestingly, SPIM does not define a byte order for quantities of several bytes; rather,
it adopts the byte order of the machine on which it is running. For example, on an Intel
x86 machine (Windows or Mac OS X on an Intel x86), the order is said to be little-endian,
meaning that the bytes in a word are ordered from right to left. On Sparc or a Power PC
(Solaris or Mac OS X on a Sparc), the order is said to be big-endian, meaning that the
bytes in a word are ordered from left to right. For example, given the directive
w: .byte0,1,2,3
if we address w as a word, the 0 will appear in the lowest-order byte on a little-endian
machine (as in Figure 6.4(a)) and in the highest order byte on a big-endian machine (as in
Figure 6.4(b)).
FIGURE 6.4 Little-endian versus big-endian.
For most of our work, the endian-ness of our underlying machine on which SPIM is
running should not matter.
6.2.3 Registers
Many of the thirty-two 32-bit general-purpose registers, by convention, are designated for
special uses and have alternative names that remind us of these uses:
$zero (register number 0) always holds the constant 0.
$at (1) is reserved for use by the assembler and should not be used by programmers or in
code generated by compilers.
$v0 and $v1 (2 and 3) are used for expression evaluation and as the results of a function.
$a0 { $a3 (4{7) are used for passing the rst four arguments to routines; any additional
arguments are passed on the stack.
 
Search WWH ::




Custom Search