Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The RISC-V code for Procedure Y is shown in the first column of the following table. Procedure X calls Procedure Y and Procedure Y calls
- The RISC-V code for Procedure Y is shown in the first column of the following table. Procedure X calls Procedure Y and Procedure Y calls Procedure Z to accomplish certain functions. You need to examine the listed RISC-V code and fill in the missing instructions according to the procedure call and register usage convention. At the beginning of Y, a stack frame is created for saving registers, parameters, and local variables. Register x10 is used for passing arguments from X to Y and from Y to Z. Registers x5, x6, x8 and x9 are used and updated in Y. The operations of different parts of the procedure are commented on the right column of the table, where a hint in red for filling in needed RISC-V instructions. Note that all registers are 64-bit.
procedureY: | Label for Procedure Y | |
addi | sp, sp, -40 sd x5, x0 sd x8, x0 sd x9, x0 sd x5, x0 | Create stack space, Save registers (fill in needed RISC-V code) |
... ... ld ld add sub add ... |
x8, 0(x10) x9, 8(x10) x5, x10, x8 x6, x5, x9 x10, x5, x6 | Procedure Y body I
// use of x8, x9, x5, x6, x10, note that x5, x6 are temporary registers |
jal |
procedureZ | (fill in RISC-V code)
Call procedure Z
(fill in RISC-V code) |
add add ... ... | x5, x8, x5 x28, x9, x5 | Procedure Y body II |
| Restore registers, return stack space (fill in RISC-V code) | |
jalr x0, 0(ra) | Return to caller |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started