Question: Write a small assembly program to implement a function call. Use the 4-argument function on pp. 3-4. Run it on your assembler and watch the

Write a small assembly program to implement a function call. Use the 4-argument function on pp. 3-4. Run it on your assembler and watch the values of the PC, $ra, $a0, , $a3, and $v0 registers, as well as any temporary registers you may need.

Write a small assembly program to implement a function call. Use the4-argument function on pp. 3-4. Run it on your assembler and watch

The stack pointer register ($sp) holds the memory address of "points to") the most recently saved register. The stack grows from higher addresses to lower addresses. The top after a push operation is "lower than before. You can picture this as the stack g Example 1: Compile the following C procedure: int my_procedure (int g, int h, int i, int j) int f; return f; Assume that the parameter variables g, h, i, j are in argument registers $ao $al, $a2, $a3, and that local parameter f is in $s0 Solution: We need the following steps: 1. Label the procedure at start of the 1st procedure instructiorn 2. Decide on the registers used by the procedure: the calculation of f needs 2 temporary registers, 1 for each partial add the assignment to f needs 1 destination register, to hold the result 3. Save these registers, $t0, $t1, and $s0, which may contain useful values for the caller procedure creating space for 3 words on the stack, by decrementing the stack pointer saving the old contents of $t0, $t1, and $s0 onto the stack in memory 4. Perform the procedure calculations .2 adds and 1 sub

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!