COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
positive
|
|
negative
|
|
May be positive or negative
|
|
Cannot be accessed
|
Detailed explanation-1: -Local variables (including parameters) are stored in the activation record of the method in which they are declared. They are accessed at runtime using an offset from the frame pointer (FP). Since we’re assuming that “up” in the stack means a lower address, these offsets will be negative numbers.
Detailed explanation-2: -An activation record contains all the necessary information required to call a procedure. An activation record may contain the following units (depending upon the source language used). Stores temporary and intermediate values of an expression. Stores local data of the called procedure.
Detailed explanation-3: -Temporary values, such as those arising from the evaluation of expressions, in cases where those cannot be held in registers. Therefore, Direct Link is not present in activation record of procedure.
Detailed explanation-4: -Activation record for factorial(1) (called by factorial(2)) is seup similarly. factorial(1) calculates the result and returns it by setting the value at return value location and pops off it local variables and sets back the base pointer.
Detailed explanation-5: -What is the difference between an activation record and an activation record instance? An activation record is the format, or layout, of the moncode part of a subprogram, whereas an activation record instance is a concrete example of an activation record, a collection of data in the form of an activation record.