Question: 4. (30 points) Assume the following c code. int main() { test (1, 3); } int test (int a, int b) { int i =
4. (30 points) Assume the following c code. int main() { test (1, 3); } int test (int a, int b) { int i = sum (a+1, 6-1) return i + a + b; } int sum (int c, int d) { return c + d } Complete assembly code for main(), test(), and sum() functions. Try to use a minimum number of instructions. Note, you will need to use stacks to complete the function calls. Please make sure that which registers' values need to be stored in the stack. Register allocations - arguments (a, b, c, and d) $a0 and $al - return value $v0 stack pointer $sp main: /* write your instructions here */ jal test /* assume your program is terminated here */ test: /* write your instructions here */ jal sum /* write your instructions here */ jr $ra sum: /* write your instructions here */ jr Sra
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
