The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+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?

asked in Compiler Design by Veteran (52k points)
edited by | 662 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.
answered by Veteran (59.8k 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
0 votes

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).

answered by Active (4.3k 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
49,535 questions
54,117 answers
71,028 users