COMPSCI 61C Lecture Notes - Lecture 11: Opcode, Divisor
Document Summary
I-format instructions: opcode rt rs immediate write into rt immediate is signed: addi, addiu, stli, slti, lw, sw logical immediates (ori) don"t sign extend. Ex. addi (cid:616), (cid:617), (cid:620)0 opcode: all instruction types have opcode (arithmetic has opcode 0) funct: speci es what"s going on if arithmetic (opcode = 0) Use i-format opcode speci es beq (4) vs bne (5) rs and rt specify registers. Branches are typically used for loops (if, while, for) Function calls and unconditional jumps handled with jump instructions (j-format) Recall: instructions stored in a localized area of memory (code / text) Pc-relative addressing: use the immediate eld as a two"s complement o set to pc. Can specify +/- 2^25 instructions from the pc (which is +/- 2^17 addresses) Branch calculation if we don"t take the branch: pc = pc + 4 if we do take the branch: pc = (pc + 4) + (immediate << 2) start counting from instruction after.