lui $13, 0x0004 lw $12, 10($13)
After the lui
instruction $13 contains 0x00040000
By using the lui
instruction,
the base register
can be loaded with multiples
of 0x00010000.
But often you want a more specific address in the base register.
Use the
ori
instruction
to fill the bottom 16 bits.
Recall that:
ori t,s,imm
zero-extends imm
to 32 bits then does a bitwise OR of that with the contents of register $s.
The result goes into register $t.
Say that
memory is as at right.
The lw
instruction (below) loads the word
at 0x0060500C into $12.
lui $13, 0x________ ori $13, $13, 0x________ lw $12, 0xC($13)