Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2 2 . 9 LAB: Nested procedures Given the following C program and the mapping of registers to variables, complete the ARM implementation of procedure
LAB: Nested procedures
Given the following C program and the mapping of registers to variables, complete the ARM implementation of procedure Sum.
int Difint a int b
return b a;
int Sumint m int n
int p Difn m;
int q Difm n;
return p q;
int main
int x y;
z x y Sumx y;
return ;
Registers Variables
X x
X y
X z
Hint: Use X X as arguments and X as return value, according to the convention for procedure calling.
Ex: If the values of X and X are initialized in the simulator as:
Registers Data
X
X
the result is stored in $s:
Registers Data
X
X
X
Note: Use the button under the Registers display to initialize register values for X and X
ADDI X XZR # Assume Stack memory starts at Do not modify.
Procedure Main Do not modify
Main:
ADD X XZR X
ADD X XZR X
BL Sum
ADD X X X
ADD X X X
B End
Procedure Sum
Sum:
Type your code here.
Procedure Dif Do not modify
Dif:
SUB X X X
BR X
End:
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