Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Translate the following high level language code to MIPS assuming that the varia

ID: 3685926 • Letter: T

Question

Translate the following high level language code to MIPS assuming that the variables a, b, c and d are available in the registers $t0, $t1, $t2 and $t3. Hints: different types of shift instructions discussed in class can do certain types of multiplication and division. Do not use multiplication and division instructions mult and div for this problem. Write the MIPS code within a pure text file.

int a = 0x0077abcd;
int b = 16 * a ; // the * operator is multiplication
int c = 0xba70cb0;
int d = c / 8; // the / operator is integer division

if ( a > b )
    d = a * 2;
else
    c = b * 4;

Explanation / Answer

MIPS without using mul, div

Answer

li $a ,0x0077abcd;

mult $newval $a 16;

li $b ,$newval;

li $c ,0xba70cb0;

divu $c 8;

IF : slt $a, $b

      li $a ,2

      sw $d ,$a

      beq $d ,$a, LABEL

ELSE:

     slt $b, $c

      li $b ,4

      sw $d ,$c

      beq $d ,$c, LABEL

           

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote