The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+6 votes
525 views

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 (59.5k points)
edited by | 525 views
+2
Someone please answer this
0

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 (55.4k points)
edited by
+1
how is it identified that a  is pointer variable?
+1

@Digvijay Pandey,  can you please explain it?

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

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

0
please make your point clear
0
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
0
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).

http://www.husseinsspace.com/teaching/udw/1996/asmnotes/chapfive.htm

answered by Active (3.9k points)


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

39,750 questions
46,765 answers
140,657 comments
58,517 users