







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








high-level code assembly code machine code
Compiler Assembler
x = 3 causes 3 to be stored at address 0. y = 9.9 causes 9.9 to be stored at address 4 z[1] = x+4 causes 3+4=7 to be stored at address 12+(1*4)=
Address Value 0: 3 4 : 9. 8: 12: 16: 7 20: 24:
Address Allocated To Value 0 x 3 4 y 9. 8 12 z 16 7 20 24
int fop(int x,int y) { int z; x = x+1; z = x; y=5+z; return y; } main () { int x; x = 9; x = foo(x,9); } }
Address Allocated To Value 0 x 9 15 4 fop return value 15 8 x 9 10 12 y 15 16 z 10 20
Main’s activation record Fop’s activation record
z = x + y;
y = x + z;
Address Allocated To Value 0 a 9 25 4 b 17 8 foo return value 17 12 x 7 8 16 &y 20 z 17 24
Main’s activation record Foo’s activation record
struct Composite { int field1[4]; int field2; } main () { Composite c; c.field2=8; } The following is a valid trace: Address Allocated To Value 0 c.field1[0] 4 c.field1[1] 8 c.field1[2] 12 c.field1[3] 16 c.field2 8
Main’s activation record
p_c = new Composite;
p_x = new int(2);
main () { int x; Composite c; // the struct defined above int *p_x; Composite *p_c; p_c = new Composite; p_x = new int; p_x = 5; (p_c).field1[1] = 4; p_c = &c; p_x++; }
Stack Address Allocated To Value 0 x 4 c.field ... 20 c.field 24 p_x 1020 1024 28 p_c 1000 4 Heap 1000 *p_c.field 1004 4 1008 1012 1016 *p_c.field 1020 *p_x 5 1024
Main’s activation record
data = x*2; } } Stack Address Allocated To Value 0 foo^ ^ 4 foo^ ^ 8 x 4 Heap 1000 foo.data 8 1004 foo.data
Main’s activation record meth's activation record