Question

6. (10 points) Translate the following c++/Java Code snippets into MIPs. Assume readInt is some value already read from the keybaord. if (readInt 0 && read Int 500){ y read Int 10 yelset. y read Int 100 read Int $50 $s1 li $to 500 500 for if condition. li $t1 10 10 for multiplication li $t2 100 100 for multiplication
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:-

    .data   ##data section where variables are declared and intialized

   .text
main:
   blez $s0,ELSE   ##if conditon readInt > 0
   bge $s0,$t0,ELSE   ##if condition readInt < 500
           ##if the variable passes two of the conditions then only will read this part otherwise ELSE part

   mult $s0,$t1   ##multiplying of $s0 and $t1
   mflo $s1   ## copying the result into $s1 i.e y
   j END       ##skipping the ELSE part
ELSE:
   mult $s0,$t2   ##multiplying of $s0 and $t1
   mflo $s1   ## copying the result into $s1 i.e y

END:
   li $v0,10   ##close of the program
   syscall       ##system call

Add a comment
Know the answer?
Add Answer to:
Translate the following C++/Java Code snippets into MIPS. Assume readInt is some value already read from...
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