Ref: green card at front of book, plus table on pg. 78 (some more on pg. 281), B.10
NOTES
Pseudo-Instructions we have used: move, li, la, b, bge, bgt, ble, blt
Another real instruction we’ve used: syscall
Floating point: don’t worry about instruction formats (similar)
Note: ignore trailing “u” on an instruction for now: determines trap behavior on errors
R-Format Instructions: add, and, jr, nor, or, slt, sll, srl, sub
0 for shifts only
add $8,$9,$10
opcode = 0 (look up in table in book)
funct = 32 (look up in table in book)
rs = 9 (first operand)
rt = 10 (second operand)
rd = 8 (destination)
shamt = 0 (not a shift)
Called a Machine Language Instruction:
hex representation: 012A 4020hex
I-Format Instructions: addi, andi, ori, slti, lb, lui, lw, sb,
sw, branches
addi $21,$22,-50
opcode = 8 (look up in table in book)
rs = 22 (register containing operand)
rt = 21 (target register)
immediate = -50 (by default, this is decimal in assembler code)
Branches: PC-Relative Addressing: beq, bne
Use I-Format
If we do take the branch (else PC = PC + 4):
PC = (PC + 4) + (immediate
* 4)
J-Format Instructions: for jumping further: j, jal (jr is R
format)
° New PC = { PC+4[31..28], address, 2’b0 } from green card in book