Question

CS51 Lab 8 1. Assume x goes to Ss0, y goes to $s1, and z goes to Ss2. Convert the following C code to MIPS. Use labels Else,Assume x goes to $a0, y goes to Sa1, and z goes to $a2. Convert the folowing C code to MIPS. Include a statement to go back t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the MIPS code for the above C code snippets:

C

MIPS

if (x==y)
{
y=y+z;
}
else{
z=z-x
}

beq $s0, $s1, ELSE
add $s1, $s1, $s2
ELSE: sub $s2, $s2, $s1

While(x<z)
{
y=y-z;
x++;
}

bge $s0, $s3, DONE
sub $s2 $s2, $s3
addi $s1, $s1, 1
DONE:

for (int x=1; x<5;x++){
z=x+y;
y--;

# <init>
ori $s0,1
# if (<cond>)
L1: blez $s0, 5, DONE
# <for-body>
add $s3, $s0, $s1
addi $s2, $s2, -1
DONE:

Add a comment
Know the answer?
Add Answer to:
CS51 Lab 8 1. Assume x goes to Ss0, y goes to $s1, and z goes to Ss2. Convert the following C cod...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT