LW Mips: Load Word Opcode Example
Lw d, off(base)
Characteristics of LW MIPS Instruction
Lw instruction includes:
- LW to perform a load word instruction.
- A destination register(d) where the word would be loaded.
- An offset which is a 16-bit unsigned integer, necessary to make a memory address.
- A base register. The offset and base register combine to give memory address.
MIPS Lw Program Example
See the below example to understand the use of load word instruction.
lwExample: .word 3,2,5,5,6
In the above program, we described the use of LW(load word) in an array. We initialized an array(lwExample) and assigned five values of type word. In the main body of the program, we used a while loop to increment the index at each iteration. At each increment, we add 4 to index because each value is stored in 4 bytes. We used a lw instruction to retrieve values from each index of the array and print it.