Unfaking Direct-Mode Loads and Stores

Some Interesting Variants of the Load Instruction
Instruction Load immediate (fake) Load upper immediate Load address (fake)
Example in assembly language li $10, 17 lui $11, 71 la $12, 0x10010044
What it does Place the value 17 into $10 Place the value 71 into the upper half of $11 Place the address 0x10013456 into $12
Assembly language after unfaking ori $10, $0, 17

 

lui $12, 0x1001

ori $12, $12, 3456

Previous row assembled into         I-format instructions
13 0 10 17
15 0 11 71
15 0 12 1001
13 12 12 3456
Result in register
0 17
71 0
1001 3456

Now we need to talk about unfaking the direct-mode load instruction. Suppose the instruction is

lw $13, 0x10015678

The unfaking is a sequence of two instructions

lui $1, 0x1001

lw $13, 0x5678($1)

What this sequence will do is to make register $1 look like this
1001 0
 and then use it as the base register to calculate the effective address for the load instruction. The effective address is the sum of $1 and 0x5678. Since 0x5678 is a 16-bit value, it fits into the bottom half of the sum, yielding
1001 5678

 which is, of course 0x10015678, the value given in the instruction.

Again, the value 0x10015678 is split into two 16-bit halves, and each half appears in one of the two instructions that unfake the fake.

15 0 1 1001
35 1 13 5678