Assembler (Intel) inconsistencies in 2.0.x, Was: Re: [fpc-devel] Bug: compilation loop in 2.0.2 when using -So
Jonas Maebe
jonas.maebe at elis.ugent.be
Fri Aug 18 14:52:41 CEST 2006
On 18 aug 2006, at 14:32, Marco van de Voort wrote:
>> presume that what we do is Delphi compatible. To, it seems more
>> like the TP/Delphi (and probably masm/tasm) behaviour of treating
>> "[p]" and "p" as the same thing was wrong. [] means a memory
>> reference and [p] should actually mean something like [[ebp+8]] or so
>> if p is stored at address ebp+8 (which is an addressing mode that is
>> not supported by the 80x86, but it is supported by e.g. the m68k).
>
> Sb (Carlo probably, since it was passcript) just remarked on IRC
> that the
> register convention is not compatible.
>
> The registers are pushed left to right (which I verified), while
> Delphi does
> right to left. (not verified)
The registers parameters contain the same values on FPC and Delphi.
What's different is the order in which parameters which do not fit in
registers are pushed. On FPC it's left to right, while Delphi does
right to left.
Kylix example:
procedure test(a,b,c,d,e: longint);
begin
end;
begin
test(1,2,3,4,5);
end.
Kylix generates:
0x0804d483 <PROGRAM+23>: push $0x4
0x0804d485 <PROGRAM+25>: push $0x5
0x0804d487 <PROGRAM+27>: mov $0x3,%ecx
0x0804d48c <PROGRAM+32>: mov $0x2,%edx
0x0804d491 <PROGRAM+37>: mov $0x1,%eax
0x0804d496 <PROGRAM+42>: call 0x804d41c <test>
We generate:
pushl $5
pushl $4
movl $3,%ecx
movl $2,%edx
movl $1,%eax
call P$PROGRAM_TEST$LONGINT$LONGINT$LONGINT$LONGINT$LONGINT
I don't understand the logic of what Delphi/Kylix does. The registers
are loaded from left to right, yet the other parameters are pushed
from right to left...
Jonas
More information about the fpc-devel
mailing list