Unit 4 Run-Time Storage Organization
Unit 4 Run-Time Storage Organization
code
storage space that won’t
static data change: global data,
constant, ...
stack
actual parameters
local data
temporaries
• Links:
. Access (or static) link: a pointer to places of non-local data,
stack
AR 1
FP
AR 2
SP
main{
stack stack stack stack
r(); main
q(1);
} main main main main
r{ r q(1)
...}
r q(1) q(1)
q(int i)
{
if(i>0) then q(i-1) q(0) q(0)
}
P() FP
{
I
int I,J,K; J A.R. for P
... when called
K
}
program main
procedure P main(1)
depth=3 procedure R
end
depth =2 R Q(2)
end
depth=1 procedure Q P(2)
depth =2 P
end R(3)
dynamic link static link
Q (access)
end.
Effect:
• Changing a formal parameter (in the called procedure) does affect the
corresponding actual.
• Side effects.