tags:

views:

29

answers:

1

I have the following question

.data
a: .word 12,-5,4,0
x: .byte 5
.text
main: addi $t1, $0, 8
lw $t2, a($0)
lw $t3, a($t1)

Can someone, what the value of $t3 will be?, How can you access, the 8th element when the array has a length of 4?

+2  A: 

The value will be 4. MIPS is byte-addressed, not word-addressed. A word is 4 bytes, so a byte offset of 8 is equivalent to a word offset of 2.

sxeraverx
Also worthy to note that x86 assembly is also byte-addressed (and probably many other assembly languages), so the OP should get familiar with that offsetting.
Kizaru