Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructor note: Hint: Use add, jal instructions in the main assembly. Do not use lw , sw instructions. Notice that when
Instructor note:
Hint:
Use "add", "jal" instructions in the main assembly. Do not use lwsw instructions.
Notice that when the Sum and Dif functions are called, the arguments are flipped: x y and y x
Given the following C program and the mapping of registers to variables, complete the MIPS implementation of Main. Do not implement return ; in main
int Difint a int b
return a b;
int Sumint a int b
return a b;
int main
int x y;
w Sumx y;
z Dify x;
return ; Do not implement
Registers Variables
$s x
$s y
$s w
$s z
Hint: Use a a as arguments and v as return value, according to the register conventions.
Ex: If the values of $s and $s are initialized in the simulator as:
Registers Data
$s
$s
the results are stored in $s and $s:
Registers Data
$s
$s
$s
$s
Note: Use the button under the Registers display to initialize register values for $s and $s
Assembly Code:
Main:
# Type your code here.
j End
# Procedure Sum Do not modify
Sum:
add $v $a $a
jr $ra
# Procedure Dif Do not modify
Dif:
sub $v $a $a
jr $ra
End:
Registers:
$s:
$s:
Please provide the correct answer by using the assembly code I provided and any adjustments to the registers provided as well as shown in the screenshot
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