The activation record for a call to f would appear as Offset ofx Control linl fp Offset of c Return address a0] Offset of a Offset of
Offset of x fp Offset of c Offset of a Offset of y The activation record for a call to f would appear as x c Control link Return address a[9] … a[1] a[0] y
Assuming two bytes for integers, four bytes for addresses one byte for character and eight bytes for double-precision floating point, we would have the following offset values Name Offset +5 +4 24 32 Now, an access of, would require the computation of the address (-24+2*1)(fp)
Name Offset x +5 c +4 a -24 y -32 Assuming two bytes for integers, four bytes for addresses, one byte for character and eight bytes for double-precision floating point, we would have the following offset values: Now, an access of a[i], would require the computation of the address: (-24+2*i)(fp)
For the expression: (X=X+3)+ 4, the p code and three-address code Lad x Lod x Ldc 3 Adi t1=x+3 Stn X=tl Ldc 4 Adi t2=t1+4
• For the expression: ( x = x +3 ) + 4, the pcode and three-address code: Lad x Lod x Ldc 3 Adi t1=x+3 Stn x=t1 Ldc 4 Adi t2=t1+4
8.6.1 The borland 3.0 C Compiler for the 80X86
8.6.1 The Borland 3.0 C Compiler for the 80X86
Consider the examples of the output of this compiler with the following assignment (X=x+3)+4 The assembly code for this expression as produced by the borland 3.0 compiler for the Intel 80X86 is as follows mov ax, word ptr [bp-2 add ax. 3 mov word ptr [bp-2, ax add ax. 4 Notes The bp is used as the frame pointer The static simulation method is used to convert the intermediate code into the target code
• Consider the examples of the output of this compiler with the following assignment (x = x +3 ) + 4 • The assembly code for this expression as produced by the Borland 3.0 compiler for the Intel 80x86 is as follows: mov ax, word ptr [bp-2] add ax, 3 mov word ptr [bp-2], ax add ax, 4 • Notes: – The bp is used as the frame pointer. – The static simulation method is used to convert the intermediate code into the target code