Question: Computer Architecture: adding to stack with MIPS # 8 only Questions(7) and (8), use high-level language source code for a procedure/function in the C language
Computer Architecture: adding to stack with MIPS # 8 only
Questions(7) and (8), use high-level language source code for a procedure/function in the C language int leaf_example (int g, int h, int i, int j) { int f = (g + h) - (1 + j); return f; } and the code translated by a compiler of that procedure/function into MIPS assembly language leaf example: addi $sp, $sp, -12 sw $t0, 4Ssp) sw $S0, 0 (Ssp) add $t0, Sa0, $al add $tl, $a2, ?a2 sub $s0, $t0, $tl lw $S0, 0 (Ssp) lw $t0, 4($sp) lw $tl, 8 ($sp) addi $sp, $sp, 12 r Sra The value of the C language parameters g, h, i, and j are kept in the MIPS registers $a0, $al, Sa2, and $a3, respectively (7) In the calculation f (g + h) - (i + j) a) What is the command in the assembly language program that is calculating (g h) b) What is the command in the assembly language program that is calculation j): c) What register contains the value for f: d) What registers have values that are being removed/popped on the stack at the beginning of leaf_example, and what registers have values that are being placed/pushed off of the stack at the end of leaf example: (8) There are three values being placed/pushed on the stack just before leaf example ends a) Which position is f being placed/pushed on the stack? That is, of the three values being placed on the stack, is fbeing placed/pushed on the stack first, second, or third b) A value that is placed at the bottom of a stack requires that all of the items on the stack be removed/popped in order to make the value appear at the top of the stack. A value that is placed at the top of a stack is always the first value that is allowed to be removed/popped from the stack. Given that, how many pops would it take to remove f from the stack, one, two, or three: c) The purpose of leaf example is to return a value. Which register contains the value that leaf_example will return d) When values are being removed/popped off the stack at the beginning of leaf_example, is the stack pointer being increased or decreased? e) By how many bytes is the stack pointer being changed when values are being removed/popped f) When values are being placed/pushed on the stack at the end of leaf_example, is the stack pointer being increased or decreased? g) By how many bytes is the stack pointer being changed when values are being placed/pushed Questions(7) and (8), use high-level language source code for a procedure/function in the C language int leaf_example (int g, int h, int i, int j) { int f = (g + h) - (1 + j); return f; } and the code translated by a compiler of that procedure/function into MIPS assembly language leaf example: addi $sp, $sp, -12 sw $t0, 4Ssp) sw $S0, 0 (Ssp) add $t0, Sa0, $al add $tl, $a2, ?a2 sub $s0, $t0, $tl lw $S0, 0 (Ssp) lw $t0, 4($sp) lw $tl, 8 ($sp) addi $sp, $sp, 12 r Sra The value of the C language parameters g, h, i, and j are kept in the MIPS registers $a0, $al, Sa2, and $a3, respectively (7) In the calculation f (g + h) - (i + j) a) What is the command in the assembly language program that is calculating (g h) b) What is the command in the assembly language program that is calculation j): c) What register contains the value for f: d) What registers have values that are being removed/popped on the stack at the beginning of leaf_example, and what registers have values that are being placed/pushed off of the stack at the end of leaf example: (8) There are three values being placed/pushed on the stack just before leaf example ends a) Which position is f being placed/pushed on the stack? That is, of the three values being placed on the stack, is fbeing placed/pushed on the stack first, second, or third b) A value that is placed at the bottom of a stack requires that all of the items on the stack be removed/popped in order to make the value appear at the top of the stack. A value that is placed at the top of a stack is always the first value that is allowed to be removed/popped from the stack. Given that, how many pops would it take to remove f from the stack, one, two, or three: c) The purpose of leaf example is to return a value. Which register contains the value that leaf_example will return d) When values are being removed/popped off the stack at the beginning of leaf_example, is the stack pointer being increased or decreased? e) By how many bytes is the stack pointer being changed when values are being removed/popped f) When values are being placed/pushed on the stack at the end of leaf_example, is the stack pointer being increased or decreased? g) By how many bytes is the stack pointer being changed when values are being placed/pushed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
