Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 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 will need to trace the execution of the entire program instruction-by- instruction to be able to determine the values for the registers for each instruction included in the table Instructions addi Ssp, Ssp. -4 sw $ra, (Ssp) jal leaf jr Sra (in leaf) lw Sra, (Ssp) addi Ssp, Ssp, 4 jr Sra (in main) ra pc 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 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 will need to trace the execution of the entire program instruction-by- instruction to be able to determine the values for the registers for each instruction included in the table Instructions addi Ssp, Ssp. -4 sw $ra, (Ssp) jal leaf jr Sra (in leaf) lw Sra, (Ssp) addi Ssp, Ssp, 4 jr Sra (in main) ra pc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

long term effects of the american revolution

Answered: 1 week ago