[fpc-devel] Strange assembler from 2.7.1

Martin lazarus at mfriebe.de
Thu Sep 6 23:00:47 CEST 2012


To start with, I have very sittle info, so this may not lead anywhere.
But then again, I was unable to reproduce it myself. So I would 
appreciate any hint what I may be looking for...

I discovered this while debugging a PascalScript issue.

The environment:
- A macbook. 64 bit intel (Owned by Mattias)
- FPC 2.7.1 - 32 bit - exact revision unknown - supposedly build without 
any extra arguments to make

In unit classes is the following procedure

function Point(AX, AY: Integer): TPoint;
begin
   with Result do
   begin
     X := AX;
     Y := AY;
   end;
end;

Being called from PascalScript it did not work.
A copy taken to a new unit and compiled with the very same fpc, and it did.

Stopping in the disassemble view (using asm single stepping) the point 
in classes had the below asm:

CLASSES_POINT$LONGINT$LONGINT$$TPOINT
0010BAF0 83ec0c                   sub    $0xc,%esp
0010BAF3 890424                   mov    %eax,(%esp)
0010BAF6 89542404                 mov    %edx,0x4(%esp)
0010BAFA 8b0424                   mov    (%esp),%eax
0010BAFD 8b542404                 mov    0x4(%esp),%edx
0010BB01 83c40c                   add    $0xc,%esp
0010BB04 c3                       ret


I don't have the exact copy of the asm for the case where the function 
was compiled in a unit outside the RTL, but it used eax,ecx,edx. And eax 
would be the pointer to the record (result:TPoint). Above the result is 
at -12(esp)


For now, my question is: What settings could get fpc to generate the 
above code?




More information about the fpc-devel mailing list