Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions