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 Ssp is initialized to 7FFFEFFC hex, the text or code

image text in transcribed

image text in transcribed

image text in transcribed

5. Consider the following MIPS assembly program with a leaf procedure call. Assume that the Ssp 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 : addi 00400104 $sp, $sp,-4 # main calls a procedure so it should save its own return address on the stack lw $t1, ($s0) addi $a0, $t1, 1 a leaf add St2, Sv0. S0 # assume $s0 has the address of my-global variable 00400108 004001OC 00400110 00400114 # call the leaf procedure $ra, ($sp) $sp, $sp, 4 # restore main'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 ill need to trace the execution of theentieprogram 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 Sra, (Ssp) jal leaf r Sra (in leaf) lw Sra, ($sp) addi Ssp, Ssp, 4 jr Sra (in main) Ssp Sra pc b) What are the values of all affected registers (except pc, Ssp, and $ra) immediately after each indicated instruction in the below table is executed during the execution of the above MIPS assembly program? As an example if a register such as the t0 is affected e.g register value changed and its new value is 2 n decimal then represent the change using the name of the register and its new value as follows: St0-2. Use both binary and hexadecimal numbers to represent register contents Instruction Register-Value Pair Register-Value Pair ister-Value Pair sw $ra, (Ssp) lw St1, ($s0) addi $a0, St1, 1 add $12, SvO, $0 c) Identify 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 Ssp 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 : addi 00400104 $sp, $sp,-4 # main calls a procedure so it should save its own return address on the stack lw $t1, ($s0) addi $a0, $t1, 1 a leaf add St2, Sv0. S0 # assume $s0 has the address of my-global variable 00400108 004001OC 00400110 00400114 # call the leaf procedure $ra, ($sp) $sp, $sp, 4 # restore main'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 ill need to trace the execution of theentieprogram 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 Sra, (Ssp) jal leaf r Sra (in leaf) lw Sra, ($sp) addi Ssp, Ssp, 4 jr Sra (in main) Ssp Sra pc b) What are the values of all affected registers (except pc, Ssp, and $ra) immediately after each indicated instruction in the below table is executed during the execution of the above MIPS assembly program? As an example if a register such as the t0 is affected e.g register value changed and its new value is 2 n decimal then represent the change using the name of the register and its new value as follows: St0-2. Use both binary and hexadecimal numbers to represent register contents Instruction Register-Value Pair Register-Value Pair ister-Value Pair sw $ra, (Ssp) lw St1, ($s0) addi $a0, St1, 1 add $12, SvO, $0 c) Identify 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

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

Students also viewed these Databases questions

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago

Question

Compare levels of resolution in conflict outcomes?

Answered: 1 week ago

Question

Strategies for Managing Conflict Conflict Outcomes?

Answered: 1 week ago