Question: addi $sp , $zero, 8 1 8 8 # Assume program stack starts at 8 1 8 8 . Do not modify. # Procedure Main

addi $sp, $zero, 8188 # Assume program stack starts at 8188. Do not modify.
# Procedure Main
Main:
addi $t0, $zero, 5
addi $t1, $zero, 10
# Call Sum
move $a0, $t0 # Move argument $t0 to $a0
move $a1, $t1 # Move argument $t1 to $a1
jal Sum # Call Sum procedure
lw $t2,0($sp) # Load the result of Sum from the stack into $t2
# Call Dif
move $a0, $t0 # Move argument $t0 to $a0
move $a1, $t1 # Move argument $t1 to $a1
jal Dif # Call Dif procedure
lw $t3,0($sp) # Load the result of Dif from the stack into $t3
j End # Jump to End label
#Procedure Sum (Do not modify)
Sum:
lw $t0,8($sp)
lw $t1,4($sp)
add $t2, $t0, $t1
sw $t2,0($sp)
jr $ra
# Procedure Dif (Do not modify)
Dif:
lw $t0,8($sp)
lw $t1,4($sp)
sub $t2, $t0, $t1
sw $t2,0($sp)
jr $ra
End:
I NEED HELP WITH JUST THE MAIN FUNCTION AND GETTING THE CORRECT OUTPUTVALUE FOR EACH REGISTER. 3.11 Clone of LAB: Function calls
Given the following C program and the mapping of registers to variables, complete the MIPSzy 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?S=um(x,y);
z=Dif(y,x);
return 0; // Do not implement
}
Hints: Use program stack to pass arguments, return values, and preserve saved registers. Remember to pop the stack after each function
returns.
Ex: If the values of $ to and $ t 1 are initialized in the simulator as:
the results are stored in $t2 and $t3:
Note: Use the '+' button under the Registers display to initialize register values for $t0 and $t1.
Register $t0=5, $t1=10, $t2=15, $t3=5 after initializing them
 addi $sp, $zero, 8188 # Assume program stack starts at 8188.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!