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

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. data my_global:.word 100 text globl main 00400100 | main : 00400104 addi SW $sp, $sp,-4 # main calls a procedure so it should save its own return address on the stack 00400108 0040010C 00400110 00400114 $t1, ($sO) $a0, $t1, 1 leaf $t2, SvO, $0 # assume $sO has the address of my-global variable lw addi # call the leaf edure add 00400118 00400110 00400120 Iw Sra, ( # restore man's own return address from the stack ra 00400124 | leaf: 00400128 addi $VO, $a0, 1 # leaf procedure return value ra Page 4 of6 a) A subset of instructions from the above MIPS program is given below, while also observing the order of execution. Trace the execution of the above program and enter (in hex) the contents of each indicated register of the CPU in the table below. The values of indicated registers should be those that materialize following the execution of the corresponding instruction on that row in the table. Note that you wil need to trace the execution of the entire program instruction-by- nstruction to be able to determine the values for the registers for each instruction included in the table. Ssp Sra pc addi sw $ra, (Ssp) jal r Sra (in leaf) addi Ssp, Ssp, 4 ir Sra (in main) 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. data my_global:.word 100 text globl main 00400100 | main : 00400104 addi SW $sp, $sp,-4 # main calls a procedure so it should save its own return address on the stack 00400108 0040010C 00400110 00400114 $t1, ($sO) $a0, $t1, 1 leaf $t2, SvO, $0 # assume $sO has the address of my-global variable lw addi # call the leaf edure add 00400118 00400110 00400120 Iw Sra, ( # restore man's own return address from the stack ra 00400124 | leaf: 00400128 addi $VO, $a0, 1 # leaf procedure return value ra Page 4 of6 a) A subset of instructions from the above MIPS program is given below, while also observing the order of execution. Trace the execution of the above program and enter (in hex) the contents of each indicated register of the CPU in the table below. The values of indicated registers should be those that materialize following the execution of the corresponding instruction on that row in the table. Note that you wil need to trace the execution of the entire program instruction-by- nstruction to be able to determine the values for the registers for each instruction included in the table. Ssp Sra pc addi sw $ra, (Ssp) jal r Sra (in leaf) addi Ssp, Ssp, 4 ir Sra (in main)

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