Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Main routine M1 calls a procedure P1 (The return address is a value RM. Assume the initial stack pointer has a 32 bit value

1. Main routine M1 calls a procedure P1 (The return address is a value RM. Assume the initial stack pointer has a 32 bit value of 0x0700C. Procedure P1 will be using $s0, $s1, $s2 and need to be saved on the stack. RM (which is in $ra) need to be saved on the stack (since there is a call to another procedure). In P1, there is a call of procedure P2 (return address is a value RP1). Procedure P2 is likely to use $s4, $s5 (and hence need to be saved on stack). Show the SP value right after $s5 is saved. Also, show the stack contents (updated in this sequence).

2. Assume $t0 initially holds the value 0x00101000. slt $t2, $0, $t0 bne $t2, $0, ELSE j DONE ELSE: addi $t2, $t2, 5 DONE: a) What is the value of $t2 after the execution of the above instruction sequence? b) Write the corresponding machine code for bne and addi in this program. LAST NAME: FIRST NAME: PERSON#:

3. Consider the following MIPS loop: LOOP: slt $t2, $0, $t1 beq $t2, $0, DONE addi $t1, $t1, -1 addi $s2, $s2, 2 j LOOP DONE: (a) Assume that the initial value in register $t1 is 10 and $s2 is 0. What is the value in register $s2 after the above program sequence is executed? (b) Express the function implemented by the program sequence using a high level language sequence (such as using C code). Assume that the registers $s1, $s2, $t1, and $t2 are integers A, B, i, and j, respectively. (c) If register $t1 is initialized to the value N, how many times is the addi s2, s2, 2 instruction executed?

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

2. What is the business value of security and control?

Answered: 1 week ago