MIPS LUI and SW LB Operations

0

so I'm trying to solve this problem it reads as follows, Taking to account that the address of $t0 is 0x10000000

lui $t0,0x6F90
sw $t0,4($t0)
lb $t0,6($t0)

What's the value of $t0 in a little endian format? So I after the first operation we get $t0=6F90000, after that I store $t0 in position 4 which is basically duplicating $t0, so $t0=6F900006F90000. After that I go to position 6 and extract the byte, in this case 90 and extend its signal so the answer should be 0xFFFFFF90, but my colleague told me its wrong and wouldn't explain it to me. Can anyone please tell me what im doing wrong

arrays
assembly
mips
asked on Stack Overflow Jan 26, 2020 by HelpMeBro • edited Jan 26, 2020 by Nick

2 Answers

1

You went wrong at $t0=6F900006F90000. That obviously can't happen as $t0 is a 32 bit register. sw $t0,4($t0) actually writes $t0 into memory at address 4+$t0. So that means the memory will look like:

address   value
6F900004:  00
6F900005:  00
6F900006:  90
6F900007:  6F

The lb $t0,6($t0) then loads a signed byte from address 6+$t0 = 6F900006. That contains 90 which is FFFFFF90 when sign extended to 32 bits. This is your final value in $t0.

answered on Stack Overflow Jan 26, 2020 by Jester
0

You have some incorrect ideas.  The store stores a word into memory at locations 0x6F900004-0x6F900007.

lui $t0, 0x6F90      # sets $t0 to 0x6F900000
sw  $t0, 4($t0)      # stores to memory at addresses 0x6F900004-0x6F900007; does not change $t0
lb  $t0, 6($t0)      # $t0=FFFFFF90
answered on Stack Overflow Jan 26, 2020 by Erik Eidt • edited Jan 26, 2020 by HelpMeBro

User contributions licensed under CC BY-SA 3.0