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?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question

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?

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning