1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NikAS [45]
3 years ago
10

For the (pseudo) assembly code below, replace X, Y, P, and Q with the smallest set of instructions to save/restore values on the

stack and update the stack pointer. Assume that procA and procB were written independently by two different programmers who are following the MIPS guidelines for caller-saved and callee-saved registers. In other words, the two programmers agree on the input arguments and return value of procB, but they can't see the code written by the other person.(50 points)
procA:
$s0 = ...
$s1 = ...
$s2 = ...
$t0 = ...
$t1 = ...
$t2 = ...
X
$a0 = ...
$a1 = ...
jal procB
Y
... = $s1
... = $t0
... = $t1
... = $a0
jr $ra

procB:
P
... = $a0
... = $a1
$s2 = ...
$t0 = ...
Q
jr $ra
Computers and Technology
1 answer:
Dimas [21]3 years ago
8 0

Answer:

Explanation:

Let us first consider the procedure procA; the caller in the example given.

  Some results: $s0,$s1,$s2, $t0,$t1 and $t2 are being stored by procA. Out of these registers, few registers are accessing by procA after a call to procB. But, procB might over-write these registers.

       Thus, procA need to save some registers into stack first before calling procB, .

      only $s1,$t0 and $t1 are being used after return from procB in the given example,

       Caller saves and restores only values in $t0-$t9, according to MIPS guidelines for caller-saved and callee-saved registers, .

       Thus, procA needs to save only $t0 and $t1.

    jal instruction overwrites the register $ra by writing the address, to which the control should jump back, after completing the instructions of procB, when procB is called,.

       Therefore, procA also need to save $ra into stack.

 ProcA is writing new values into $a0,$a2, procA must save $a0 and $a1 first before calling procB, .

     In the given example, after return from procB, only $a0 is being used. It is therefore enough to save $a0.

   Also, procA needs to save frame pointer, which points the start of the stack space for each procedure.

       Generally, as soon as the procedure begins, frame pointer is set to the current value of the stack pointer,.

Let us consider the procedure procB; the callee in the given example.

 The callee is responsible for saving values in $s0-$s7 and restoring them before returning to caller, this is according to MIPS guidelines for caller-saved and callee-saved registers,

   procB is expected to over-write the registers $s2 and $t0. Nonetheless, in the first two lines, procB might over-write the registers $s0 and $s1.

   Thus, procB is responsible for saving and restoring $s0,$s1 and $s2.

X:

We need to create space for 5 values on the stack since procA needs to save $a0,$ra,$t0,$t1 and $fp(frame pointer), . Each value(word) takes 4 bytes.

$sp = $sp – 20 # on the stack, create space for 5 values

sw $a0, 16($sp) # store the result in $a0 into the memory address

               # indicated by $sp+20

sw $ra, 12($sp) # save the second value on stack

sw $t0, 8($sp) # save the third value on stack

sw $t1, 4($sp) # save the fourth value on stack

sw $fp, 0($sp) #  To the stack pointer, save the frame pointer

$fp = $sp      #  To the stack pointer, set the frame pointer

Y:

lw $fp, 0($sp) #  from stack, start restoring values

lw $t1, 4($sp)

lw $t0, 8($sp)

lw $ra, 12($sp)

lw $a0, 16($sp)

$sp = $sp + 20 # decrease the size of the stack

P:

$sp = $sp – 12 #  for three values, create space on the stack

sw $s0, 0($sp) # save the value in $s0

sw $s1, 0($sp) # save the value in $s1

sw $s2, 0($sp) # save the value in $s2

Q:

lw $s0, 0($sp) #  from the stack, restore the value of $s0

lw $s1, 0($sp) #  from the stack, restore the value of $s1

lw $s2, 0($sp) #  from the stack, restore the value of $s2

$sp = $sp + 12 # decrease the stack size

You might be interested in
Which of the following defines slander?
Harlamova29_29 [7]

Answer:

Btw its C.

Explanation:

4 0
4 years ago
If you want the date in your document to update each time the document is opened, _____.
den301095 [7]
By clicking the update automatically<span> checkbox when inserting the date and/or time into a Word document... hope this helps!!!!</span>
8 0
3 years ago
Read 2 more answers
Please help me ASAP!
netineya [11]

Answer:

loser

Explanation:

5 0
3 years ago
Read 2 more answers
1
Effectus [21]

Answer:

1. Modularity.

2. Refinement.

3. Structural partitioning.

4. Data Structure.

Explanation:

A software development life cycle (SDLC) can be defined as a strategic process or methodology that defines the key steps or stages for creating and implementing high quality software applications. There are six (6) main stages in the creation of a software and these are;

1. Planning.

2. Analysis.

3. Design.

4. Development (coding).

5. Deployment.

6. Maintenance.

One of the most important steps in the software development life cycle (SDLC) is design. It is the third step of SDLC and comes immediately after the analysis stage.

Basically, method design is the stage where the software developer describes the features, architecture and functions of the proposed solution in accordance with a standard. Some of the models or techniques used in the design of a software are;

  • Modularity: refers to the concept that software architecture has the ability to divide into modules and that each
  • module can be examined independently.
  • Refinement: is a process that elaborates on each design component until it reaches the coding details.
  • Structural partitioning: allows designers to split a program structure horizontally and vertically.
  • Data Structure: represents logical relationships between individual data elements.
4 0
3 years ago
Where in the Backstage view can you add the Developer tab to the ribbon?
valina [46]

Backstage view can be added to the Developer tab to the ribbon by Options setting

  • Options

<u>Explanation:</u>

On the File tab, go to Options > Customize Ribbon. Under Customize the Ribbon and under Main Tabs, select the Developer checkbox. To show the tab, click on the File menu and afterward select Options starting from the drop menu. At the point when the Excel Options window shows up, click on the Customize Ribbon alternative on the left.

Snap on the Developer checkbox under the rundown of Main Tabs on the right. At that point click on the OK button. Right-Click on the Ribbon and select Customize the Ribbon. On the correct side of the exchange take care of that pops is a rundown of Ribbon tabs, Check the container for the Developer tab.

4 0
3 years ago
Other questions:
  • A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never
    7·1 answer
  • What is a software that allows the user to modify and redistribute?
    11·1 answer
  • Value or power of a network grows exponentially as a function of the number of network members. this is known as ________ law.
    8·1 answer
  • If my_string = "This is MY string!", why does print (my_string[0:7:5]) return "Ti" and not
    11·1 answer
  • A _____ is often used in Access to present a menu with command buttons that end users can click to perform various database acti
    13·1 answer
  • Lee has changed the style of his table to make the header row stand out. Next, he wants to center the text in the header row and
    11·2 answers
  • Please help i only have 20 minuets
    5·1 answer
  • Select all the correct answers.
    5·1 answer
  • The library Wi-Fi kiosk requires a symmetric connection to the Internet. Which WAN technology would probably be the least expens
    8·1 answer
  • Plz help me I will mark as the brainlest I only need long answer plz help me ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!