Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given the following C program and the mapping of registers to variables, complete the MIPSzy implementation of function Sum. int Dif ( int a ,
Given the following C program and the mapping of registers to variables, complete the MIPSzy implementation of function Sum.
int Difint a int b
return ;
int Sumint int
int Dif;
int Dif;
return ;
int main
int ;
sum ;
return ;
addi $sp $zero, # Assume program stack starts at Do not modify.
# Procedure Main Do not modify
Main:
# Store arguments for Sum
addi $sp $sp # Push $t to stack
sw $t$sp
addi $sp $sp # Push $t to stack
sw $t$sp
addi $sp $sp # Push return value to stack
jal Sum
# Load return value
lw $t$sp
addi $sp $sp # Pop return value from stack
lw $t$sp
addi $sp $sp # Pop $t from stack
lw $t$sp
addi $sp $sp # Pop $t from stack
# Final additions
add $t $t $t
add $t $t $t
j End
# Procedure Sum
Sum:
# Type your code here.
# Procedure Dif Do not modify
Dif:
# Load arguments
lw $t$sp
lw $t$sp
sub $t $t $t
sw $t$sp # Push return value
jr $ra
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