Hello all!
Today, I have finally updated Lazarus to new version (2.2.2, FPC 3.2.2) - I was using Laz 2.0.8 (FPC 3.0.4) - and tried to compile some of my code to see what is broken
.
I have found that the x64 compiler simply ignores size of integer parameters in assembly. Let's have following code:
{$MODE ObjFPC}
{$ASMMODE Intel}
...
procedure Foo(Value: Byte); register; assembler;
asm
MOVZX EDX, Value
end;
In x86, this is correctly compiled as
... but in x64, the compiler just throws error:
Error: Asm: [movzx reg32,reg32] invalid combination of opcode and operands
Ok, I can work around it - for example not using parameter names and writing the registers directly (which is annoying as they differ in windows and linux). But it gets worse, because this:
procedure Foo(Value: Byte); register; assembler;
asm
MOV DL, Value
end;
... is in x64 compiled as:
which is imho totally wrong, and no error or warning is issued. If you expect higher 24bits of EDX to be preserved (they should be), you are in for a nasty surprise. The same happens whether you use Intel or ATT syntax.
This was not hapenning in FPC 3.0.4 that I was using before, there it produces:
Am I wrong here, am I missing something, or is this a bug? And is it known? If this is to be expected, can someone point me to some documentation describing this?
Note - I am not able to go and try newer FPC versions.