[fpc-devel] Strange assembler from 2.7.1
jonas.maebe at elis.ugent.be
Thu Sep 6 23:18:24 CEST 2012
On 06 Sep 2012, at 23:00, Martin wrote:
> Stopping in the disassemble view (using asm single stepping) the point in classes had the below asm:
> 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?
It's the default setting on Darwin/i386 and iPhoneSim/i386, because that's how its ABI prescribes that small records should be returned. Apparently there's a check for cdecl/cppdecl/mwpascal missing in the parameter manager for that platform, although until now nobody noticed.
All those custom calling conventions on i386 are a real pain, especially on platforms where they have absolutely no use or right of existence other than the fact that everyone and their uncle insists on writing inline assembler code in when programming in FPC/Delphi/TP.
More information about the fpc-devel