View the step-by-step solution to:

Question

Hello, please help me for this question : It has three steps , the program is about to change from " C to MIPS ",

the steps are:-

Step 1. (question)

Create a program called lab3.1.asm as follows:

• reserve space in memory for three variables called var1 through var3 of size word. The initial values of var1 and var2 will be the first and the second digit of your CWID respectively. var3 will be initialized to minus the number of this year.

• the program will implement the piece of C code described below.

• tmp is a local variable for which you may use any of the registers $t0 through $t9.

if (var1 == var2) {

 var1 = var3;    /* change the values of var1 and .. */

 var2 = var3;  /* var2 to the value of var3 */

} else {        /* execute when var1 != var2 */

 tmp = var1;  /* swap the values of var1 and var2 */

 var1 = var2;

 var2 = tmp;

For example," Implementing if-then-else"

The if-then-else is one of the fundamental programming constructs.

Ex 1: if (var1 == var2) {

 .... /* block of code #1 */

        } else {

 .... /* block of code #2 */

        }

Let's assume that the values of variables var1 and var2 are in registers $t0 and $t1. Then, this piece of C code would be translated as:

bne $t0, $t1, Else # go to Else if $t0 != $t1

  ....  # code for block #1

       beq $0, $0, Exit  # go to Exit (skip code for block #2)

Else:

 ....  # code for block #2

Exit:  # exit the if-else

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes