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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.