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

  Calculate the area and perimeter of a rectangle

Design and write a program, using functions, that calculates the area and perimeter of a rectangle whose dimensions (length and width) are provided by a user.

  Demonstrates a basic knowledge of the programming language

Write a 2-3 page report over your programming languages topic. This may be either a paper or 2 pages of code that demonstrates a basic knowledge of the programming language.

  Assembly language instructions into machine code

The assembly instructions are stored in a file. Each line of the file stores exactly oneinstruction. The name of the file should be provided to the program as a command line argument.

  Construct a markov algorithm

Construct a Markov Algorithm that will reverse the order of an input string that consists of zero or more upper case letters - It will always have the following effect: whatever is on the RHS of that rule (except the period, if there is one) will b..

  Design pseudocode to enter names of two primary colors

Design a pseudocode program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than "red", "blue", or "yellow".

  Advantages of the common language runtime

What are the advantages of the Common Language Runtime in .NET

  Write program to calculate distance and time hurricane take

Write C++ program that will calculate the distance and time it will take (days/hours) for hurricane to reach Ft. Lauderdale if: Hurricane is at coordinates 16 N, 64 W, just SE of South Fla. off in Atlantic, with a speed of 20 mph.

  Write a new class file with a main() method in the project

Write a new class file with a main() method in the same project, use it to load in the names.txt, sort the names, and store them to a file called, nameout.txt. Each name on its own line.

  Write statement to assign new value to element of array

Write a single statement that assigns a new value to element of the array indexed by j . This new value should be equal to twice the value stored in the next element of the array.

  2 steps of handling data and invoking procedures

2 steps of handling data and invoking procedures2 steps of handling data and invoking procedures

  Describe benefits of code citations to avoid plagiarism.

Describe some benefits of code citations in addition to avoiding plagiarism.

  Writes a function that takes a list of integers

Using ML writes a function that takes a list of integers as argument and returns a pair consisting of the sum of the even position and the sum of the odd positions of the list. You should not use auxiliary functions

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