AVR - assembler parser incorrectly coverts a negative const to unsigned const
Original Reporter info from Mantis: ccrause @ccrause
-
Reporter name: Christo Crause
Original Reporter info from Mantis: ccrause @ccrause
- Reporter name: Christo Crause
Description:
TOprRec definition in rautils.pas defines the type of the val field as word for AVR. When an AVR assembler constant is added as a constant operand in TInstruction.ConcatInstruction by calling ai.loadconst the word value gets converted to tcgint (Int64) and loses its sign.
The attached patch performs a type cast to int16 to preserve the sign.
Steps to reproduce:
Compile following example:
program test;
begin
asm
rjmp -2
end;
end.
Additional information:
Generated assembler snippet:
# CPU AVR5 .Ll2: # [5] rjmp -2
rjmp 65534
Mantis conversion info:
- Mantis ID: 32946
- Build: r37889
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 38291 (#87318541)