Question: 5 9 . 9 LAB: Function calls Given the following C program and the mapping of registers to variables, complete the MIPSzy implementation of Main.
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 ; 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;
zDify x;
return ; 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 $ t and $ are initialized in the simulator as:
begintabularcc
hline Registers & Data
hline St &
hline $t &
hline
endtabular
the results are stored in St and $ mathrmt :
begintabularcc
hline Registers & Data
hline $t &
hline$ mathbft &
hline mathbf$ t & mathbf
hline mathbf$ t & mathbf
hline
endtabular
Note: Use the button under the Registers display to initialize register values for $t and St
begintabularccc
hline multicolumnlLine pddi $sp$zero, # Assume progri
hline Line & &
hline Line & # Procedure Main &
hline Line & Main: &
hline Line & # Type your code h & here.
hline Line & &
hline Line & &
hline Line & j End &
hline Line & &
hline multicolumnlLine # Procedure Sum Do not modify
hline Line & Sum: &
hline Line & Iw $t$sp &
hline Line & lw $t$sp &
hline Line & add $t$t$t &
hline
endtabular
Line
add $ mathrmt$ mathrmttheta$ mathrmtl
Line
sw $t$sp
Line
jr $ra
Line
Line # Procedure Dif Do not modify
Line Dif:
Line Iw $t$sp
Line lw $t$sp
Line sub $ t $ t $ t
Line
Line
sw $t$sp
Line
jr $ra
Line End:
Line
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
