MC logo

Load Coding Example

  Coding Examples

<<I Format Coding Branch Coding>>
Load instructions are similar to the immediate instructions. The offset replaces the immediate value. Consider:

lw $s4, 12($sp)

  1. Look up the values of the registers: $s4 is 20 = 101002, $sp is 29 = 111012.

  2. Convert the offset to binary: 12 = 11002.

  3. Look up the instruction to find its type and format. (You'll find it on p. A-66.) Plug the numbers into the format, being careful to get the registers in the right places, and pad the offset to 16 bits:
    10001111101101000000000000001100

  4. Regroup the bits.
    10001111101101000000000000001100

  5. Represent as a hex number: 8FB4000C
<<I Format Coding Branch Coding>>