Assembler (Intel) inconsistencies in 2.0.x, Was: Re: [fpc-devel] Bug: compilation loop in 2.0.2 when using -So

Konstantin Münning konstantin at muenning.com
Fri Aug 18 13:36:10 CEST 2006


Jonas Maebe wrote:
> 
> On 17 aug 2006, at 21:40, Konstantin Münning wrote:
> 
>> There are some other inconsistencies to previous versions of FPC and
>> Borland Pascal like assembler syntax and pointer addition
>> (inc(Pointer,LongInt) does not work anymore).
> 
> Please (as always) post a test program, because it works file for me
> with 2.0.4-rc3.

Here to demonstrate assembler problem:

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

Modifying like this fixes this:

PROGRAM Modified;
{$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.

Interestingly this works without complaints:

PROGRAM Working;
{$ASMMODE Intel}
 PROCEDURE Test;ASSEMBLER;
  VAR
   p:Pointer;
   l:LongInt;
   w:Word;
   b:Byte;
  ASM
   mov eax,[p]
   mov eax,[l]
   mov ax,[w]
   mov al,[b]
  END;

 VAR
  p:Pointer;
  l:LongInt;
  w:Word;
  b:Byte;
BEGIN
 ASM
  mov eax,[p]
  mov eax,[l]
  mov ax,[w]
  mov al,[b]
 END;
END.

Konstantin




More information about the fpc-devel mailing list