0
votes
li $t0 , 0xABCD9876
sw $t0 , 100($0)
lb $s5 , 101($0)

New to MIPS; So my understanding is,

li loads the value 0xABCD9876 into register $t0

This value is then stored into memory at address ($0+100)

lb then copies the byte at address ($0+101) into register $s5

But there's nothing in register ($0+101) is there? 0xABCD9876 was stored in ($0+100), not ($0+$101). Lost at this point.

1

1 Answers

2
votes

Memory is byte-addressed. Hence, ($0+100) points at a single byte. When it is used with a sw or lw instruction, you are actually accessing not only ($0+100), but also ($0+101), ($0+102), and ($0+103) (in other words, you’re accessing four bytes (one word) beginning at that address). By storing a word and then accessing a particular byte of it, you can determine which order the word’s bytes were stored in memory, and hence determine the processor’s endianness.