ARM 64 assembler error: improper resulting machine code
Original Reporter info from Mantis: pik33
-
Reporter name: Piotr Kardasz
Original Reporter info from Mantis: pik33
- Reporter name: Piotr Kardasz
Description:
On RaspberryPi OS x64 I installed its default Lazarus 2.0.0 / fpc 3.0.4
Free Pascal Compiler version 3.0.4+dfsg-22 [2019/01/24] for aarch64
Then I built Lazarus 2.0.8 from the source
As my compiled program didn't work as expected, I started to debug and found this in the asm code:
retromalina.pas:867 add x4,x4,x12,lsl # 2
00000000004305F8 84000c8b add x4, x4, x12
The compiler omitted lsl#2 and compiled 84000c8b opcode instead of proper 8b0c0884 opcode of this instruction
Steps to reproduce:
Compile this project on RPiOs 64bit. Run it. "1" is written on the screen, should be "4"
program project1;
uses crt;
procedure test;
var a:uint64;
begin
asm
mov x4,# 0
mov x12,# 1
add x4,x4,x12,lsl # 2
str x4,a
end;
writeln(a);
end;
begin
test;
end.
Additional information:
A ugly workaround: manually assembling this instruction This:
asm
mov x4,# 0
mov x12,# 1
.long 0x8b0c0884 // add x4,x4,x12,lsl # 2
str x4,a
end;
gives a proper result.
I think (TODO: check it) more instruction with the syntax op xd,xn,xm,shift @q can be affected.
Mantis conversion info:
- Mantis ID: 37218
- Version: 2.0.8
- Fixed in version: 3.3.1