Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[6 points] Consider the following code written in a language with static scoping and nested subprograms. Assume that a is called from main function

[6 points] Consider the following code written in a language with static scoping and nested subprograms. Assume that a is called from main function and on the bottom of the stack there is the activation record instance for main. Additionally, activations records (AR) of all related subprograms are given. What are the offset pairs (in the form of (chain offset, local offset) ) of all the variables in lines designated by pos1 and pos2? function a() { int y,z; function b() { int y; function c() { int x; x = y + z; // posl } C(); } function d(int i) { int x; function e() { int x,y: d(5); x = y + i; // pos2 if (i>0) then b(); else e(); d(e); AR for a AR for d AR for e Local z Localy Dynamic link AR for b AR for c Local x Local y Local y Local x Param i Local x Dynamic link Dynamic link Static link Dynamic link Static link ynamic link Static link Static link Static link Return addr. Return addr. Return addr. Return addr. Return addr. Pos1 x: ( * ) y: ( )z:( Pos2 x: ( : ) y: ( + )i: (

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Pos1 x21 y11 z21 Pos2 x12 y11 i22 chain offset l... 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

A Balanced Introduction to Computer Science

Authors: David Reed

3rd edition

132166755, 978-0132166751

More Books

Students also viewed these Programming questions

Question

Consider the following code: For (i = 0; i Answered: 1 week ago

Answered: 1 week ago

Question

Know what happens when a company declares a dividend

Answered: 1 week ago