Signed and Zero Extension
-
An integer register on the MIPS is 32 bits.
When a value is loaded from memory with fewer than 32 bits, the
remaining bits must be assigned.
-
Sign extension is used for signed loads of bytes (8 bits using the
lb instruction) and halfwords (16 bits using the lh
instruction).
Sign extension replicates the most significant bit loaded into the
remaining bits.
-
Zero extension is used for unsigned loads of bytes (
lbu ) and
halfwords (lhu ).
Zeroes are filled in the remaining bits.
|