Show work when converting between notations. Convert the following instructions
ID: 3605281 • Letter: S
Question
Show work when converting between notations.Convert the following instructions into MIPS code: g. cc (b+a) a, b, and c are in registers Ss0, Ss1, and Ss2, respectively. h, g = ( e + f+ d ) / 4 d, e, f and g are in registers Ss3, Ss4, Ss5, and Ss6, respectively (Use srl instruction) i. i-(h-8) + (j-10) h, i, and j are in registers Ss0, Ss1, and Ss2, respectively k=m*8 k and m are in registers Ss1 and St5, respectively. (MUL instruction is not allowed, use relationship between multiplication and shift) j,
Explanation / Answer
Hi,
Please find the answers.
g.c=c-(b+a)
add $t1, $s1, $s0 # compute the sum of $s0 and $s1, and
# put it into $t1.
sub $s2, $s2, $t1 # compute the difference of $s2 and $t1, and
# put it into $s2.
h.g=(e+f+d)/4
li $t1, 2 # load 4(2 power of 2) into $t1
add $t2, $s4, $s5 # compute the sum of $s4 and $s5, and
# put it into $t2.
add $t3, $t2, $s3 # compute the sum of $t2 and $s3, and
# put it into $t3.
srl $s6, $t3, $t1 # $s6 gets the logical
# right shift of $t5
# by shft positions.
# shft is a 2-bit i.e.(2 power of 2)
# integer, 0 shft < 32
i.i=(h-8)+(j-10)
li $t1, 8 # load 3 into $t1
li $t2, 10 # load 10 into $t2
sub $t3, $s0, $t1 # compute the difference of $s0 and $t1, and
# put it into $t3.
sub $t4, $s2, $t2 # compute the difference of $s2 and $t2, and
# put it into $t4.
add $s1, $t3, $t4 # compute the sum of $t4 and $t3, and
# put it into $s1.
j.k=m*8
li $t1, 3 # load 8(2 power of 3) into $t1
sll $s1, $t5, $t1 # $s1 gets the logical
# left shift of $t5
# by shft positions.
# shft is a 3-bit i.e.(2 power of 3)
# integer, 0 shft < 32
Thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.