[fpc-pascal]Default calling convention

Thomas Schatzl tom_at_work at gmx.at
Fri Jul 2 19:31:30 CEST 2004


Hello,

>>
>>In this case
>>
>>   procedure nx_fill(P: PLongword; Count: Longint; Value: Longword);
>>   assembler;
>>   asm
>>           pushl   %edi
>>           movl    P,%edi  // edi <- P
>>           movl    Value,%eax  // eax <- Value
>>           movl    Count,%ecx  // ecx <- Count
>>           rep
>>           stosl
>>           popl    %edi
>>   end;
>>
>>works both as embedded and non-embedded assembler procedure because the
>>order of assignments is ok in both cases.
> 
>  
> Yes, but this way a program becomes a mineland. You write this, a few 
> weeks later, for some reason, you change the line order, and you waste 
> time to find why, suddenly, your program crashes (and yet, assuming you
> immediately activate the bug).

:( That's true.

I usually add a 'pascal' procedure modifier to most (if not all) 
assembler routines exactly because of that. This forces parameter 
passing on the stack.
This is a little slower, but if your hand-coded assembler proc is only 
faster if the parameters are passed through registers, it might be a 
good idea to use Pascal right away...

Regards,
   Thomas





More information about the fpc-pascal mailing list