Variable Accesses Flashcards

1
Q

local variables

A

declared in the method that accesses them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

global variables

A

not declared in any method, accessible to all

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Non-local vars

A

variables declared in one sub-program and used in a nested sub-program
for dynamic scope, bars used in a method w/o being declared there

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

stack pointer points to

A

next 4-byte slot to use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

frame pointer points to

A

4-byte slot that holds the return address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are doubles stored

A

pairs of floating point registers with consecutive numbers {f0, f1}. Instructions only refer to the even numbered register of each pair

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

non-local vars in statically scoped languages

A

variable declared in one sub-program and accessed in another, nested sub program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Where are non-local vars stored in statically scoped languages?

A

Stored in the AR of the sub-program that declares them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens when non-local vars are used in statically scoped languages?

A

the activation record in which they are stored is found at runtime using access links or display

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can an activation record be found for statically scoped languages?

A

Access links or display

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do dynamically scoped languages work?

A

A variable can be declared in one method, and accessed in a called method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Idea of acess links

A

Add a new field to each AR
If P is nested inside Q, then at runtime P’s access link will point to the access link field in the AR of the most recent activation of Q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

For static scoping access links, how to determine how many links of the chain to follow at runtime

A

Use a “level number” attribute for the non-local variable, x, and “current level number” of the subprogram accessing x
If level i uses x and x was declared in level j, follow i-j links, then use x’s offset attribute to find x’s storage space in AR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Who is access link set up by?

A

calling procedure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

2 cases for how to set up access links?

A

1) calling procedure’s level is < the called procedure

2) calling procedure’s level is >= to the called procedure’s level

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If calling procedure’s level is < called procedure’s level (called procedure nested directly inside calling procedure)

A

The called procedure’s access link should point to the access link field of the calling procedure’s AR. The calling procedure sets up access link by pushing the value of FP just before the call

17
Q

If calling procedure’s level is >= to the called procedure’s level

A

The called procedure’s acces link should point to an AR that is already on the stack. The value for the new access link is found by starting with the value of the calling procedure’s access link field and following callingprocedure level-called procedure leve access links