Run-stack and activation record management

Assignment Help Programming Languages
Reference no: EM131276757

Programming Languages

Assignment

Q1) For the program below show the output. (for space you can place the three values printed by P1 on the same line.

Assume static scoping
PROGRAM EX1;
int i; // global
int A[3]; // global

PROCEDURE P1( int x, int y)
Begin

END;

y := 2; PRINT(x); i := 3; PRINT(x); i := 3; PRINT(x); PRINT(y)

BEGIN //main
A[1]:= 7; A[2]:= 13; A[3]:= 11;
i := 1;
P1(A[i], i); // first call
P1(i, A[i]); // second call
END.

a) x is passed by value and y is passed by value.

b) x is passed by value and y is passed by name.

c) x is passed by name and y is passed by value.

d) x is passed by name and y is passed by name.

Q2. For the program below show the output
Assume static scoping
PROGRAM EX2;
int N; int M; // global

PROCEDURE P1(int x, int y, int z) BEGIN

END;

x := 1;
z := x + y;

BEGIN
N := 2; M := 0
P1 (N, N, M)
PRINT (M);
END.

a) What is printed for M if parameters passed by reference?

b) What is printed for M if parameters passed by value-results?

Q3. For the program below show the output
Assume static scoping
PROGRAM EX3;
int k; // global

PROCEDURE P1(int x)
BEGIN
x := 2;
x := x + k;
END;

BEGIN

END.

k := 1; P1(k);
PRINT (k);

a) What is printed for k if pass by value ?

b) What is printed for k if pass by results ?

Q4. Many programming languages allow unrestricted GOTO statements which allow a programmer to use a GOTO to jump to any visible LABEL. Thinking about the run-stack and activation record management,

a) Though looking very efficient in terms of a quick jump to distant code why may it cause some efficiency problems during execution? Explain.

Q5) Show (draw) the runtime-stack with AR(s) for the following. Include static and dynamic link information (dashed arrows) as used in fig. 10.9 Assume the execution is at the ground condition when it becomes true!!!!
PROGRAM EX5;

PROCEDURE P2(int y)
PROCEDURE P1(int x) // P1 is nested in P2 BEGIN
if (x < 0 ) // ground condition
return;
else P1 (x-1);
END;
BEGIN
P1 (y);
END;
// main driver
BEGIN
P2(3) //assume P2 will be first AR on stack!
END.

Reference no: EM131276757

Questions Cloud

What is the utilization of the servers : In a bank, there are six tellers. The arrival rate of customers is 5 per hour, and the mean service time is 18 minutes. What is the utilization (as a percentage) of the servers?
Concepts associated with corporate governance : The following are concepts associated with corporate governance except:
How to react in life threatening situations : A tactical training company that provides self-defense lessons and teaches people how to react in life threatening situations. Security services will be providing security for people during events. Target market: colleges, public places, celebs, busi..
Manufacturers and sellers of defective medical devices : Do you think manufacturers and sellers of defective medical devices should be subject to civil litigation or criminal prosecution or both? Explain your answer. (Health Management class )
Run-stack and activation record management : Though looking very efficient in terms of a quick jump to distant code why may it cause some efficiency problems during execution? Explain - Show (draw) the runtime-stack with AR(s) for the following. Include static and dynamic link information
Identify the companys stakeholders : Key Parties. (1)Who are the principal parties (i.e., the key parties) involved in the case study?List and briefly identify them.(2) For the primary business in the case studyonly, (a) identify the company's stakeholders.
What makes any corporation or business accountable : If Congress did not mandate the valve by law here in the US, what then makes corporations accountable in this area? What makes any corporation or business accountable to the environment in which does it business?
Why you support or oppose adding the proposed equal rights : Write a 200 to 500 word explanation of why you support or oppose adding the proposed Equal Rights Amendment to Constitution. Make sure that you include some discussion of 14th Amendment levels of scrutiny in your explanation.
Does one store seem to be more trend right than the other : Does one store seem to be more "trend-right" than the other? What is the mix of staple, fashion or fad merchandise in each retailer?

Reviews

Write a Review

Programming Languages Questions & Answers

  Describe the most challenging aspect of the assignment

Describe the most challenging aspect of the assignment. Describe the most difficult aspect of the assignment to understand. Provide any suggestions for improving the assignment in the future.

  Write a program to enter any number of integers in array

Write a program which permits a user to enter any number of integers, which are then stored in the array. After user enters integers, perform the following operations on array.

  Write a program using the rand function

Write a program using the rand() function and a large array to find the standard deviation, variance and mean as well as the min and max values of the array.

  Application to convert kilometers in miles

Application will input number of kilometers, compute number of miles, and display number of miles. You will use a constant to store the kilometers-to-miles conversion factor.

  Create block using a loop to determine number of items

Create a block using a loop that will determine the number of items that can be purchased based on the price of the item and the total amount available to spend.

  Create a shell script that will list files in a directory

This option instructs the program to display a long listing. The output shall display the following column headers

  Issues into account for collecting user data via forms

In addition to making our forms easy to use we need to consider user privacy and the use of data. What are some of the issues which you believe you require to take into account for collecting user data via forms?

  Implement shape hierarchy-compute area of two-dimensional

Implement Shape hierarchy. Each TwoDimensionalShape must contain function getArea to compute the area of two-dimensional shape. Each ThreeDimensionalShape must have member functions.

  Write a program that opens a file and reads in two vectors

Write a program that opens a file, reads in two vectors, and then computes their dot product

  Program to output circle-s radius-diameter-circumference

Write a program to prompt the user to enter center and a point on circle. Program must then output circle's radius, diameter, circumference, and area.

  Write an assembly program that computes factorial

Write an assembly program that computes f(1), f(2), f(3),..., and f(10). Note that n! is defined as follows: or . Also, note that 1! = 0! = 1.

  Write a program to input a purchase amount

Write a program to input a purchase amount and calculate the sales tax and total do. The SalesTax depends on the county identifying code

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd