a) sub $s0, $s0, $s1 sub $s0, $s0, $s3 add $s0, $s0, $s1 b) addi $t0, $s6, 4 add
ID: 3826108 • Letter: A
Question
a) sub $s0, $s0, $s1
sub $s0, $s0, $s3
add $s0, $s0, $s1
b) addi $t0, $s6, 4
add $t1, $s6, $0
sw $t1, 0($t0)
lw $t0, 0($t0)
add $s0, $t1, $t0
For the MIPS assembly above, assume that the registers $s0, $s1, $s2, and $s3 contain the values 0x0000000a, 0x00000014, 0x0000001e, and 0x00000028, respectively. Also, assume that register $s6 contains the value 0x00000100, and that memory contains the following values:
Address Value
0x00000100 0x00000064
0x00000104 0x000000c8
0x00000108 0x0000012c
Find the value of $s0 at the end of the assembly code.
Explanation / Answer
Consider the MIPS program :
a) sub $s0, $s0, $s1
sub $s0, $s0, $s3
add $s0, $s0, $s1
The value of $s0 in the program at each step is given as,
$s0 = FFFFFFF6
$s0 = FFFFFFCE
$s0 = FFFFFFE2
Therefore the value of $s0 is $s0 = FFFFFFE2
Consider the MIPS program :
b) addi $t0, $s6, 4
add $t1, $s6, $0
sw $t1, 0($t0)
lw $t0, 0($t0)
add $s0, $t1, $t0
The value of $s0 in the program at each step is given as,
addi $t0, $s6, 4 # $t0 = 104
add $t1, $s6, $0 # $t1 = 100
sw $t1, 0($t0)
lw $t0, 0($t0) # $t0 = 100
add $s0, $t1, $t0 # $s0 = 100+100
therefore $s0 is equal to $s0=200
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.