Question: c code to MIPS assembly code (compile in QTSpim) In this part, you will gain experience in writing assembly code to call, execute, and return
In this part, you will gain experience in writing assembly code to call, execute, and return from a function. You will use the jal and jr instructions to get to and return from a function. You will need to study the registers and adhere to the standards of which registers are saved by the caller and callce. The register conventions are attached on the last page for your convenience. You will also gain experience in the use of the stack. Some points to keep in mind while writing function calls are, You will need to save any of the Stx registers on the stack that you want to preserve after the function returns. Remember to pop those Stx back from the stack immediately after the calling function returns. Remember to push any of Ss registers onto the stack you might want to use them inside your function You will then need to pop those $s registers back before you execute the jr Sra to return. You may also need to push and pop the Sra register if your function calls yet another function. i.e., if your function is not a "leaf" function. . . Program 1 In this first program you can use registers to pass arguments and results. Conventionally, you should use the Sao...Sa4 registers to pass your function arguments. int distance (int a, int b) int temp (b> a) tempa ab: batemp retorna-b) 1 void main(void) int varl 30 int var2 210: result - distance (vari, var2): return
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
