Load/Store and Data Movement Instructions
These instructions are with the I-type format and include:
- the load instructions move a value (
w
—word, 32 bits, h
—halfword, 16 bits, b
—byte, 8 bits) from memory into a register,
- the store instructions move a value from the register to memory, and
- the
move
instruction moves a value between two registers.
Loads |
Stores |
Data Movement |
Immediate |
lw rd, mem
lh rd, mem
lhu rd, mem
lb rd, mem
lbu rd, mem
|
sw rs, mem
sh rs, mem
sb rs, mem
|
move rd, rs
|
la rd, mem
li rd, imm
lui rd, imm
|
The effective address (EA) of the memory location (i.e., the
mem
field) is specified by any of the three addressing modes, which will be detailed later:
- Relative such as
EA = relocatable address ± expression
,
- Register indirect such as
EA = [$n]
, and
- Base such as
EA = [$n]+offset
.
where
[ ]
means “contents of.”
The
lh
and
lb
are signed loads; i.e., the sign is extended to fill the upper bits of the register.
lhu
and
lbu
are unsigned—the upper bits of the register are filled with zeros.
The
la
,
li
,
lui
, and
move
instructions are not really load instructions since they do not access memory.
- The
la
computes the effective address in the instruction and places the address (not the contents of the memory location) in the register.
- The
li
places the value of an expression that can be
computed at assembly time into the register, while lui
places the value into the upper half of the register and fills the lower half with zeros.
- The
move
instruction copies a value from one register to another.
I’m glad you dropped by!
It’ been a a month of Sundays (a long time) since I saw you last.
|