[fpc-pascal]Default calling convention
Thomas Schatzl
tom_at_work at gmx.at
Fri Jul 2 11:39:39 CEST 2004
Hello,
>>>>I noticed that, with FPC 1.9.4, the (default) calling convention
>>>>"register" depends on the fact that a routine is or is not embedded
>>>>in an other routine.
>>>>
>>>>With "proc(A,B,C: Longint);", if "proc" is not embedded then
>>>>eax = A, edx = B and ecx = C but if "proc" is embedded then edx = A,
>>>>ecx = B and C is on the stack.
>>>>
>>>>Is this convention definitive or temporary? I am not sure it is
>>>>definitive since it makes the code of assembler routines dependent
>>>>on their status: embedded or not.
This is exactly the same as Delphi (7) behaves.
>> procedure nx_fill(P: PLongword; Count: Longint; Value: Longword);
>> assembler;
>> asm
>> pushl %edi
>> movl %eax,%edi // edi <- P
>> movl %ecx,%eax // eax <- Value
>> movl %edx,%ecx // ecx <- Count
>> rep
>> stosl
>> popl %edi
>> end;
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.
Btw, there's already a method in the system unit which does the same
thing as your routine: filldword()...
Regards,
Thomas
More information about the fpc-pascal
mailing list