Question: Can someone please help me fix my code the code is what is within main Given the following C program and the mapping of registers

Can someone please help me fix my code
the code is what is within main
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 = Sum(x, y); z = Dif(y, x); return 0; // Do not implement }
RegistersVariables$t0x$t1y$t2w$t3z
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 $t0 and $t1 are initialized in the simulator as:
RegistersData$t05$t110
the results are stored in $t2 and $t3:
RegistersData$t05$t110$t215$t35
Note: Use the '+' button under the Registers display to initialize register values for $t0 and $t1.
addi $sp, $zero, 8188 # Assume program stack starts at 8188. Do not modify.
# Procedure Main
Main:
# Type your code here.
addi $sp, $sp,-8
sw $t0,0($sp)
sw $t1,4($sp)
jal Sum
addi $sp, $sp,8
addi $sp, $sp,-8
sw $t0,0($sp)
sw $t1,4($sp)
jal Dif
lw $t3,0($sp)
addi $sp, $sp,8
j End
# 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: Initial storage
Resulting storage
Yours
Graded
Can someone please help me fix my code the code

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 Programming Questions!