lw
requires the address that you load from to be word-aligned (i.e. the address must be a multiple of 4).
So let's say that you have you have this array located at address 0x1000:
array: .byte 0,1,2,3
And you want to load the second byte (1
), which is located at address 0x1001, which isn't word-aligned. That clearly won't work, unless you did an lw
from address 0x1000 and then performed some shifting and ANDing to get the byte you wanted, which would be a real hassle as a programmer.
Or let's say you wanted to load the 0
, which is located at a word-aligned address, and compare it against some value. So you do lw
from address 0x1000, but now your target register will contain either 0x00010203
or 0x03020100
(depending on the endianness) rather than just 0
. So before performing the comparison you'll have to do a bitwise AND to extract the byte you wanted.
As I'm sure you can see it would be very inconvenient to have to do these extra steps whenever you want to process individual bytes of data - which in most programs is a pretty common operation.