I have the following question here
.data
a: .asciiz "2021"
x: .byte 7,2,12
.text
main: addi $t2, $0, 1
lb $t3, a($t2)
Can someone explain to me, HOW the value of $t3 is 48?
thanks
EDIT this is an another question which is similiar, and is confusing.
.data
a: .word 12,-5,4,0
x: .byte 5
.text
main: addi $t1, $0, 8
lw $t2, a($0)
lw $t3, a($t1)
How will you load word, from index 8, when ‘a’ has a length of 4?
Yes, when you add
$0and1, you get1, which is put into$t2.Then, when you evaluate
a($t2), that’s the second byte (offset 1 since it’s based at offset 0) ofawhich is the “0”, ASCII code0x30or48.From various pieces of information:
Those little snippets should hopefully be enough to explain what it’s doing.
And, regarding your edit, you’re incorrectly thinking that
.word 12,-5,4,0has a length of 4 bytes. In fact it has a length of 16 bytes since words in MIPS are 32 bits (four bytes) wide.So when you load from byte offset 8, you will get the word
4.