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. 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

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions