Question: (15 points) Translate the following C code into MIPS assembly language. If you need to use registers $t0 through $t9 or $s0 through $s7, use
(15 points) Translate the following C code into MIPS assembly language. If you need to use registers $t0 through $t9 or $s0 through $s7, use the lower-numbered registers first.
Completed the assembly language program, submit your program as a separated .asm file.
Procedure func is a leaf procedure, and procedure f is a non-leaf procedure.
Assume that the arguments a, b, c, and d for function f are in $a0-$a3, respectively, and the return value is in $v0.
Assume that the arguments a and b for function func are in $a0-$a1, respectively, and the return value is in $v0.
The code for functions main, f and func is as follows:
void main ( ) {
int g = -5;
int h = 10;
int i = 15;
int j = 20
f (g, h, i, j);
}
int f (int a, int b, int c, int d) {
int x = c+d; // x should be 35
int y = func(a, b); // y should be 15
return func(x, y); // return value should be 20
}
int func (int a, int b) {
if (a > b)
return a - b;
else
return b - a;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
