SPARC Registers


Risc microprocessors are typically designed to have a relatively small number of instructions that can be decoded and run quickly. To enable the instructions to run quickly, the number of memory accesses is kept to the smallest amount possible. To help limit the number of memory accesses, RISC machines typically have a large number of registers. Both the MIPS and the SPARC machines have a relatively large number of registers for the programmer/compiler to use. In the MIPS machine, there are 32 registers that the program can use (actually, only 24 of the 32 are generally available). In the SPARC machine there are 32 registers that the program can use AT ONE TIME (actually, 28 of the 32 are generally available). Since the SPARC has been optimized for subroutine calls, the actual number of registers in the microprocessor is much larger than 32 (often 124 registers exist), but only 32 registers are visible to the program at any given time (see the subroutine overview section for more information).

Registers can be categorized by function since they are typically created for a given purpose. On RISC machines, if the register is not being used for the purpose it is designed for, it is available to use by any instruction.

The most general registers are the "temporary" registers. These registers exist to store values loaded from memory or calculated by the ALU before being stored in memory. These registers are not preserved across subroutine calls. Basically, the program should use these as the "general use" registers for the program. The MIPS machine has ten temporary registers which are designated as $t0-$t9 (registers 8-15,24, and 25). The SPARC machine has only eight temporary registers designated %l0-%l7 (registers 16-23), but the SPARC often has other registers available that can also be used as temporaries if the program needs them.

For memory accessing and for subroutine calls, both the MIPS and the SPARC provide a few specialized registers. Since they are key to the operation of the machine, the program should use the registers as designed, unless they are known to not be needed. The MIPS and the SPARC both provide a stack pointer register, $sp and %sp. They also both provide a frame pointer register, $fp and %fp. The MIPS machine reserves register $at for the assembler and $k0 and $k1 for the OS kernel. The MIPS machine also has a global memory pointer, %gp, that the SPARC doesn't have. In other words, the MIPS machine reserves four registers that the program can't generally use. The SPARC does not have this limitation.

Although the SPARC has more branch instructions than the MIPS, often the comparisons still need to be made against the constant zero. Consequently, both the MIPS and the SPARC reserve one register for the constant zero. This register, designated $zero on MIPS and %g0 on SPARC, will always return zero when read from and will not change if written to.

To provide for subroutines, there needs to be registers available for passing the arguments to the registers, returning values from the registers and returning from the subroutine.

The MIPS machine has four function argument registers, designated $a0-$a3, two return value registers, designated $v0-$v1, and one register for the return address, designated $ra. The SPARC machine has six registers for function arguments, designated %i0-%i5, six registers for function return values, designated %o0-%o5, and a function return address, designated %i7.

The SPARC machine has seven registers that are not present on the MIPS machine called %g1-%g7 (recall that %g0 is the zero register). These registers are "global" registers and their value does not change across subroutine calls. Actually, all subroutines use the same global registers; therefore the SPARC machine doesn't need the global register pointer that the MIP machine has. If the SPARC needs more globals, it can use the general memory.

In both machines, if doing a subroutine call requires more arguments than the machine provides registers for, than the program must use the stack to save the additional information.

Since the SPARC machine has more registers available to the program at any given instant and since the machine has some optimazation for subroutine calls, the SPARC machine has a clear advantage over the MIPS machine for register design.

The layout of the SPARC registers is:

SPARC Register Layout

Direct Register Comparison

Like the MIPS processor, the SPARC has a large number of registers. Many of these registers are similar to the MIPS registers. Like the MIPS, there are thirty-two registers available to the compiler/programmer to use. The layout of the registers is shown below.

Number MIPS Function SPARC
0$zeroAlways returns zero%g0 Always returns zero
1$atReserved for Assembler%g1Global 1
2$v0Func Return 1%g2Global 2
3$v1Func Return 2%g3Global 3
4$a0Func Arg 1%g4Global 4
5$a1Func Arg 2%g5Global 5
6$a2Func Arg 3%g6Global 6
7$a3Func Arg 4%g7Global 7
8$t0Temp 1%o0For Sub Arg 1
9$t1Temp 2%o1For Sub Arg 2
10$t2Temp 3%o2For Sub Arg 3
11$t3Temp 4%o3For Sub Arg 4
12$t4Temp 5%o4For Sub Arg 5
13$t5Temp 6%o5For Sub Arg 6
14$t6Temp 7%spStack Pointer
15$t7Temp 8%o7Subroutine Return Address
16$s0Saved 1%l0Local 1
17$s1Saved 2%l1Local 2
18$s2Saved 3%l2Local 3
19$s3Saved 4%l3Local 4
20$s4Saved 5%l4Local 5
21$s5Saved 6%l5Local 6
22$s6Saved 7%l6Local 7
23$s7Saved 8%l7Local 8
24$t8Temp 9%i0Func Arg 1
25$t9Temp 10%i1Func Arg 2
26$k0OS Kernel 1%i2Func Arg 3
27$k1OS Kernel 2%i3Func Arg 4
28$gpPtr To Global Mem%i4Func Arg 5
29$spStack Pointer%i5Local 6
30$fpFrame Pointer%fpFrame Pointer
31$raFunc Return Address%i7Func Return Address

Prev: Intruction Types
Next: Subroutines

mailboxPaul Austin mailboxCharles Gates
Last modified: Tue Apr 23 09:21:56 EDT 2002