MIPS Programm (Why is $t3 = 0x0000 0010 )

-1

Can someoe help me understand why $t3 = 0x00000010

.data   
vec: .word 8, 12, 16, 19, 2009, 0, 0, 0, 0, 0

.text   
main: lw $t1, vec  
lw $t2, vec+4   
lw $t3, vec($t1)   
lw $t4, vec+4($t3
mips
asked on Stack Overflow Feb 8, 2018 by Kp242 • edited Feb 8, 2018 by Michael

1 Answer

0

Because that lw $t1, vec at the beginning loads the first word at vec into $t1, i.e. 8.

lw $t3, vec($t1) then loads the word at vec+$t1, i.e. vec+8. An offset of 8 gives you the third word, since each word is 4 bytes. And the third word at vec is 16, which in hexadecimal notation is 0x10 (those six leading zeroes are of no importance).

answered on Stack Overflow Feb 8, 2018 by Michael

User contributions licensed under CC BY-SA 3.0