Consider the following segment of code:procedure Mvar x: integer;procedure A (c: integer)var a, b: integer;procedure Bvar b, c, d: integer;begin {B}….a := c – d;….end B;begin {A}….x := b + c;….B()….end A;begin {M}….A(3)….end M;Assuming the definition of M is at static nesting level 0. Draw the runtime stack that will be ineffect at the execution of “a := c – d;”. Show the static and dynamic links, and the currentpositions of the EP and SP pointers.What is the static distance to x’s environment of definition and the offset within the environmentwhen “a := c – d;” is executed?

Question
Asked May 17, 2019
89 views

Consider the following segment of code:
procedure M
var x: integer;
procedure A (c: integer)
var a, b: integer;
procedure B
var b, c, d: integer;
begin {B}
….
a := c – d;
….
end B;
begin {A}
….
x := b + c;
….
B()
….
end A;
begin {M}
….
A(3)
….
end M;
Assuming the definition of M is at static nesting level 0. Draw the runtime stack that will be in
effect at the execution of “a := c – d;”. Show the static and dynamic links, and the current
positions of the EP and SP pointers.
What is the static distance to x’s environment of definition and the offset within the environment
when “a := c – d;” is executed?

check_circle

Expert Answer

Step 1

Instructions for drawing the runtime stack (at “a:= c-d;”):

  • The stack includes the activation records of the nested procedures.
  • Mention the local variables, parameters, return address, dynamic links, and static links.
  • The dynamic link of a procedure always points to the caller procedure.
  • The static link of a procedure points to the most recent occurrence of an activation record of the static parent of the procedure being called.
  • The EP or FP points to the frame base of the current caller.
  • The SP points to the next available stack location.
Step 2

The runtime s...

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: What form of storage doses a password manger store encrypted passwords? Is it local, web sites, clod...

A: Passwords managers allows one to generate strong and unique passwords and store them in one safe pla...

question_answer

Q: Register A holds the 8-bit binary 11011001. Determine the B operand and the logic microoperation to ...

A: Selective Complement: this operations complement the bits in register A for which the corresponding ...

question_answer

Q: Find context-free grammars for the following languages (with n ≥ 0, m ≥ 0, k ≥ 0):  L = {anbmck, k =...

A: Solution:Given language,L = {anbmck, k = n+m}Consider the “G” as grammar production is given below:

question_answer

Q: Write a grammar for the language consisting of strings built only of theletters aand b. The strings ...

A: The given language L contains the strings that have infinite number of letters but the strings must ...

question_answer

Q: Define a class called Player that implements Comparable <Player> with health and name attribut...

A: The question posed here is an extremely long and complex one, so we have judiciously attempted to pr...

question_answer

Q: 2. What are ‘accelerated filers’ and how are they selected- revenue, # employee, etc.

A: If a company meets the following conditions at the fiscal year end, it is considered as accelerated ...

question_answer

Q: Write a GUI application that calculates a car’s gas mileage. The application should let the user ent...

A: Program plan:Test.javaImport the required header filesDefine “Test” classCreate an object for the “M...

question_answer

Q: • Write a program in Eclipse that computes future investment value at a given interest rate for a sp...

A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named “comp...

question_answer

Q: I need help with creating a main.css, I already have the HTML.the details are in the pic and I will ...

A: You can use following code in your main.css file to format your HTML document.Note: Make use of <...