In: Computer Science
Consider the following code:
lb $t0, 1($t1)
sw $t0, 0($t2)
Assume the followings.
• The register $t1 contains the content 0x1000,0000.
• The word at memory address 0x1000,0000 is 0xAABB,CCDD.
What value of the word is stored at the memory address pointed to by register $t2? Show the value of the word in hexadecimal.
Greetings!!
Code:Please note that instead of address 10000000, the address 10010000 is used.
main:
#assumptions made
li $t1,0x10010000 #t1 contains address 10010000
li $t2,0x10010004 #t2 contains address 10010004
li $t3,0xAABBCCDD #given data
sw $t3,0($t1) #stored the data to memory address 10010000
lb $t0, 1($t1) #load one byte from the memory ie it reads one
byte from 10010001
sw $t0, 0($t2) #store the sign extended one word data to address
10010004
Output screenshots:
Case 1:Please note that the data stored in the memory is in little endian form. ie lower byte DD of the data is stored at address 0x10010000 and CC at addres 0x10010001 and BB at 0x10010002 and AA at 0x10010003.
Case 2:lb $t0,1(t1)
Please note that the one byte data loaded into t0 is in sign extended form. ie MSB of the data is extended to the other higher bits and hence the register t0 has 0xFFFFFFCC
Case 3:sw $t0,0($t2)
Hope this helps