This Web page was created by reformatting portions of the LaTeX source file of the public domain documentation distributed with the SPIM simulator.
Register Name | Number | Usage |
---|---|---|
zero | 0 | Constant 0 |
at | 1 | Reserved for assembler |
v0 | 2 | Expression evaluation and results of a function |
v1 | 3 | Expression evaluation and results of a function |
a0 | 4 | Argument 1 |
a1 | 5 | Argument 2 |
a2 | 6 | Argument 3 |
a3 | 7 | Argument 4 |
t0 | 8 | Temporary (not preserved across call) |
t1 | 9 | Temporary (not preserved across call) |
t2 | 10 | Temporary (not preserved across call) |
t3 | 11 | Temporary (not preserved across call) |
t4 | 12 | Temporary (not preserved across call) |
t5 | 13 | Temporary (not preserved across call) |
t6 | 14 | Temporary (not preserved across call) |
t7 | 15 | Temporary (not preserved across call) |
s0 | 16 | Saved temporary (preserved across call) |
s1 | 17 | Saved temporary (preserved across call) |
s2 | 18 | Saved temporary (preserved across call) |
s3 | 19 | Saved temporary (preserved across call) |
s4 | 20 | Saved temporary (preserved across call) |
s5 | 21 | Saved temporary (preserved across call) |
s6 | 22 | Saved temporary (preserved across call) |
s7 | 23 | Saved temporary (preserved across call) |
t8 | 24 | Temporary (not preserved across call) |
t9 | 25 | Temporary (not preserved across call) |
k0 | 26 | Reserved for OS kernel |
k1 | 27 | Reserved for OS kernel |
gp | 28 | Pointer to global area |
sp | 29 | Stack pointer |
fp | 30 | Frame pointer |
ra | 31 | Return address (used by function call) |
Service | System Call Code | Arguments | Result |
---|---|---|---|
print_int | 1 | $a0 = integer | |
print_float | 2 | $f12 = float | |
print_double | 3 | $f12 = double | |
print_string | 4 | $a0 = string | |
read_int | 5 | integer (in $v0) | |
read_float | 6 | float (in $f0) | |
read_double | 7 | double (in $f0) | |
read_string | 8 | $a0 = buffer, $a1 = length | |
sbrk | 9 | $a0 = amount | address (in $v0) |
exit | 10 |
In all instructions below, Src2 can either be a register or an immediate value (a 16 bit integer). The immediate forms of the instructions are only included for reference. The assembler will translate the more general form of an instruction (e.g., add) into the immediate form (e.g., addi) if the second argument is constant.
abs Rdest, Rsrc | Absolute Value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Put the absolute value of the integer from register Rsrc in register Rdest. |
li Rdest, imm | Load Immediate | ||||
Move the immediate imm into register Rdest. |
In all instructions below, Src2 can either be a register or an immediate value (a 16 bit integer).
seq Rdest, Rsrc1, Src2 | Set Equal | ||||||||||||||||||||||||||||||||
Set register Rdest to 1 if register Rsrc1 equals Src2 and to be 0 otherwise. |
In all instructions below, Src2 can either be a register or an immediate value (integer). Branch instructions use a signed 16-bit offset field; hence they can jump 2^15-1 instructions (not bytes) forward or 2^15 instructions backwards. The jump instruction contains a 26 bit address field.
b label | Branch instruction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Unconditionally branch to the instruction at the label. |
la Rdest, address | Load Address | ||||||||||||||||||||||||||||||||||||||||
Load computed address, not the contents of the location, into register Rdest. |
sb Rsrc, address | Store Byte | ||||||||||||||||||||||||||||||
Store the low byte from register Rsrc at address. |
move Rdest, Rsrc | Move | ||||||||||||||||||
Move the contents of Rsrc to Rdest. The multiply and divide unit produces its result in two additional registers, hi and lo. These instructions move values to and from these registers. The multiply, divide, and remainder instructions described above are pseudoinstructions that make it appear as if this unit operates on the general registers and detect error conditions such as divide by zero or overflow. | |||||||||||||||||||
mfhi Rdest | Move From hi | ||||||||||||||||||
mflo Rdest | Move From lo | ||||||||||||||||||
Move the contents of the hi (lo) register to register Rdest. |
The MIPS has a floating point coprocessor (numbered 1) that operates on single precision (32-bit) and double precision (64-bit) floating point numbers. This coprocessor has its own registers, which are numbered f0-f31. Because these registers are only 32-bits wide, two of them are required to hold doubles. To simplify matters, floating point operations only use even-numbered registers - including instructions that operate on single floats. Values are moved in or out of these registers a word (32-bits) at a time by lwc1, swc1, mtc1, and mfc1 instructions described above or by the l.s, l.d, s.s, and s.d pseudoinstructions described below. The flag set by floating point comparison operations is read by the CPU with its bc1t and bc1f instructions. In all instructions below, FRdest, FRsrc1, FRsrc2, and FRsrc are floating point registers (e.g., f2).
abs.d FRdest, FRsrc | Floating Point Absolute Value Double | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
abs.s FRdest, FRsrc | Floating Point Absolute Value Single | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Compute the absolute value of the floating float double (single) in register FRsrc and put it in register FRdest. |
rfe | Return From Exception | ||||
Restore the Status register. |