The Gateway to Computer Science Excellence
+8 votes

A stack is used to pass parameters to procedures in a procedure call.

  1. If a procedure $P$ has two parameters as described in procedure definition:

    procedure P (var x :integer; y: integer);

    and if $P$ is called by ; $P(a, b)$

    State precisely in a sentence what is pushed on stack for parameters $a$ and $b$

  2. In the generated code for the body of procedure $P$, how will the addressing of formal parameters $x$ and $y$ differ?

in Compiler Design by Veteran (52.2k points)
edited by | 763 views
Someone please answer this

var x:integer means pointer and y:integer means variable

anyone confirm?

2 Answers

+4 votes
$a$ is pointer variable so address and $b$ is variable so its value pushed into stack.
by Veteran (60.6k points)
edited by
how is it identified that a  is pointer variable?

@Digvijay Pandey,  can you please explain it?

exactly !!!! how did you came to conclusion that the variable a is a pointer.
kindly explain !!!!!!

@Digvijay Pandey can you eexplain how is it identify....?????

please make your point clear
Pointers are language specific i guess. They have not aksed about c language.Some language might not support pointer.Solution should be generic i guess
dijvijay sir please explain

Since the variable x is passed by reference, it is a pointer to an integer. y is an integer variable. The syntax is of Pascal and it is not in syllabus anymore.


Yes I understood the syntax.

But how you came to the conclusion that it is passed by reference?
I read the article of tutorial's point.
+1 vote

For part a)

Push a
Push b

Now the producer can be called which then pushes its Return address into the Stack with a pointer SP.
To access these parameters we need to access [SP+2], [SP+4] (Stack fills from higher memory address to lower memory address, so if location 'a' is 10 and 'b' is 8 then SP will be on 6).

by Active (4.8k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,615 answers
102,333 users