
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 1
This page cannot be seen from the preview
Don't miss anything!

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.