5 For the following C statement what is the corresponding MI

5.   For the following C statement what is the corresponding MIPS assembly code? Assume variable g is assigned to $s1, h to $s2, and f to $s0.
f = g + ( h – 5 );

Solution

lw   $s1, 4 ($t1) #puts g into a register 4 away from s1
lw   $s2, 8 ($t1) #puts h into a register

addi   $s2, $s2, -5 #h = h-5
add   $s0, $s1, $s2 #addition f = g+(h-5)
sw   $s0, 0 ($t1) #stores the value of f

***Please mention if u got any doubts,thank you

5. For the following C statement what is the corresponding MIPS assembly code? Assume variable g is assigned to $s1, h to $s2, and f to $s0. f = g + ( h – 5 );S

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site