Procedural Abstraction Homework 4: Drawing Activation Records for Given Pascal Program, Assignments of Computer Science

A homework assignment from a pascal programming course, where students are required to draw the set of activation records on the stack just prior to the return from function f1 in the given pascal program. Students must include all entries in the ars, use line numbers for return addresses, draw directed arcs for access links, and label the values of local variables and parameters. Each ar must be labeled with its procedure name.

Typology: Assignments

Pre 2010

Uploaded on 08/16/2009

koofers-user-6d3
koofers-user-6d3 🇺🇸

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework 4: Procedural abstraction(15pts)
Due Oct 27, 2008
Sec6.5, Problem1. For the following Pascal program, draw the set of activation records that are on the
stack just prior to the return from function F1. Include all entries in the ARs. Use
line numbers for return addresses. Draw directed arcs for access linkes. Clearly label
the values of local variables and parameters. Label each AR with its procedure name.
1 program main(input, output);
2 procedure P1( function g(b: integer) : integer);
3 var a : integer;
4 begin
5 a := 3;
6 writeln(g(2))
7 end;
8 procedure P2;
9 var a: integer;
10 function F1(b : integer) : integer;
11 begin
12 F1 := a + b
13 end
14 procedure P3;
15 var a: integer;
16 begin
17 a := 7;
18 P1(F1)
19 end;
20 begin
21 a := 0;
22 P3
23 end;
24 begin
25 P2
26 End.
1

Partial preview of the text

Download Procedural Abstraction Homework 4: Drawing Activation Records for Given Pascal Program and more Assignments Computer Science in PDF only on Docsity!

Homework 4: Procedural abstraction(15pts)

Due Oct 27, 2008

Sec6.5, Problem1. For the following Pascal program, draw the set of activation records that are on the stack just prior to the return from function F1. Include all entries in the ARs. Use line numbers for return addresses. Draw directed arcs for access linkes. Clearly label the values of local variables and parameters. Label each AR with its procedure name.

1 program main(input, output); 2 procedure P1( function g(b: integer) : integer); 3 var a : integer; 4 begin 5 a := 3; 6 writeln(g(2)) 7 end; 8 procedure P2; 9 var a: integer; 10 function F1(b : integer) : integer; 11 begin 12 F1 := a + b 13 end 14 procedure P3; 15 var a: integer; 16 begin 17 a := 7; 18 P1(F1) 19 end; 20 begin 21 a := 0; 22 P 23 end; 24 begin 25 P 26 End.