Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
