5.4. Lw, Sw Load And Store Instructions

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 6

1/3/2019 5.4. lw, sw: Load and store instructions
https://learn.zybooks.com/zybook/FIUCDA3103CickovskiFall2018/chapter/5/section/4 1/6
5.4 lw, sw: Load and store instructions
Load instruction: lw
A load instruction copies data from memory into a register. A MIPS load instruction format is shown below. Another sectio
reason for the 0( ) around the memory-address.
lw register 0(memory-address)
MIPS register names start with a $. MIPSzy supports 8 registers. Writeable registers are $t0, $t1, ..., $t6. A special $zero reg
the value 0 and can only be read, not written.
The load instruction's memory-address is a register whose value is the memory address from which data is copied.
Load word
lw is short for "load word", in contrast to just loading a byte (a word is four bytes)
PARTICIPATION
ACTIVITY 5.4.1: Load instruction: lw.
1) If $t6's value is 2020, what is the
memory address for the following
instruction?
lw $t0, 0($t6)
Check Show answer
1/3/2019 5.4. lw, sw: Load and store instructions
https://learn.zybooks.com/zybook/FIUCDA3103CickovskiFall2018/chapter/5/section/4 2/6
2) Given the following register le and
memory contents, what value is loaded
into register $t3 by the following
instruction?
lw $t3, 0($t6)
3) Given the following register le,
complete the load instruction to load
register $t2 with data at memory
address 5012.
Check Show answer
1/3/2019 5.4. lw, sw: Load and store instructions
https://learn.zybooks.com/zybook/FIUCDA3103CickovskiFall2018/chapter/5/section/4 3/6
lw $t2, 0( )
4) Assuming $t5 holds 6000, write a load
instruction that loads register $t4 with
data at memory address 6000.
Store instruction: sw
A store instruction copies data from a register to memory. A MIPS store instruction format is shown below. Another sectio
reason for the 0( ) around the memory-address.
sw register 0(memory-address)
PARTICIPATION
ACTIVITY 5.4.2: Store instruction: sw.
1) Assuming $t6 holds 600 and $t0 holds
5008, what is the memory address for
Check Show answer
Check Show answer
1/3/2019 5.4. lw, sw: Load and store instructions
https://learn.zybooks.com/zybook/FIUCDA3103CickovskiFall2018/chapter/5/section/4 4/6
the following instruction?
sw $t6, 0($t0)
2) Given $t2 holds 6200, $t3 holds 536,
and $t4 holds 616, what value is stored
into memory?
sw $t3, 0($t2)
3) Given the following register le,
complete the store instruction to store
register $t2's value into memory at
address 5000.
sw , 0($t4)
Check Show answer
Check Show answer
Check Show answer
1/3/2019 5.4. lw, sw: Load and store instructions
https://learn.zybooks.com/zybook/FIUCDA3103CickovskiFall2018/chapter/5/section/4 5/6
4) Assuming $t0 holds 5400 and $t1 holds
280, write a store instruction that stores
register $t1's value into memory at
address 5400.
Instruction format summary: lw, sw
The condensed instruction format below species all registers using $ followed by a single character. Ex: $a.
Table 5.4.1: Instruction summary: lw, sw.
Instruction Format Description Example
lw lw $a, 0($b) Load word: Copies data from memory at
address $b to register $a. lw $t3, 0($t6)
sw sw $a, 0($b) Store word: Copies data from register $a to
memory at address $b. sw $t1, 0($t3)
CHALLENGE
ACTIVITY 5.4.1: Load and store instructions.
Check Show answer
Check Show answer
Start
Compute: $t6 = DM[5192]
1
2
1/3/2019 5.4. lw, sw: Load and store instructions
https://learn.zybooks.com/zybook/FIUCDA3103CickovskiFall2018/chapter/5/section/4 6/6
lw
$t5
, 0(
$t5
)
2 3
3
Registers
$t5 5192
$t6 0
Data memory
5192 8
Check
Next
Provide feedback on this section
1

Navigation menu