DO NOT COPY AND PASTE THE OTHER ANSWERS ON answers!12.10 LAB: Nested procedures
addi $sp, $zero, 6000 # Assume Stack memory starts at6000. Do not modify.
# Procedure Main (Do not modify)Main: add $a0, $zero, $s0 add $a1, $zero, $s1 jal Sum add $s2, $s0, $s1 add $s2, $s2, $v0 j End
# Procedure SumSum: # Type your code here.
# Procedure Dif (Do not modify)Dif: sub $v0, $a1, $a0 jr $ra
End:
Given the following C program and the mapping of registers to variables, complete the MIPS implementation of procedure Sum. int Dif(int a, int b) { return ba; int Sum (int m, int n) { int p = Dif(n+1, m-1); int q = Dif (m+1, n-1); return p + q; int main() { int x, y; z = x + y + Sum(x, y); return 0; } Registers Variables $50 $s1 $s2 X y Z Note: Use the '+' button under the Registers display to initialize register values for $s0 and $s1. Hints: Use stack memory as needed and follow register conventions.
Registers Variables $s0 $s1 $s2 the result is stored in $s2: X y Z Note: Use the '+' button under the Registers display to initialize register values for $50 and $s1. Hints: Use stack memory as needed and follow register conventions. Ex: If the values of $s0 and $s1 are initialized in the simulator as: Registers Data $s0 5 $s1 10 Registers Data $50 $$1 $s2 сл 10 11
DO NOT COPY AND PASTE THE OTHER ANSWERS ON answers! 12.10 LAB: Nested procedures addi $sp, $zero, 6000 # Assume Stack me
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am