



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




load and store architecture MIPS: can access memory only to transfer data to or from registers CISC: may allow, for example, add to memory location, store in register load: copy the data from memory into a register. store: copy the data from a register to memory.
lw $rt, offset($rs) Load word from memory location to register
sw $rt, offset($rs) Store word from register to memory location
Offset is a 16-bit 2C value (immediate); all are I-type semantics of lw
Addr <-- R[s] + (IR 15 ) 16 ::IR (^) 15- R[t] <-- M 4 [ Addr ] compute address
**- add the contents of register s (base) to the sign-extended offset
M 4 [ Addr ] <-- R[t] stored in the endianness of the machine
Byte operations lb $rt, offset($rs) Load sign-extended byte from memory location to register lbu $rt, offset($rs) Load zero-extended (unsigned) byte from memory location to register sb $rt, offset($rs) Store the least significant byte of a register to memory location What about sbu? For lb , the address is computed the same way as lw , but the address does not have to be word aligned. Addr <-- R[s] + (IR 15 ) 16 ::IR (^) 15- R[t] <-- (M 1 [ Addr ] 7 ) 24 ::M 1 [ Addr ] Since the value is interpreted as 2C, the fetched byte is sign-extended to 32 bits. lbu is just like lb except the byte is zero-extended in the register sb is similar to sw: M 1 [ Addr ] <-- R[t] (^) 7- The least significant byte of register t is copied to the address in memory. Do we really need to have separate instructions to load, store bytes?
Halfword operations (short int) short int is usually 16 bits lh $rt, offset($rs) Load halfword from memory location to register Data is sign-extended in register lhu $rt, offset($rs) Data is zero-extended in register sh $rt, offset($rs) Store halfword from register to memory location
Loading constant lui $rt, immed Semantics: R[t] = IR (^) 15-0 0 16 load the lower halfword of immed into upper halfword of $rt lower bits of $rt are set to 0 $rs is ignored
R-type I-type
Load Word lw
Halfword lh Halfword unsigned lhu Byte lb Byte unsigned lbu Constant lui
Store Word sw
Halfword sh Byte sb
This document was created with Win2PDF available at http://www.daneprairie.com. The unregistered version of Win2PDF is for evaluation or non-commercial use only.