Search results
Exact instruction names appear first. Search also covers registers, system calls, encodings and expansions. Try opcode:0x23 or funct:0x20; use the format filter to narrow results. Press Esc to clear; ↓ to focus the first result.
How to read this guide
d / s / t denote general-purpose registers; fd / fs / ft denote floating-point registers. imm is an immediate constant; label is a symbolic target. Most three-operand instructions put the destination first. Stores and branches need to be read separately.
add $t0,$t1,10 or lw $t0,label are extended forms. mul is real in classic MIPS32 but may be a pseudo-instruction on earlier targets.This guide covers common integer, memory, control-flow and basic floating-point operations. It does not enumerate privileged instructions, atomics, DSP, MSA or every ISA revision. MIPS32 Release 6 changes multiplication, division and control flow, among other features. Instruction and expansion references: MARS basic-instruction implementation; MARS pseudo-instruction expansion table.
Registers: bits first, interpretation second
The 32 general-purpose registers each hold 32 bits. They have no inherent signed, unsigned or pointer type; an instruction determines how to interpret the bits.
The register number is the 5-bit value placed in an instruction's register field, not the value stored in the register. For example, $t0 = register 8 = 01000 in binary (0x08). Names and numbers in each grouped row correspond in order: $t0 = 8 (01000), $t1 = 9 (01001), …, $t7 = 15 (01111). You can also write $8 instead of $t0 in assembly.
| Name | Register number (decimal) | Register number (5-bit binary) | Register number (hexadecimal) | Usage |
|---|---|---|---|---|
$zero / $0 | 0 | 00000 | 0x00 | The constant value 0; writes are discarded. |
$at | 1 | 00001 | 0x01 | Assembler temporary. |
$v0–$v1 | 2–3 | 00010–00011 | 0x02–0x03 | Procedure return values; MARS also uses $v0 for syscall service numbers. |
$a0–$a3 | 4–7 | 00100–00111 | 0x04–0x07 | Procedure arguments. |
$t0–$t7 | 8–15 | 01000–01111 | 0x08–0x0F | Temporaries; caller-saved. |
$s0–$s7 | 16–23 | 10000–10111 | 0x10–0x17 | Saved variables; callee-saved. |
$t8–$t9 | 24–25 | 11000–11001 | 0x18–0x19 | More temporaries; caller-saved. |
$k0–$k1 | 26–27 | 11010–11011 | 0x1A–0x1B | OS temporaries; reserved for kernel or exception-handler use. |
$gp | 28 | 11100 | 0x1C | Global pointer. |
$sp | 29 | 11101 | 0x1D | Stack pointer. |
$fp / $s8 | 30 | 11110 | 0x1E | Frame pointer, or another saved register. |
$ra | 31 | 11111 | 0x1F | Procedure return address. |
$fp and $s8 are two names for the same register: 30 = 11110 in binary (0x1E).
HI, LO and PC are separate special registers. They do not have general-purpose register numbers 0–31 and cannot be selected through an ordinary 5-bit rs, rt or rd field.
Most register roles are calling conventions, not hardware restrictions. See UNSW 2026 MIPS instruction reference.
Integer arithmetic
| Instruction | Syntax, meaning and example |
|---|---|
| addReal | add d, s, tAdd signed integers; raise an exception on signed overflow. add $t0, $t1, $t2R format · opcode 0 (0x00) · funct 32 (0x20)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10000032 (0x20)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| adduReal | addu d, s, tAdd and keep the low 32 bits; no overflow exception. addu $t0, $t1, $t2R format · opcode 0 (0x00) · funct 33 (0x21)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10000133 (0x21)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 0001 Encoding checked against pinned MARS ac3d34ea65c3. |
| addiReal | addi t, s, immAdd a sign-extended 16-bit immediate; trap on signed overflow. addi $t0, $t1, -1I format · opcode 8 (0x08) · no functopcode [6] 0010008 (0x08)rs [5]srt [5]timmediate [16]immFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The immediate is sign-extended, including for sltiu. Example word: 0010 0001 0010 1000 1111 1111 1111 1111 Encoding checked against pinned MARS ac3d34ea65c3. |
| addiuReal | addiu t, s, immThe immediate is still sign-extended; no overflow exception. addiu $sp, $sp, -16I format · opcode 9 (0x09) · no functopcode [6] 0010019 (0x09)rs [5]srt [5]timmediate [16]immFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The immediate is sign-extended, including for sltiu. Example word: 0010 0111 1011 1101 1111 1111 1111 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| subReal | sub d, s, tSubtract t from s; trap on signed overflow. sub $t0, $t1, $t2R format · opcode 0 (0x00) · funct 34 (0x22)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10001034 (0x22)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| subuReal | subu d, s, tSubtract and keep the low 32 bits; no overflow exception. subu $t0, $t1, $t2R format · opcode 0 (0x00) · funct 35 (0x23)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10001135 (0x23)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 0011 Encoding checked against pinned MARS ac3d34ea65c3. |
| mulReal | mul d, s, tA real instruction in classic MIPS32: keep the low 32 product bits. Do not rely on HI/LO afterward. Earlier targets may implement it as a pseudo-instruction. mul $t0, $t1, $t2SPECIAL2 / R format · opcode 28 (0x1C) · funct 2 (0x02)opcode [6] 01110028 (0x1C)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]0000102 (0x02)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0111 0001 0010 1010 0100 0000 0000 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| multReal | mult s, tMultiply two signed 32-bit integers. Write the signed 64-bit product to HI:LO. mult $t1, $t2R format · opcode 0 (0x00) · funct 24 (0x18)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]000000 (0x00)shamt [5]000000 (0x00)funct [6]01100024 (0x18)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0000 0000 0001 1000 Encoding checked against pinned MARS ac3d34ea65c3. |
| multuReal | multu s, tMultiply two unsigned 32-bit integers. Write the unsigned 64-bit product to HI:LO. multu $t1, $t2R format · opcode 0 (0x00) · funct 25 (0x19)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]000000 (0x00)shamt [5]000000 (0x00)funct [6]01100125 (0x19)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0000 0000 0001 1001 Encoding checked against pinned MARS ac3d34ea65c3. |
| divReal | div s, tDivide signed s by signed t. LO receives the quotient, truncated toward zero; HI receives the remainder. Check division by zero and INT_MIN / -1 first. div $t1, $t2R format · opcode 0 (0x00) · funct 26 (0x1A)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]000000 (0x00)shamt [5]000000 (0x00)funct [6]01101026 (0x1A)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0000 0000 0001 1010 Encoding checked against pinned MARS ac3d34ea65c3. |
| divuReal | divu s, tDivide unsigned s by unsigned t. LO receives the quotient; HI receives the remainder. Check division by zero first. divu $t1, $t2R format · opcode 0 (0x00) · funct 27 (0x1B)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]000000 (0x00)shamt [5]000000 (0x00)funct [6]01101127 (0x1B)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0000 0000 0001 1011 Encoding checked against pinned MARS ac3d34ea65c3. |
| mfhiReal | mfhi dCopy the contents of HI into general-purpose register d; use this to retrieve a division remainder or the high half of a multiplication result. mfhi $t0R format · opcode 0 (0x00) · funct 16 (0x10)opcode [6] 0000000 (0x00)rs [5]000000 (0x00)rt [5]000000 (0x00)rd [5]dshamt [5]000000 (0x00)funct [6]01000016 (0x10)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0000 0000 0000 0100 0000 0001 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| mfloReal | mflo dCopy the contents of LO into general-purpose register d; use this to retrieve a division quotient or the low half of a multiplication result. mflo $t0R format · opcode 0 (0x00) · funct 18 (0x12)opcode [6] 0000000 (0x00)rs [5]000000 (0x00)rt [5]000000 (0x00)rd [5]dshamt [5]000000 (0x00)funct [6]01001018 (0x12)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0000 0000 0000 0100 0000 0001 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| mthiReal | mthi sCopy general-purpose register s into HI. LO is unchanged. mthi $t0R format · opcode 0 (0x00) · funct 17 (0x11)opcode [6] 0000000 (0x00)rs [5]srt [5]000000 (0x00)rd [5]000000 (0x00)shamt [5]000000 (0x00)funct [6]01000117 (0x11)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0000 0000 0000 0000 0001 0001 Encoding checked against pinned MARS ac3d34ea65c3. |
| mtloReal | mtlo sCopy general-purpose register s into LO. HI is unchanged. mtlo $t0R format · opcode 0 (0x00) · funct 19 (0x13)opcode [6] 0000000 (0x00)rs [5]srt [5]000000 (0x00)rd [5]000000 (0x00)shamt [5]000000 (0x00)funct [6]01001119 (0x13)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0000 0000 0000 0000 0001 0011 Encoding checked against pinned MARS ac3d34ea65c3. |
| negPseudo | neg d, sCompute d = 0 − s as a signed operation. Signed overflow raises an exception; negating INT_MIN cannot be represented. neg $t0, $t1Expansion · 1 real instructions · no opcode of its ownPinned MARS expansion for this operand form. sub d, $zero, s Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. neg $t1,$t2 is the source template form. ac3d34ea65c3. |
| neguPseudo | negu d, sCompute d = 0 − s modulo 2^32. No signed-overflow exception is raised. negu $t0, $t1Expansion · 1 real instructions · no opcode of its ownPinned MARS expansion for this operand form. subu d, $zero, s Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. negu $t1,$t2 is the source template form. ac3d34ea65c3. |
| absPseudo | abs d, sSigned absolute value. The absolute value of INT_MIN is not representable as a signed 32-bit integer. abs $t0, $t1Expansion · 3 real instructions · no opcode of its own3 real instructions. Clobbers $at. The pinned sequence returns INT_MIN unchanged for INT_MIN; it does not trap on that unrepresentable positive absolute value. sra $at, s, 31 xor d, $at, s subu d, d, $at Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. abs $t1,$t2 is the source template form. ac3d34ea65c3. |
| remPseudo | rem d, s, tCompute the signed remainder s % t. Commonly expands to signed division and a read of HI. Check division boundaries first. rem $t0, $t1, $t2Expansion · 4–5 real instructions · no opcode of its ownPinned MARS inserts a divisor-zero guard. With delayed branching enabled, insert nop immediately after bne; the internal target still resolves to the divide instruction. Clobbers HI/LO. Signed overflow boundaries still need a caller check. The label here is explanatory and must be unique if used in source. bne t, $zero, do_divide # nop here only when delayed branching is enabled break do_divide: div s, t mfhi d Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. rem $t1,$t2,$t3 is the source template form. ac3d34ea65c3. |
| remuPseudo | remu d, s, tCompute the unsigned remainder s % t. Commonly expands to unsigned division and a read of HI. The divisor must be nonzero. remu $t0, $t1, $t2Expansion · 4–5 real instructions · no opcode of its ownPinned MARS inserts a divisor-zero guard. With delayed branching enabled, insert nop immediately after bne; the internal target still resolves to the divide instruction. Clobbers HI/LO. Signed overflow boundaries still need a caller check. The label here is explanatory and must be unique if used in source. bne t, $zero, do_divide # nop here only when delayed branching is enabled break do_divide: divu s, t mfhi d Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. remu $t1,$t2,$t3 is the source template form. ac3d34ea65c3. |
Bitwise operations and shifts
| Instruction | Syntax, meaning and example |
|---|---|
| andReal | and d, s, tBitwise AND: each result bit is 1 only when both corresponding operand bits are 1. d = s AND t. and $t0, $t1, $t2R format · opcode 0 (0x00) · funct 36 (0x24)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10010036 (0x24)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 0100 Encoding checked against pinned MARS ac3d34ea65c3. |
| orReal | or d, s, tBitwise OR: each result bit is 1 when either corresponding operand bit is 1. d = s OR t. or $t0, $t1, $t2R format · opcode 0 (0x00) · funct 37 (0x25)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10010137 (0x25)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 0101 Encoding checked against pinned MARS ac3d34ea65c3. |
| xorReal | xor d, s, tBitwise exclusive OR: each result bit is 1 when the corresponding operand bits differ. d = s XOR t. xor $t0, $t1, $t2R format · opcode 0 (0x00) · funct 38 (0x26)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10011038 (0x26)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 0110 Encoding checked against pinned MARS ac3d34ea65c3. |
| norReal | nor d, s, tCompute ~(s OR t). nor $t0, $t1, $zeroR format · opcode 0 (0x00) · funct 39 (0x27)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10011139 (0x27)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 0000 0100 0000 0010 0111 Encoding checked against pinned MARS ac3d34ea65c3. |
| andiReal | andi t, s, immZero-extend the 16-bit immediate, then compute t = s AND immediate. Useful for masking bits; immediate range 0…65535. andi $t0, $t1, 0x00ffI format · opcode 12 (0x0C) · no functopcode [6] 00110012 (0x0C)rs [5]srt [5]timmediate [16]immFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The immediate is a 16-bit unsigned field. Example word: 0011 0001 0010 1000 0000 0000 1111 1111 Encoding checked against pinned MARS ac3d34ea65c3. |
| oriReal | ori t, s, immZero-extend the 16-bit immediate, then compute t = s OR immediate. Useful for setting bits; immediate range 0…65535. ori $t0, $t1, 0x00ffI format · opcode 13 (0x0D) · no functopcode [6] 00110113 (0x0D)rs [5]srt [5]timmediate [16]immFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The immediate is a 16-bit unsigned field. Example word: 0011 0101 0010 1000 0000 0000 1111 1111 Encoding checked against pinned MARS ac3d34ea65c3. |
| xoriReal | xori t, s, immZero-extend the 16-bit immediate, then compute t = s XOR immediate. Useful for toggling bits; immediate range 0…65535. xori $t0, $t1, 0x00ffI format · opcode 14 (0x0E) · no functopcode [6] 00111014 (0x0E)rs [5]srt [5]timmediate [16]immFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The immediate is a 16-bit unsigned field. Example word: 0011 1001 0010 1000 0000 0000 1111 1111 Encoding checked against pinned MARS ac3d34ea65c3. |
| luiReal | lui t, immPlace the immediate in the upper 16 bits; clear the lower 16 bits. lui $t0, 0x1234I format · opcode 15 (0x0F) · no functopcode [6] 00111115 (0x0F)rs [5]000000 (0x00)rt [5]timmediate [16]immFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The immediate is a 16-bit unsigned field. Example word: 0011 1100 0000 1000 0001 0010 0011 0100 Encoding checked against pinned MARS ac3d34ea65c3. |
| sllReal | sll d, t, shamtShift t left by shamt bits, fill low bits with zeroes and discard high bits. The immediate shift count is 0…31. sll $t0, $t1, 3R format · opcode 0 (0x00) · funct 0 (0x00)opcode [6] 0000000 (0x00)rs [5]000000 (0x00)rt [5]trd [5]dshamt [5]shamtfunct [6]0000000 (0x00)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0000 0000 1001 0100 0000 1100 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| srlReal | srl d, t, shamtShift t right logically by shamt bits, filling high bits with zeroes. The immediate shift count is 0…31. srl $t0, $t1, 3R format · opcode 0 (0x00) · funct 2 (0x02)opcode [6] 0000000 (0x00)rs [5]000000 (0x00)rt [5]trd [5]dshamt [5]shamtfunct [6]0000102 (0x02)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0000 0000 1001 0100 0000 1100 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| sraReal | sra d, t, shamtShift t right arithmetically by shamt bits, replicating the sign bit. The immediate shift count is 0…31. sra $t0, $t1, 3R format · opcode 0 (0x00) · funct 3 (0x03)opcode [6] 0000000 (0x00)rs [5]000000 (0x00)rt [5]trd [5]dshamt [5]shamtfunct [6]0000113 (0x03)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0000 0000 1001 0100 0000 1100 0011 Encoding checked against pinned MARS ac3d34ea65c3. |
| sllvReal | sllv d, t, sShift t left by the count in the low 5 bits of s. Fill low bits with zeroes; discard high bits. Operand order is destination, value, count. sllv $t0, $t1, $t2R format · opcode 0 (0x00) · funct 4 (0x04)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]0001004 (0x04)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0100 1001 0100 0000 0000 0100 Encoding checked against pinned MARS ac3d34ea65c3. |
| srlvReal | srlv d, t, sShift t right logically by the count in the low 5 bits of s. Fill high bits with zeroes. Operand order is destination, value, count. srlv $t0, $t1, $t2R format · opcode 0 (0x00) · funct 6 (0x06)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]0001106 (0x06)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0100 1001 0100 0000 0000 0110 Encoding checked against pinned MARS ac3d34ea65c3. |
| sravReal | srav d, t, sShift t right arithmetically by the count in the low 5 bits of s. Replicate the sign bit. Operand order is destination, value, count. srav $t0, $t1, $t2R format · opcode 0 (0x00) · funct 7 (0x07)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]0001117 (0x07)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0100 1001 0100 0000 0000 0111 Encoding checked against pinned MARS ac3d34ea65c3. |
| notPseudo | not d, sInvert every bit; commonly expands to nor d, s, $zero. not $t0, $t1Expansion · 1 real instructions · no opcode of its ownPinned MARS expansion for this operand form. nor d, s, $zero Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. not $t1,$t2 is the source template form. ac3d34ea65c3. |
Comparisons and branches
| Instruction | Syntax, meaning and example |
|---|---|
| sltReal | slt d, s, tCompare s and t as signed 32-bit integers. Write 1 to d if s < t; otherwise write 0. slt $t0, $t1, $t2R format · opcode 0 (0x00) · funct 42 (0x2A)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10101042 (0x2A)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 1010 Encoding checked against pinned MARS ac3d34ea65c3. |
| sltuReal | sltu d, s, tCompare s and t as unsigned 32-bit integers. Write 1 to d if s < t; otherwise write 0. sltu $t0, $t1, $t2R format · opcode 0 (0x00) · funct 43 (0x2B)opcode [6] 0000000 (0x00)rs [5]srt [5]trd [5]dshamt [5]000000 (0x00)funct [6]10101143 (0x2B)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0001 0010 1010 0100 0000 0010 1011 Encoding checked against pinned MARS ac3d34ea65c3. |
| sltiReal | slti t, s, immSign-extend the 16-bit immediate, then compare it with signed s. Write 1 to t if s is less; otherwise write 0. slti $t0, $t1, 10I format · opcode 10 (0x0A) · no functopcode [6] 00101010 (0x0A)rs [5]srt [5]timmediate [16]immFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The immediate is sign-extended, including for sltiu. Example word: 0010 1001 0010 1000 0000 0000 0000 1010 Encoding checked against pinned MARS ac3d34ea65c3. |
| sltiuReal | sltiu t, s, immSign-extend the 16-bit immediate, then interpret both operands as unsigned. Write 1 to t if s is less; otherwise write 0. The immediate is not zero-extended. sltiu $t0, $t1, 10I format · opcode 11 (0x0B) · no functopcode [6] 00101111 (0x0B)rs [5]srt [5]timmediate [16]immFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The immediate is sign-extended, including for sltiu. Example word: 0010 1101 0010 1000 0000 0000 0000 1010 Encoding checked against pinned MARS ac3d34ea65c3. |
| beqReal | beq s, t, labelBranch to label if register s equals register t; otherwise continue. The real instruction compares two registers. beq $t0, $t1, equalI / branch format · opcode 4 (0x04) · no functopcode [6] 0001004 (0x04)rs [5]srt [5]toffset [16]branchOffsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. offset = (target − (PC + 4)) / 4, signed 16 bits. Fixed rt bits select the condition where shown; there is no funct field. Example word: 0001 0001 0000 1001 0000 0000 0000 0111 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| bneReal | bne s, t, labelBranch to label if register s differs from register t; otherwise continue. The real instruction compares two registers. bne $t0, $t1, differentI / branch format · opcode 5 (0x05) · no functopcode [6] 0001015 (0x05)rs [5]srt [5]toffset [16]branchOffsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. offset = (target − (PC + 4)) / 4, signed 16 bits. Fixed rt bits select the condition where shown; there is no funct field. Example word: 0001 0101 0000 1001 0000 0000 0000 0111 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| bgezReal | bgez s, labelBranch to label if s, interpreted as a signed integer, is greater than or equal to zero. bgez $t0, nonnegativeREGIMM / I format · opcode 1 (0x01) · no functopcode [6] 0000011 (0x01)rs [5]srt [5]000011 (0x01)offset [16]branchOffsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. offset = (target − (PC + 4)) / 4, signed 16 bits. Fixed rt bits select the condition where shown; there is no funct field. Example word: 0000 0101 0000 0001 0000 0000 0000 0111 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| bgtzReal | bgtz s, labelBranch to label if s, interpreted as a signed integer, is greater than zero. bgtz $t0, positiveI / branch format · opcode 7 (0x07) · no functopcode [6] 0001117 (0x07)rs [5]srt [5]000000 (0x00)offset [16]branchOffsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. offset = (target − (PC + 4)) / 4, signed 16 bits. Fixed rt bits select the condition where shown; there is no funct field. Example word: 0001 1101 0000 0000 0000 0000 0000 0111 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| blezReal | blez s, labelBranch to label if s, interpreted as a signed integer, is less than or equal to zero. blez $t0, nonpositiveI / branch format · opcode 6 (0x06) · no functopcode [6] 0001106 (0x06)rs [5]srt [5]000000 (0x00)offset [16]branchOffsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. offset = (target − (PC + 4)) / 4, signed 16 bits. Fixed rt bits select the condition where shown; there is no funct field. Example word: 0001 1001 0000 0000 0000 0000 0000 0111 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| bltzReal | bltz s, labelBranch to label if s, interpreted as a signed integer, is less than zero. bltz $t0, negativeREGIMM / I format · opcode 1 (0x01) · no functopcode [6] 0000011 (0x01)rs [5]srt [5]000000 (0x00)offset [16]branchOffsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. offset = (target − (PC + 4)) / 4, signed 16 bits. Fixed rt bits select the condition where shown; there is no funct field. Example word: 0000 0101 0000 0000 0000 0000 0000 0111 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| beqzPseudo | beqz s, labelBranch to label if s is zero. Commonly expands to beq s, $zero, label. beqz $t0, is_zeroExpansion · 1 real instructions · no opcode of its ownPinned MARS expansion for this operand form. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. beq s, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. beqz $t1,label is the source template form. ac3d34ea65c3. |
| bnezPseudo | bnez s, labelBranch to label if s is nonzero. Commonly expands to bne s, $zero, label. bnez $t0, nonzeroExpansion · 1 real instructions · no opcode of its ownPinned MARS expansion for this operand form. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. bne s, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. bnez $t1,label is the source template form. ac3d34ea65c3. |
| bltPseudo | blt s, t, labelBranch to label if signed s < signed t. Commonly expands to a signed comparison followed by a conditional branch. blt $t0, $t1, lessExpansion · 2 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. slt $at, s, t bne $at, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. blt $t1,$t2,label is the source template form. ac3d34ea65c3. |
| blePseudo | ble s, t, labelBranch to label if signed s ≤ signed t. Expands to a comparison and a conditional branch. ble $t0, $t1, less_or_equalExpansion · 2 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. slt $at, t, s beq $at, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. ble $t1,$t2,label is the source template form. ac3d34ea65c3. |
| bgtPseudo | bgt s, t, labelBranch to label if signed s > signed t. Expands to a comparison and a conditional branch. bgt $t0, $t1, greaterExpansion · 2 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. slt $at, t, s bne $at, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. bgt $t1,$t2,label is the source template form. ac3d34ea65c3. |
| bgePseudo | bge s, t, labelBranch to label if signed s ≥ signed t. Expands to a comparison and a conditional branch. bge $t0, $t1, greater_or_equalExpansion · 2 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. slt $at, s, t beq $at, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. bge $t1,$t2,label is the source template form. ac3d34ea65c3. |
| bltuPseudo | bltu s, t, labelBranch to label if unsigned s < unsigned t. Expands to an unsigned comparison and a conditional branch. bltu $t0, $t1, unsigned_lessExpansion · 2 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. sltu $at, s, t bne $at, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. bltu $t1,$t2,label is the source template form. ac3d34ea65c3. |
| bleuPseudo | bleu s, t, labelBranch to label if unsigned s ≤ unsigned t. Expands to an unsigned comparison and a conditional branch. bleu $t0, $t1, unsigned_less_or_equalExpansion · 2 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. sltu $at, t, s beq $at, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. bleu $t1,$t2,label is the source template form. ac3d34ea65c3. |
| bgtuPseudo | bgtu s, t, labelBranch to label if unsigned s > unsigned t. Expands to an unsigned comparison and a conditional branch. bgtu $t0, $t1, unsigned_greaterExpansion · 2 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. sltu $at, t, s bne $at, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. bgtu $t1,$t2,label is the source template form. ac3d34ea65c3. |
| bgeuPseudo | bgeu s, t, labelBranch to label if unsigned s ≥ unsigned t. Expands to an unsigned comparison and a conditional branch. bgeu $t0, $t1, unsigned_greater_or_equalExpansion · 2 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. sltu $at, s, t beq $at, $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. bgeu $t1,$t2,label is the source template form. ac3d34ea65c3. |
| bPseudo | b labelUnconditional branch; commonly beq $zero, $zero, label. b loopExpansion · 1 real instructions · no opcode of its ownPinned MARS expansion for this operand form. The expansion ends in a real branch; its following instruction is the delay slot when delayed branching is enabled. MARS does not automatically append a nop for these ordinary branch pseudos. bgez $zero, label Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. b label is the source template form. ac3d34ea65c3. |
| seqPseudo | seq d, s, tWrite 1 to d if s equals t; otherwise write 0. Equality compares the bit patterns. seq $t0, $t1, $t2Expansion · 3 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. subu d, s, t ori $at, $zero, 1 sltu d, d, $at Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. seq $t1,$t2,$t3 is the source template form. ac3d34ea65c3. |
| snePseudo | sne d, s, tWrite 1 to d if s differs from t; otherwise write 0. Equality compares the bit patterns. sne $t0, $t1, $t2 |
| slePseudo | sle d, s, tWrite 1 to d if signed s ≤ signed t; otherwise write 0. sle $t0, $t1, $t2Expansion · 3 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. slt d, t, s ori $at, $zero, 1 subu d, $at, d Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. sle $t1,$t2,$t3 is the source template form. ac3d34ea65c3. |
| sgePseudo | sge d, s, tWrite 1 to d if signed s ≥ signed t; otherwise write 0. sge $t0, $t1, $t2Expansion · 3 real instructions · no opcode of its ownThe expansion below follows the pinned MARS register-operand form. $at is register $1; reserve it for the assembler. slt d, s, t ori $at, $zero, 1 subu d, $at, d Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. sge $t1,$t2,$t3 is the source template form. ac3d34ea65c3. |
| sgtPseudo | sgt d, s, tWrite 1 to d if signed s > signed t; otherwise write 0. sgt $t0, $t1, $t2Expansion · 1 real instructions · no opcode of its ownPinned MARS expansion for this operand form. slt d, t, s Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. sgt $t1,$t2,$t3 is the source template form. ac3d34ea65c3. |
Memory and addresses
| Instruction | Syntax, meaning and example |
|---|---|
| lwReal | lw t, offset(s)Load a 32-bit word from memory into t. Address = s + sign-extended 16-bit byte offset. The address must be a multiple of 4. lw $t0, 12($sp) # t0 = word at sp + 12I format · opcode 35 (0x23) · no functopcode [6] 10001135 (0x23)rs [5]srt [5]timmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies the value register, including for stores. Example word: 1000 1111 1010 1000 0000 0000 0000 1100 Encoding checked against pinned MARS ac3d34ea65c3. |
| swReal | sw t, offset(s)Store all 32 bits of t to memory. Address = s + sign-extended 16-bit byte offset. The address must be a multiple of 4; t is not modified. sw $t0, 12($sp) # word at sp + 12 = t0I format · opcode 43 (0x2B) · no functopcode [6] 10101143 (0x2B)rs [5]srt [5]timmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies the value register, including for stores. Example word: 1010 1111 1010 1000 0000 0000 0000 1100 Encoding checked against pinned MARS ac3d34ea65c3. |
| lbReal | lb t, offset(s)Load one 8-bit byte from memory into t and sign-extend it to 32 bits. Address = s + sign-extended 16-bit byte offset; no alignment restriction. lb $t0, 0($a0) # 0xff becomes 0xffffffffI format · opcode 32 (0x20) · no functopcode [6] 10000032 (0x20)rs [5]srt [5]timmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies the value register, including for stores. Example word: 1000 0000 1000 1000 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| lbuReal | lbu t, offset(s)Load one 8-bit byte from memory into t and zero-extend it to 32 bits. Address = s + sign-extended 16-bit byte offset; no alignment restriction. lbu $t0, 0($a0) # 0xff becomes 0x000000ffI format · opcode 36 (0x24) · no functopcode [6] 10010036 (0x24)rs [5]srt [5]timmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies the value register, including for stores. Example word: 1001 0000 1000 1000 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| lhReal | lh t, offset(s)Load one 16-bit halfword from memory into t and sign-extend it to 32 bits. Address = s + sign-extended 16-bit byte offset; requires 2-byte alignment. lh $t0, 2($a0) # 0xffff becomes 0xffffffffI format · opcode 33 (0x21) · no functopcode [6] 10000133 (0x21)rs [5]srt [5]timmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies the value register, including for stores. Example word: 1000 0100 1000 1000 0000 0000 0000 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| lhuReal | lhu t, offset(s)Load one 16-bit halfword from memory into t and zero-extend it to 32 bits. Address = s + sign-extended 16-bit byte offset; requires 2-byte alignment. lhu $t0, 2($a0) # 0xffff becomes 0x0000ffffI format · opcode 37 (0x25) · no functopcode [6] 10010137 (0x25)rs [5]srt [5]timmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies the value register, including for stores. Example word: 1001 0100 1000 1000 0000 0000 0000 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| sbReal | sb t, offset(s)Store the low 8 bits of t to one byte of memory. Address = s + sign-extended 16-bit byte offset; no alignment restriction. The register is unchanged. sb $t0, 0($a0) # store low byte of t0I format · opcode 40 (0x28) · no functopcode [6] 10100040 (0x28)rs [5]srt [5]timmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies the value register, including for stores. Example word: 1010 0000 1000 1000 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| shReal | sh t, offset(s)Store the low 16 bits of t to a halfword of memory. Address = s + sign-extended 16-bit byte offset; requires 2-byte alignment. The register is unchanged. sh $t0, 2($a0) # store low halfword of t0I format · opcode 41 (0x29) · no functopcode [6] 10100141 (0x29)rs [5]srt [5]timmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies the value register, including for stores. Example word: 1010 0100 1000 1000 0000 0000 0000 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| laPseudo | la d, labelLoad the address of a label, without reading the contents at that address. la $t0, arrayExpansion · 1–2 real instructions · no opcode of its ownDefault: 2 real instructions and $at is clobbered. The compact alternative applies only to a suitable MARS compact memory configuration and a signed 16-bit address. Other assemblers and relocation models may expand la differently. # Default MARS label form: lui $at, upper16(address(label)) ori d, $at, lower16(address(label)) # MARS compact-address alternative: addi d, $zero, address(label) Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. la $t1,label is the source template form. ac3d34ea65c3. |
| liPseudo | li d, valueLoad a constant; may expand to one or several real instructions. li $t0, 0x12345678Expansion · 1–2 real instructions · no opcode of its own1 or 2 real instructions, depending on the accepted immediate form. upper16 is bits 31:16; lower16 is bits 15:0, used by ori without sign extension. The full-width pinned MARS template clobbers $at. # Signed 16-bit constant: addiu d, $zero, imm16 # Unsigned 16-bit constant: ori d, $zero, imm16 # General 32-bit constant: lui $at, upper16(value) ori d, $at, lower16(value) Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. li is the source template form. ac3d34ea65c3. |
| movePseudo | move d, sCopy a register; commonly implemented as addu d, s, $zero. move $s0, $a0Expansion · 1 real instructions · no opcode of its ownPinned MARS expansion for this operand form. addu d, $zero, s Symbolic operands d/s/t stand for registers. Click a real mnemonic above to see its encoding. move $t1,$t2 is the source template form. ac3d34ea65c3. |
Jumps and calls
| Instruction | Syntax, meaning and example |
|---|---|
| jReal | j labelJump using a pseudo-direct target encoding; cannot encode every 32-bit address. j doneJ format · opcode 2 (0x02) · no functopcode [6] 0000102 (0x02)index [26]jumpIndexFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Target = {(PC+4)[31:28], index[25:0], 00}. The index is a word index, not a byte address. Example word: 0000 1000 0001 0000 0000 0000 0000 1000 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| jalReal | jal labelCall a function and write the return address to $ra. The saved address depends on delay-slot execution mode. jal sum_arrayJ format · opcode 3 (0x03) · no functopcode [6] 0000113 (0x03)index [26]jumpIndexFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Target = {(PC+4)[31:28], index[25:0], 00}. The index is a word index, not a byte address. Example word: 0000 1100 0001 0000 0000 0000 0000 1000 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| jrReal | jr sJump to the address in a register; jr $ra is the usual return sequence. jr $raR format · opcode 0 (0x00) · funct 8 (0x08)opcode [6] 0000000 (0x00)rs [5]srt [5]000000 (0x00)rd [5]000000 (0x00)shamt [5]000000 (0x00)funct [6]0010008 (0x08)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0011 1110 0000 0000 0000 0000 1000 Encoding checked against pinned MARS ac3d34ea65c3. |
| jalrReal | jalr d, sJump to the address in s and save the return address in d; commonly d = $ra. jalr $ra, $t9R format · opcode 0 (0x00) · funct 9 (0x09)opcode [6] 0000000 (0x00)rs [5]srt [5]000000 (0x00)rd [5]dshamt [5]000000 (0x00)funct [6]0010019 (0x09)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0011 0010 0000 1111 1000 0000 1001 Encoding checked against pinned MARS ac3d34ea65c3. |
| nopAlias | nopDo nothing; identical encoding to sll $zero, $zero, 0. MARS lists nop as a basic instruction. nopR format · opcode 0 (0x00) · funct 0 (0x00)opcode [6] 0000000 (0x00)rs [5]000000 (0x00)rt [5]000000 (0x00)rd [5]000000 (0x00)shamt [5]000000 (0x00)funct [6]0000000 (0x00)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. Register fields contain 5-bit register numbers. Unused fields shown as zero must be zero in this form. Example word: 0000 0000 0000 0000 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| syscallReal | syscallEnter a system-service handler. MARS selects a simulated service using $v0; service numbers are not defined by the MIPS ISA. syscallSPECIAL / code format · opcode 0 (0x00) · funct 12 (0x0C)opcode [6] 0000000 (0x00)code [20]000000000000000000000 (0x00)funct [6]00110012 (0x0C)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. This no-operand form uses code = 0. MIPS also has encoded code fields; MARS services use $v0, not this field. Example word: 0000 0000 0000 0000 0000 0000 0000 1100 Encoding checked against pinned MARS ac3d34ea65c3. |
| breakReal | breakRaise a breakpoint exception; not a general substitute for exiting a program. breakSPECIAL / code format · opcode 0 (0x00) · funct 13 (0x0D)opcode [6] 0000000 (0x00)code [20]000000000000000000000 (0x00)funct [6]00110113 (0x0D)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. This no-operand form uses code = 0. MIPS also has encoded code fields; MARS services use $v0, not this field. Example word: 0000 0000 0000 0000 0000 0000 0000 1101 Encoding checked against pinned MARS ac3d34ea65c3. |
Common floating-point instructions
| Instruction | Syntax, meaning and example |
|---|---|
| lwc1Real | lwc1 ft, offset(s)Load a 32-bit word from memory into floating-point register ft. Copy the raw bits without numerical conversion; requires 4-byte alignment. lwc1 $f0, 0($a0)I format · opcode 49 (0x31) · no functopcode [6] 11000149 (0x31)rs [5]srt [5]ftimmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies a floating-point register. Example word: 1100 0100 1000 0000 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| swc1Real | swc1 ft, offset(s)Store the 32-bit bit pattern in floating-point register ft to memory without numerical conversion. Requires 4-byte alignment; ft is unchanged. swc1 $f0, 0($a0)I format · opcode 57 (0x39) · no functopcode [6] 11100157 (0x39)rs [5]srt [5]ftimmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies a floating-point register. Example word: 1110 0100 1000 0000 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| ldc1Real | ldc1 ft, offset(s)Load 64 bits from memory into a floating-point register pair. In MARS, ft must be even-numbered and the memory address must be 8-byte aligned. ldc1 $f2, 0($a0)I format · opcode 53 (0x35) · no functopcode [6] 11010153 (0x35)rs [5]srt [5]ftimmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies a floating-point register. Example word: 1101 0100 1000 0010 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| sdc1Real | sdc1 ft, offset(s)Store the 64-bit bit pattern in a floating-point register pair to memory. In MARS, ft must be even-numbered; requires 8-byte alignment. The register pair is unchanged. sdc1 $f2, 0($a0)I format · opcode 61 (0x3D) · no functopcode [6] 11110161 (0x3D)rs [5]srt [5]ftimmediate [16]offsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. The offset is signed and measured in bytes. The rt field identifies a floating-point register. Example word: 1111 0100 1000 0010 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| mtc1Real | mtc1 t, fsCopy the 32-bit bit pattern in general-purpose register t to floating-point register fs. This is not an integer-to-float numerical conversion. mtc1 $t0, $f0COP1 / transfer format · opcode 17 (0x11) · no functopcode [6] 01000117 (0x11)rs [5]001004 (0x04)rt [5]tfs [5]fsreserved [11]000000000000 (0x00)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. rs selects the transfer direction. There is no floating-point arithmetic funct field in this format. Example word: 0100 0100 1000 1000 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| mfc1Real | mfc1 t, fsCopy the 32-bit bit pattern in floating-point register fs to general-purpose register t. This is not a float-to-integer numerical conversion. mfc1 $t0, $f0COP1 / transfer format · opcode 17 (0x11) · no functopcode [6] 01000117 (0x11)rs [5]000000 (0x00)rt [5]tfs [5]fsreserved [11]000000000000 (0x00)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. rs selects the transfer direction. There is no floating-point arithmetic funct field in this format. Example word: 0100 0100 0000 1000 0000 0000 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| add.sReal | add.s fd, fs, ftAdd fs and ft using single-precision floating-point arithmetic and write the result to fd. add.s $f4, $f0, $f2COP1 / arithmetic format · opcode 17 (0x11) · funct 0 (0x00) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]ftfs [5]fsfd [5]fdfunct [6]0000000 (0x00)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0000 0010 0000 0001 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| sub.sReal | sub.s fd, fs, ftSubtract ft from fs using single-precision floating-point arithmetic and write the result to fd. sub.s $f4, $f0, $f2COP1 / arithmetic format · opcode 17 (0x11) · funct 1 (0x01) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]ftfs [5]fsfd [5]fdfunct [6]0000011 (0x01)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0000 0010 0000 0001 0000 0001 Encoding checked against pinned MARS ac3d34ea65c3. |
| mul.sReal | mul.s fd, fs, ftMultiply fs by ft using single-precision floating-point arithmetic and write the result to fd. mul.s $f4, $f0, $f2COP1 / arithmetic format · opcode 17 (0x11) · funct 2 (0x02) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]ftfs [5]fsfd [5]fdfunct [6]0000102 (0x02)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0000 0010 0000 0001 0000 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| div.sReal | div.s fd, fs, ftDivide fs by ft using single-precision floating-point arithmetic and write the result to fd. div.s $f4, $f0, $f2COP1 / arithmetic format · opcode 17 (0x11) · funct 3 (0x03) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]ftfs [5]fsfd [5]fdfunct [6]0000113 (0x03)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0000 0010 0000 0001 0000 0011 Encoding checked against pinned MARS ac3d34ea65c3. |
| add.dReal | add.d fd, fs, ftAdd fs and ft using double-precision floating-point arithmetic and write the result to fd. In MARS, all operands are register pairs starting at even-numbered registers. add.d $f8, $f4, $f6COP1 / arithmetic format · opcode 17 (0x11) · funct 0 (0x00) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]ftfs [5]fsfd [5]fdfunct [6]0000000 (0x00)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0010 0110 0010 0010 0000 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| sub.dReal | sub.d fd, fs, ftSubtract ft from fs using double-precision floating-point arithmetic and write the result to fd. In MARS, all operands are register pairs starting at even-numbered registers. sub.d $f8, $f4, $f6COP1 / arithmetic format · opcode 17 (0x11) · funct 1 (0x01) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]ftfs [5]fsfd [5]fdfunct [6]0000011 (0x01)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0010 0110 0010 0010 0000 0001 Encoding checked against pinned MARS ac3d34ea65c3. |
| mul.dReal | mul.d fd, fs, ftMultiply fs by ft using double-precision floating-point arithmetic and write the result to fd. In MARS, all operands are register pairs starting at even-numbered registers. mul.d $f8, $f4, $f6COP1 / arithmetic format · opcode 17 (0x11) · funct 2 (0x02) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]ftfs [5]fsfd [5]fdfunct [6]0000102 (0x02)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0010 0110 0010 0010 0000 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| div.dReal | div.d fd, fs, ftDivide fs by ft using double-precision floating-point arithmetic and write the result to fd. In MARS, all operands are register pairs starting at even-numbered registers. div.d $f8, $f4, $f6COP1 / arithmetic format · opcode 17 (0x11) · funct 3 (0x03) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]ftfs [5]fsfd [5]fdfunct [6]0000113 (0x03)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0010 0110 0010 0010 0000 0011 Encoding checked against pinned MARS ac3d34ea65c3. |
| mov.sReal | mov.s fd, fsCopy a single-precision floating-point value from fs to fd. mov.s $f12, $f0COP1 / arithmetic format · opcode 17 (0x11) · funct 6 (0x06) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]000000 (0x00)fs [5]fsfd [5]fdfunct [6]0001106 (0x06)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0000 0000 0000 0011 0000 0110 Encoding checked against pinned MARS ac3d34ea65c3. |
| mov.dReal | mov.d fd, fsCopy a double-precision floating-point value from fs to fd. In MARS, source and destination are register pairs starting at even-numbered registers. mov.d $f12, $f0COP1 / arithmetic format · opcode 17 (0x11) · funct 6 (0x06) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]000000 (0x00)fs [5]fsfd [5]fdfunct [6]0001106 (0x06)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0010 0000 0000 0011 0000 0110 Encoding checked against pinned MARS ac3d34ea65c3. |
| cvt.s.wReal | cvt.s.w fd, fsInterpret the 32 bits in fs as a signed integer and convert that integer to a single-precision value in fd. The destination is a floating-point register. cvt.s.w $f2, $f0COP1 / arithmetic format · opcode 17 (0x11) · funct 32 (0x20) · fmt 20 (0x14)opcode [6] 01000117 (0x11)fmt [5]1010020 (0x14)ft [5]000000 (0x00)fs [5]fsfd [5]fdfunct [6]10000032 (0x20)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 1000 0000 0000 0000 1010 0000 Encoding checked against pinned MARS ac3d34ea65c3. |
| cvt.d.wReal | cvt.d.w fd, fsInterpret the 32 bits in fs as a signed integer and convert that integer to double precision. In MARS, fd names a register pair starting at an even-numbered register. cvt.d.w $f2, $f0COP1 / arithmetic format · opcode 17 (0x11) · funct 33 (0x21) · fmt 20 (0x14)opcode [6] 01000117 (0x11)fmt [5]1010020 (0x14)ft [5]000000 (0x00)fs [5]fsfd [5]fdfunct [6]10000133 (0x21)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 1000 0000 0000 0000 1010 0001 Encoding checked against pinned MARS ac3d34ea65c3. |
| cvt.w.sReal | cvt.w.s fd, fsConvert the single-precision value in fs to a signed 32-bit integer using the rounding mode. Store the integer bit pattern in fd; use mfc1 to retrieve it. cvt.w.s $f2, $f0COP1 / arithmetic format · opcode 17 (0x11) · funct 36 (0x24) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]000000 (0x00)fs [5]fsfd [5]fdfunct [6]10010036 (0x24)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0000 0000 0000 0000 1010 0100 Encoding checked against pinned MARS ac3d34ea65c3. |
| cvt.w.dReal | cvt.w.d fd, fsConvert the double-precision value in fs to a signed 32-bit integer using the rounding mode. Store the integer bit pattern in fd; use mfc1 to retrieve it. In MARS, fs must be even-numbered. cvt.w.d $f2, $f0COP1 / arithmetic format · opcode 17 (0x11) · funct 36 (0x24) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]000000 (0x00)fs [5]fsfd [5]fdfunct [6]10010036 (0x24)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0010 0000 0000 0000 1010 0100 Encoding checked against pinned MARS ac3d34ea65c3. |
| trunc.w.sReal | trunc.w.s fd, fsConvert the single-precision value in fs to a signed 32-bit integer by truncating toward zero. Store the integer bit pattern in fd; use mfc1 to retrieve it. trunc.w.s $f2, $f0COP1 / arithmetic format · opcode 17 (0x11) · funct 13 (0x0D) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]000000 (0x00)fs [5]fsfd [5]fdfunct [6]00110113 (0x0D)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0000 0000 0000 0000 1000 1101 Encoding checked against pinned MARS ac3d34ea65c3. |
| trunc.w.dReal | trunc.w.d fd, fsConvert the double-precision value in fs to a signed 32-bit integer by truncating toward zero. Store the integer bit pattern in fd; use mfc1 to retrieve it. In MARS, fs must be even-numbered. trunc.w.d $f2, $f0COP1 / arithmetic format · opcode 17 (0x11) · funct 13 (0x0D) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]000000 (0x00)fs [5]fsfd [5]fdfunct [6]00110113 (0x0D)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). Example word: 0100 0110 0010 0000 0000 0000 1000 1101 Encoding checked against pinned MARS ac3d34ea65c3. |
| c.eq.sReal | c.eq.s fs, ftCompare single-precision fs and ft. Set floating-point condition flag 0 if fs is equal to ft; clear it otherwise. c.eq.s $f0, $f2COP1 / compare format · opcode 17 (0x11) · funct 50 (0x32) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]ftfs [5]fscc [3]0000 (0x00)reserved [2]000 (0x00)funct [6]11001050 (0x32)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). This two-operand form uses condition code cc = 0. Example word: 0100 0110 0000 0010 0000 0000 0011 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| c.lt.sReal | c.lt.s fs, ftCompare single-precision fs and ft. Set floating-point condition flag 0 if fs is less than ft; clear it otherwise. c.lt.s $f0, $f2COP1 / compare format · opcode 17 (0x11) · funct 60 (0x3C) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]ftfs [5]fscc [3]0000 (0x00)reserved [2]000 (0x00)funct [6]11110060 (0x3C)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). This two-operand form uses condition code cc = 0. Example word: 0100 0110 0000 0010 0000 0000 0011 1100 Encoding checked against pinned MARS ac3d34ea65c3. |
| c.le.sReal | c.le.s fs, ftCompare single-precision fs and ft. Set floating-point condition flag 0 if fs is less than or equal to ft; clear it otherwise. c.le.s $f0, $f2COP1 / compare format · opcode 17 (0x11) · funct 62 (0x3E) · fmt 16 (0x10)opcode [6] 01000117 (0x11)fmt [5]1000016 (0x10)ft [5]ftfs [5]fscc [3]0000 (0x00)reserved [2]000 (0x00)funct [6]11111062 (0x3E)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). This two-operand form uses condition code cc = 0. Example word: 0100 0110 0000 0010 0000 0000 0011 1110 Encoding checked against pinned MARS ac3d34ea65c3. |
| bc1tReal | bc1t labelBranch to label if floating-point condition flag 0 is true. This form uses the default condition code. bc1t condition_trueCOP1 / branch format · opcode 17 (0x11) · no functopcode [6] 01000117 (0x11)rs [5]010008 (0x08)cc [3]0000 (0x00)nd [1]00 (0x00)tf [1]11 (0x01)offset [16]branchOffsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. cc = 0 in this form; nd = 0 selects an ordinary delayed branch. tf selects true (1) or false (0). No funct field. Example word: 0100 0101 0000 0001 0000 0000 0000 0111 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| bc1fReal | bc1f labelBranch to label if floating-point condition flag 0 is false. This form uses the default condition code. bc1f condition_falseCOP1 / branch format · opcode 17 (0x11) · no functopcode [6] 01000117 (0x11)rs [5]010008 (0x08)cc [3]0000 (0x00)nd [1]00 (0x00)tf [1]00 (0x00)offset [16]branchOffsetFields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. cc = 0 in this form; nd = 0 selects an ordinary delayed branch. tf selects true (1) or false (0). No funct field. Example word: 0100 0101 0000 0000 0000 0000 0000 0111 For this encoded example, assume PC = 0x00400000 and label = 0x00400020. The label in the example is illustrative. Encoding checked against pinned MARS ac3d34ea65c3. |
| c.eq.dReal | c.eq.d fs, ftCompare double-precision fs and ft. Set floating-point condition flag 0 if fs is equal to ft; clear it otherwise. In MARS, both operands name register pairs starting at even-numbered registers. c.eq.d $f0, $f2COP1 / compare format · opcode 17 (0x11) · funct 50 (0x32) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]ftfs [5]fscc [3]0000 (0x00)reserved [2]000 (0x00)funct [6]11001050 (0x32)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). This two-operand form uses condition code cc = 0. Example word: 0100 0110 0010 0010 0000 0000 0011 0010 Encoding checked against pinned MARS ac3d34ea65c3. |
| c.lt.dReal | c.lt.d fs, ftCompare double-precision fs and ft. Set floating-point condition flag 0 if fs is less than ft; clear it otherwise. In MARS, both operands name register pairs starting at even-numbered registers. c.lt.d $f0, $f2COP1 / compare format · opcode 17 (0x11) · funct 60 (0x3C) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]ftfs [5]fscc [3]0000 (0x00)reserved [2]000 (0x00)funct [6]11110060 (0x3C)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). This two-operand form uses condition code cc = 0. Example word: 0100 0110 0010 0010 0000 0000 0011 1100 Encoding checked against pinned MARS ac3d34ea65c3. |
| c.le.dReal | c.le.d fs, ftCompare double-precision fs and ft. Set floating-point condition flag 0 if fs is less than or equal to ft; clear it otherwise. In MARS, both operands name register pairs starting at even-numbered registers. c.le.d $f0, $f2COP1 / compare format · opcode 17 (0x11) · funct 62 (0x3E) · fmt 17 (0x11)opcode [6] 01000117 (0x11)fmt [5]1000117 (0x11)ft [5]ftfs [5]fscc [3]0000 (0x00)reserved [2]000 (0x00)funct [6]11111062 (0x3E)Fields run from bit 31 on the left to bit 0 on the right. Brackets show widths. Field values use decimal followed by hexadecimal, alongside the binary bits. Immediate fields show their unsigned raw bits; signed interpretation depends on the instruction. fmt describes the source representation: S = 16 (0x10), D = 17 (0x11), W = 20 (0x14). This two-operand form uses condition code cc = 0. Example word: 0100 0110 0010 0010 0000 0000 0011 1110 Encoding checked against pinned MARS ac3d34ea65c3. |
No matching instructions. Try a mnemonic or another description, or clear the type filter.
Common pitfalls
The u suffix does not always mean unsigned operands
For addu / subu / addiu, the key distinction is the absence of a signed-overflow exception. addiu still sign-extends its immediate, so addiu $sp,$sp,-16 is valid. In contrast, sltu / divu / multu really do interpret their operands as unsigned.
li $t1, -1 # Bit pattern: 0xffffffff slt $t0, $t1, $zero # -1 < 0: result 1 sltu $t0, $t1, $zero # 4294967295 < 0: result 0 sltiu $t0, $zero, -1 # Immediate becomes 0xffffffff: result 1
Sign extension, zero extension and right shifts
A 16-bit field does not imply the same immediate range for every instruction. addi/addiu/slti/sltiu and memory offsets use sign extension; andi/ori/xori use zero extension. Loading byte 0xff with lb produces 0xffffffff; lbu produces 0x000000ff.
# If t1 = 0x80000000: srl $t0, $t1, 1 # 0x40000000: fill with zeroes sra $t0, $t1, 1 # 0xc0000000: replicate the sign bit
Addresses are not contents; offsets are bytes
la $t0,array obtains an address; lw $t1,0($t0) reads the contents. Element i of a 32-bit integer array lives at base + 4*i. Memory offsets are always measured in bytes. Endianness changes how multibyte values are arranged in memory, not the direction of register shifts.
Multiplication and division boundaries
Two-operand div s,t writes HI/LO; three-operand div d,s,t is a common pseudo-instruction. Check division by zero and INT_MIN / -1 explicitly instead of depending on results across environments. A later multiply or divide may overwrite HI/LO before you read them. The low 32-bit result of mul is not an automatically checked mathematical integer.
Delay slots depend on execution mode
On classic MIPS with delay slots, the instruction immediately after an ordinary branch or jump still executes. Standard MARS 4.5 disables delayed branching by default and does not insert nop instructions automatically. With delay slots enabled, a call links to PC+8; with them disabled, MARS saves a return location appropriate for execution without a delay slot. Check the settings and implementation of course-specific forks. The examples explicitly use nop slots and avoid placing multi-instruction pseudo-operations in them.
Settings: MARS settings documentation. Instruction details: MARS basic-instruction implementation; MARS pseudo-instruction expansion table.
Machine-word tools
These tools cover the real instruction forms in this guide. All calculations run locally. They do not assemble pseudo-instructions, link symbols, execute code or validate a whole program.
Build from fields
Inspect a machine word
Calculate branch and jump targets
Compare instructions
Select two mnemonics here, or use Compare on any two instruction entries.
Machine-code formats
Classic MIPS32 instructions are 32 bits long. R, I and J describe field layouts, not an exhaustive semantic classification.
R: opcode[6] rs[5] rt[5] rd[5] shamt[5] funct[6] I: opcode[6] rs[5] rt[5] immediate[16] J: opcode[6] target[26]
| Example | Fields and encoding |
|---|---|
addu $t0,$t1,$t2 | op=0 (0x00), rs=9 (0x09), rt=10 (0x0A), rd=8 (0x08), shamt=0 (0x00), funct=33 (0x21) → 19546145 (0x012A4021) |
addiu $t0,$zero,-1 | op=9 (0x09), rs=0 (0x00), rt=8 (0x08), imm=65535 (0xFFFF) → 604569599 (0x2408FFFF) |
lw $t0,4($sp) | op=35 (0x23), rs=29 (0x1D), rt=8 (0x08), imm=4 (0x0004) → 2410151940 (0x8FA80004) |
Branch and jump targets
Ordinary conditional branch target: (PC+4) + (sign_extend(imm16) << 2). The encoded range relative to PC+4 is −131072…+131068 bytes, in four-byte steps. Write a label in assembly; the assembler calculates the offset.
j/jal target: {(PC+4)[31:28], target26, 00}. This pseudo-direct encoding selects a location in a 256 MiB region. Use jr/jalr for a target held in a register. See MARS basic-instruction implementation.
Typical pseudo-instruction expansions
move $t0, $t1 # e.g. addu $t0,$t1,$zero
not $t0, $t1 # e.g. nor $t0,$t1,$zero
li $t0, 0x12345678 # One possible expansion:
lui $t0, 0x1234
ori $t0, $t0, 0x5678
blt $t0, $t1, less # One possible expansion:
slt $at, $t0, $t1
bne $at, $zero, less
nop # Explicit branch delay slotThese are equivalent implementations, not a guarantee of a particular assembler's output. la depends on addresses, relocations and the toolchain; it is not universally a fixed lui+ori sequence. For exact MARS expansions, see MARS pseudo-instruction expansion table.
Functions and the stack
A function that calls another function must protect its own return address. A callee that modifies $s0–$s7 must restore them. Temporary, argument and return-value registers may change across a call.
# Structure only: helper must be implemented separately.
# Reserve 16 bytes for outgoing arguments, following an o32-style convention.
# A 24-byte frame preserves 8-byte alignment.
f:
addiu $sp, $sp, -24
sw $ra, 20($sp)
sw $s0, 16($sp)
move $s0, $a0
jal helper
nop
# Use helper's result here; s0 still holds this function's saved value.
lw $s0, 16($sp)
lw $ra, 20($sp)
addiu $sp, $sp, 24
jr $ra
nopArgument areas, stack alignment and floating-point arguments must follow your actual ABI. The fragment above demonstrates structure; a complete program follows below.
Common MARS system calls
Load the service number into $v0, set the arguments, execute syscall, then read the result. This table describes MARS simulation services, not Linux MIPS system calls.
| $v0 | Service, arguments and result |
|---|---|
1 / 4 / 11 | Print integer / null-terminated string / character. $a0 holds the integer / string address / character low byte. |
5 / 12 | Read an integer / character; result in $v0. Save it before loading the next service number. |
8 | Read a string: $a0 = buffer address, $a1 = capacity n. For n ≥ 2, read at most n−1 characters and append a null byte. A newline may be retained. |
9 / 10 | Allocate heap memory / exit. For service 9: $a0 = byte count; $v0 receives the address. |
2 / 3; 6 / 7 | Print float / double from $f12; read float / double into $f0. |
13 / 14 / 15 / 16 | Open / read / write / close a file; consult the original documentation for flags, arguments and results. |
34 / 35 / 36 | MARS extensions: print $a0 in hexadecimal / binary / unsigned decimal. |
Service definitions: MARS syscall documentation. Custom MARS versions may add services.
Assembler directives are not CPU instructions
| Directive | Purpose |
|---|---|
.text / .data | Select the code / data section. |
.globl main | Declare main as a global symbol; entry-point selection also depends on the execution environment. |
.word / .half / .byte | Define 4-byte / 2-byte / 1-byte integer data. |
.float / .double | Define single-precision / double-precision data. |
.ascii / .asciiz | Define a string; .asciiz adds a terminating null byte. |
.space n | Reserve n bytes; do not assume initial contents across toolchains. |
.align n | In MARS, align to a 2ⁿ-byte boundary; .align 2 means four-byte alignment. Other assemblers may differ. |
Environment reference: MARS help.
Complete example: sum an array and print 15
For standard MARS 4.5 with pseudo-instructions enabled. Explicit nop slots allow this example to work with delayed branching either enabled or disabled. It requires no input and uses only integer output, character output and exit services.
# MARS 4.5: sums 1 + 2 + 3 + 4 + 5 and prints 15.
# Pseudo instructions enabled. nop slots work with delayed branching on or off.
.data
.align 2
array: .word 1, 2, 3, 4, 5
.text
.globl main
main:
la $a0, array
li $a1, 5
jal sum_array
nop
move $a0, $v0
li $v0, 1
syscall
li $a0, 10
li $v0, 11
syscall
li $v0, 10
syscall
# Input: a0 = array address, a1 = nonnegative length.
# Output: v0 = sum modulo 2^32. Clobbers t0, t1, t2.
sum_array:
move $v0, $zero
move $t0, $a0
move $t1, $a1
loop:
beq $t1, $zero, done
nop
lw $t2, 0($t0)
addu $v0, $v0, $t2
addiu $t0, $t0, 4
addiu $t1, $t1, -1
j loop
nop
done:
jr $ra
nop