Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with ARM implementation for this C program for computer organization class: Given the following C program and the mapping of registers to variables,

Please help with ARM implementation for this C program for computer organization class:
Given the following C program and the mapping of registers to variables, complete the ARM implementation of Main. Do not implement return 0; in main().
int Dif(int a, int b){
return a - b;
}
int Sum(int a, int b){
return a + b;
}
int main(){
int x, y;
w = Sum(x, y);
z = Dif(y, x);
return 0; // Do not implement
}
Registers Variables
X19 x
X20 y
X21 w
X22 z
Hint: Use X0, X1 as arguments and X2 as return value, according to the convention for procedure calling.
Ex: If the values of X19 and X20 are initialized in the simulator as:
Registers Data
X195
X2010
the results are stored in X21 and X22:
Registers Data
X195
X2010
X2115
X225
Note: Use the '+' button under the Registers display to initialize register values for X19 and X20.
Assembly
Main:
// Type your code here.
B End
// Procedure Sum (Do not modify)
Sum:
ADD X2, X0, X1
BR X30
// Procedure Dif (Do not modify)
Dif:
SUB X2, X0, X1
BR X30
End:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions