Java Reference
In-Depth Information
branches, delayed loads, caching, and memory latency. Fortunately, the MIPS assembler
models a virtual machine that both hides these timing issues and uses pseudo-instructions
to provide a slightly richer instruction set. By default, SPIM simulates this virtual machine,
although it can be configured to model the more complicated raw MIPS computer. We will
make use of the simpler, default assembly language.
6.2.2 Memory Organization
Memory is, by convention, divided into four segments, as illustrated in Figure 6.3 and
derived from [Larus, 2009].
FIGURE 6.3 SPIM memory organization.
Text segment. The program's instructions go here, near the bottom end of memory, start-
ing at 400000 hex . (The memory location below 400000 hex are reserved.)
Static data segment. Static data, which exist for the duration of the program, go here,
starting at 1000000 hex . This would be a good place to put constants (including con-
stant strings) and static fields. To access these values conveniently, MIPS designates
one of its thirty-two registers as $gp (register number 28), which points to the middle
of a 64K block data in this segment. Individual memory locations may be addressed
at fixed (positive or negative) offsets from $gp.
Dynamic data segment. Often called the heap, this is where objects and arrays are dy-
namically allocated during execution of the program. Many systems employ a garbage
collection to reclaim the space allocated to objects that are no longer of use. This seg-
ment starts just above the static data segment and grows upward, toward the run-time
stack.
Stack segment. The stack is like that for the JVM. Every time a routine is called, a new
stack frame is pushed onto the stack; every time a return is executed, a frame is
popped of The stack starts at the top of memory and grows downward toward the
heap. That the dynamic data segment and stack segment start as far apart as possible
and grow toward each other leads to an effective use dynamic memory. We use the
 
Search WWH ::




Custom Search