There are two instructions that load a byte from a memory address. The address of the byte is calculated at run time by adding an offset to a base register (just as with the load word and store word instructions). The instructions differ in how the 8-bit byte is put into the 32-bit register.
lb t,off(b) # $t <— Sign-extended byte # from memory address b+off # b is a base register. # off is 16-bit two's complement.
loads the byte from memory into the low order eight bits
of the register.
These are bits 0-7 of the register.
copies bit 7 to bits 8-31 of the register
(all bits to the left of bit 7).
Another way to say this is that the
loads the register with a 32-bit sign extended version of
the byte at the designated address.
lb instruction when the byte is regarded as an
8-bit signed integer in the range -128...+127 and you want
a 32-bit version of the same integer.
lbu t,off(b) # $t <— Zero-extended byte # from memory address b+off # b is a base register. # off is 16-bit two's complement.
fills bits 8-31 of the register with zeros.
Use this instruction when the byte is regarded as a
ascii character or 8-bit unsigned integer.