c262f98f

c262f98f - CSc 262 Final Examination Saturday, 12 December...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSc 262 Final Examination Saturday, 12 December 1998 4-7 PM Page 1 Suggested answers will be posted on CSCKAY shortly after 7. Name_____________________________________________________________________ 1. (25 pts) In this question I ask you to provide the details of the activation records for the Pascal program below. Beside each statement in the program is the (hypothetical) decimal address for the start of the machine code for the statement. For example, the start of the code that includes instructions for executing A[H]:=B[H]+1 is located at 1120. Write a description of the stack of activation records with three columns. The first column should be labeled "memory address" and have the decimal address of the first byte of the given structure. The second column should be labeled "item" and name the item which is being stored in the memory location. The third column should be labeled "value" and have the numerical value stored in the memory location (provided it can be computed). Assume that INTEGERs take two byte of memory, REALs three bytes, and addresses four bytes. Assume that the base (beginning) address of the stack is 4000. Write the details of the stack when the line marked with the comment (*POINT 1*) has been reached. Assume that static chains are used for implementing non-local references. Some notes on the program below: (1) Comments start with (* and end with *). (2) A formal parameter preceded by the keyword VAR is passed by reference; otherwise the parameter is passed by value. (3) In the declaration of PROCEDURE TWO, when I write A:RAY I am declaring the parameter A to be an ARRAY[3. .5] OF REAL. PROGRAM ZERO; TYPE RAY=ARRAY[3. .5] OF REAL; VAR I:INTEGER; X:RAY; PROCEDURE TWO(VAR A:RAY; B:RAY; H:INTEGER); VAR J:INTEGER; BEGIN A[H]:=B[H]+1; (*1120*) J:=H+4; (*1150*) (*POINT 1*) END(*PROCEDURE TWO*); (*1160*) BEGIN FOR I:=3 TO 5 DO (*1000*) X[I]:=I; TWO(X,X,4); (*1020*) WRITELN(OUTPUT,X[4]); (*1040*) END. (*1060*) Memory Address Item Value 4050 J 8 4048 H 4 4045 B[5] 5 4042 B[4] 4 4039 B[3] 3 4035 Addr A 4014 4031 Dynamic Pointer 4023
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4027 Static Pointer 4000 4023 Return Address 1040 <^^^^^^^THREE^^^^^^^^^> 4020 X[5] 5 4017 X[4] 5 4014 X[3] 3 4012 I 5 or 6 (????) 4008 Dynamic Pointer 4000 4004 Static Pointer ???? 4000 Return Address ???? 2. (25 pts) In the table below I have labeled the rows with the names of five languages, and I have labeled the columns with five properties a given language may or may not have. Fill in the 25 cells of the table by placing a Y in the cell if the language in the cell's row has the property in the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

c262f98f - CSc 262 Final Examination Saturday, 12 December...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online