Abstract
+--------+-----+-------+-----------------+
| Opcode | Rs | Rt | Immediate |
| 6 bits |5 bits|5 bits| 16 bits |
+--------+-----+-------+-----------------+
-
Opcode is used to uniquely specify an Instruction
-
rs
specifies register containing first operand -
rt
specifies register to receive result -
immediate
: see Immediate Value for more info -
I
because it is Instruction that contains immediate value -
Meaning: Add the Source Register with the Immediate Value, and store the result to the Target Register
4 types of instructions
arith $rt, $rs, 16_2s
lw/sw $rt, 16_2s($rs)
logic $rt, $rs, 16
branch $rs, $rt, label
, label in branch instruction refers to the number of instructions from the next instruction address.
slti
- Set Less Than Immediate
- If value in Source Register is smaller than Immediate Value, then Target Register is set to 1 else 0
- The mips code -
slti $t0, $t0, 100
- The equivalent more high-level code -
R[rt] = (R[rs]<SignExtImm) ? 1 : 0
Immediate Value
- Value is 2’s Complement (补码)
- 16-bits, can represent up to +-2^15 Word, 2^17 Memory Address because 4-bytes Word Addressing
- Used for PC-relative Addressing Mode