A byte is loaded into a register from the specified address.
Operation:
$t = MEM[$s + offset]; advance_pc (4);
Syntax:
lb $t, offset($s)
Encoding:
1000 00ss ssst tttt iiii iiii iiii iiii
LUI -- Load upper immediate
Description:
The immediate value is shifted left 16 bits and stored in the register. The lower 16 bits are zeroes.
Operation:
$t = (imm << 16); advance_pc (4);
Syntax:
lui $t, imm
Encoding:
0011 11-- ---t tttt iiii iiii iiii iiii
LW -- Load word
Description:
A word is loaded into a register from the specified address.
Operation:
$t = MEM[$s + offset]; advance_pc (4);
Syntax:
lw $t, offset($s)
Encoding:
1000 11ss ssst tttt iiii iiii iiii iiii
MFHI -- Move from HI
Description:
The contents of register HI are moved to the specified register.
Operation:
$d = $HI; advance_pc (4);
Syntax:
mfhi $d
Encoding:
0000 0000 0000 0000 dddd d000 0001 0000
MFLO -- Move from LO
Description:
The contents of register LO are moved to the specified register.
Operation:
$d = $LO; advance_pc (4);
Syntax:
mflo $d
Encoding:
0000 0000 0000 0000 dddd d000 0001 0010
MULT -- Multiply
Description:
Multiplies $s by $t and stores the result in $LO.
Operation:
$LO = $s * $t; advance_pc (4);
Syntax:
mult $s, $t
Encoding:
0000 00ss ssst tttt 0000 0000 0001 1000
MULTU -- Multiply unsigned
Description:
Multiplies $s by $t and stores the result in $LO.
Operation:
$LO = $s * $t; advance_pc (4);
Syntax:
multu $s, $t
Encoding:
0000 00ss ssst tttt 0000 0000 0001 1001
NOOP -- no operation
Description:
Performs no operation.
Operation:
advance_pc (4);
Syntax:
noop
Encoding:
0000 0000 0000 0000 0000 0000 0000 0000
Note: The encoding for a NOOP represents the instruction SLL $0, $0, 0 which has no side effects. In fact, nearly every instruction that has $0 as its destination register will have no side effect and can thus be considered a NOOP instruction.
OR -- Bitwise or
Description:
Bitwise logical ors two registers and stores the result in a register
Operation:
$d = $s | $t; advance_pc (4);
Syntax:
or $d, $s, $t
Encoding:
0000 00ss ssst tttt dddd d000 0010 0101
ORI -- Bitwise or immediate
Description:
Bitwise ors a register and an immediate value and stores the result in a register
Operation:
$t = $s | imm; advance_pc (4);
Syntax:
ori $t, $s, imm
Encoding:
0011 01ss ssst tttt iiii iiii iiii iiii
SB -- Store byte
Description:
The least significant byte of $t is stored at the specified address.
Operation:
MEM[$s + offset] = (0xff & $t); advance_pc (4);
Syntax:
sb $t, offset($s)
Encoding:
1010 00ss ssst tttt iiii iiii iiii iiii
SLL -- Shift left logical
Description:
Shifts a register value left by the shift amount listed in the instruction and places the result in a third register. Zeroes are shifted in.
Operation:
$d = $t << h; advance_pc (4);
Syntax:
sll $d, $t, h
Encoding:
0000 00ss ssst tttt dddd dhhh hh00 0000
SLLV -- Shift left logical variable
Description:
Shifts a register value left by the value in a second register and places the result in a third register. Zeroes are shifted in.
Operation:
$d = $t << $s; advance_pc (4);
Syntax:
sllv $d, $t, $s
Encoding:
0000 00ss ssst tttt dddd d--- --00 0100
SLT -- Set on less than (signed)
Description:
If $s is less than $t, $d is set to one. It gets zero otherwise.
# sum = x + y
lw $t0, x # Load x from memory into a CPU register
lw $t1, y # Load y from memory into a CPU register
add $t0, $t0, $t1 # Add x and y
sw $t0, sum # Store the result from the CPU register to memory