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 13:42:02 CEST 2006


On 18 aug 2006, at 13:36, Konstantin Münning wrote:

> PROGRAM Original;
> {$ASMMODE Intel}
>  PROCEDURE Test(p:Pointer;l:LongInt;w:Word;b:Byte);ASSEMBLER;
>   ASM
>    mov eax,[p]
>    mov eax,[l]
>    mov ax,[w]
>    mov al,[b]
>   END;
> BEGIN
> END.
>
> This program is like the code I'm using which works with fpc 1.0.10  
> and
> BP (BP is 16 bit only so without eax). FPC 2.0.x complains on the mov
> ax,[w] with the error(s):
>
> original.pas(7,13) Error: Asm: 16 Bit references not supported
> original.pas(7,13) Error: Asm: Invalid effective address

That's because the default calling convention is now register instead  
of oldfpccall. p is now passed in eax, l in edx and w in cx. So the  
the compiling is complaining because the above now means "mov ax, [cx]".

Add {$calling stdcall} (or alternatively {$calling oldfpccall}, but  
that's not encouraged since this calling convention is FPC-specific)  
to you source to switch back to passing all parameters on the stack.


Jonas


More information about the fpc-devel mailing list