Joel Christophel
Joel Christophel

Reputation: 2663

Load byte offset confusion

When this code runs, 4 is stored in $t2. In my thinking, though, in order to load the last byte, the offset would need to be 11, as 0x04 is the 12th byte after item. What am I not understanding here?

lbu $t2, 8($t0)

.data
item:   .word 0x11111111
    .word 0xABCD0123
    .word 0x01020304

Upvotes: 0

Views: 554

Answers (1)

Cauterite
Cauterite

Reputation: 1694

I suspect the number is being stored in 'little endian' format, so your integer 0x01020304 is actually represented in memory as the bytes 04,03,02,01 (in that order). The 0x04 which you thought was the last byte in the word (offset 11), is actually the first byte (offset 8).

Upvotes: 2

Related Questions