Question: 5. Consider the following MIPS assembly program with a leaf procedure call. Assume that the $sp is initialized to 7FFFEFFC hex, the text or code

5. Consider the following MIPS assembly program with a leaf procedure call. Assume that the $sp is initialized to 7FFFEFFC hex, the text or code segment starts at the memory address of 400100 hex, and the data segment is located starting at 10010000h for this program. Further, assume that the return address from the main procedure is 400000 hex. my_global: .word 100 text globl main 00400100 | main: 00400104 $sp, $sp,-4 addi sw ra, ($sp) # main calls a procedure so it should save its own return address on the stack $t1, ($s0) $a0, $t1, 1 leaf $t2, $vO, $0 # assume $sO has the address of my-global variable 00400108 004001OC 00400110 00400114 lw addi al add # call the leaf procedure $ra, ($sp) $sp, $sp, 4 # restore man's own return address from the stack 00400118 0040011c 00400120 lw addi ra 00400124 | leaf: 00400128 addi $v0, $a0, 1 # leaf procedure return value ra c) ldentify those instructions that access the data and stack segments in the main memory, and calculate the addresses of memory locations being accessed in the data and stack segments by those same MIPS assembly instructions in the above program. You must show explicitly each component of the calculated address. Instruction Memory Segment Memory Address Range Accessed (show detailed calculations and the computed final value) Accessed (Data or Stack) 5. Consider the following MIPS assembly program with a leaf procedure call. Assume that the $sp is initialized to 7FFFEFFC hex, the text or code segment starts at the memory address of 400100 hex, and the data segment is located starting at 10010000h for this program. Further, assume that the return address from the main procedure is 400000 hex. my_global: .word 100 text globl main 00400100 | main: 00400104 $sp, $sp,-4 addi sw ra, ($sp) # main calls a procedure so it should save its own return address on the stack $t1, ($s0) $a0, $t1, 1 leaf $t2, $vO, $0 # assume $sO has the address of my-global variable 00400108 004001OC 00400110 00400114 lw addi al add # call the leaf procedure $ra, ($sp) $sp, $sp, 4 # restore man's own return address from the stack 00400118 0040011c 00400120 lw addi ra 00400124 | leaf: 00400128 addi $v0, $a0, 1 # leaf procedure return value ra c) ldentify those instructions that access the data and stack segments in the main memory, and calculate the addresses of memory locations being accessed in the data and stack segments by those same MIPS assembly instructions in the above program. You must show explicitly each component of the calculated address. Instruction Memory Segment Memory Address Range Accessed (show detailed calculations and the computed final value) Accessed (Data or Stack)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
