* patch by Christo Crause to support ~ in att assembler

* allow -128 to 255 as a constant for instructions taking a byte sized constants (this is also what GNU As accepts), resolves #32039

git-svn-id: trunk@38316 -
This commit is contained in:
florian 2018-02-22 20:14:56 +00:00
parent 2b2d41aa27
commit d0dd3bd74e
5 changed files with 21 additions and 10 deletions

1
.gitattributes vendored
View File

@ -15955,6 +15955,7 @@ tests/webtbs/tw3190.pp svneol=native#text/plain
tests/webtbs/tw31945.pp svneol=native#text/pascal
tests/webtbs/tw3197.pp svneol=native#text/plain
tests/webtbs/tw32019.pp svneol=native#text/plain
tests/webtbs/tw32039.pp svneol=native#text/pascal
tests/webtbs/tw32040.pp svneol=native#text/pascal
tests/webtbs/tw32043.pp svneol=native#text/pascal
tests/webtbs/tw32046.pp svneol=native#text/plain

View File

@ -71,11 +71,11 @@ unit raavr;
// A_SUB
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_all), (typ: top_reg; rt: rt_all), (typ: top_none), (typ: top_none))),
// A_SUBI
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: 0), (typ: top_none), (typ: top_none))),
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: -128), (typ: top_none), (typ: top_none))),
// A_SBC
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_all), (typ: top_reg; rt: rt_all), (typ: top_none), (typ: top_none))),
// A_SBCI
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: 0), (typ: top_none), (typ: top_none))),
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: -128), (typ: top_none), (typ: top_none))),
// A_SBRC
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_all), (typ: top_const; max: 7; min: 0), (typ: top_none), (typ: top_none))),
// A_SBRS
@ -85,11 +85,11 @@ unit raavr;
// A_AND
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_all), (typ: top_reg; rt: rt_all), (typ: top_none), (typ: top_none))),
// A_ANDI
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: 0), (typ: top_none), (typ: top_none))),
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: -128), (typ: top_none), (typ: top_none))),
// A_OR
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_all), (typ: top_reg; rt: rt_all), (typ: top_none), (typ: top_none))),
// A_ORI
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: 0), (typ: top_none), (typ: top_none))),
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: -128), (typ: top_none), (typ: top_none))),
// A_EOR
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_all), (typ: top_reg; rt: rt_all), (typ: top_none), (typ: top_none))),
// A_COM
@ -97,9 +97,9 @@ unit raavr;
// A_NEG
(numOperands: (1 shl 1); Operands: ((typ: top_reg; rt: rt_all), (typ: top_none), (typ: top_none), (typ: top_none))),
// A_SBR
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: 0), (typ: top_none), (typ: top_none))),
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: -128), (typ: top_none), (typ: top_none))),
// A_CBR
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: 0), (typ: top_none), (typ: top_none))),
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: -128), (typ: top_none), (typ: top_none))),
// A_INC
(numOperands: (1 shl 1); Operands: ((typ: top_reg; rt: rt_all), (typ: top_none), (typ: top_none), (typ: top_none))),
// A_DEC
@ -145,7 +145,7 @@ unit raavr;
// A_CPC
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_all), (typ: top_reg; rt: rt_all), (typ: top_none), (typ: top_none))),
// A_CPI
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: 0), (typ: top_none), (typ: top_none))),
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: -128), (typ: top_none), (typ: top_none))),
// A_SBIC
(numOperands: (1 shl 2); Operands: ((typ: top_const; max: 31; min: 0), (typ: top_const; max: 7; min: 0), (typ: top_none), (typ: top_none))),
// A_SBIS
@ -157,7 +157,7 @@ unit raavr;
// A_MOVW
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_even), (typ: top_reg; rt: rt_even), (typ: top_none), (typ: top_none))),
// A_LDI
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: 0), (typ: top_none), (typ: top_none))),
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_16_31), (typ: top_const; max: 255; min: -128), (typ: top_none), (typ: top_none))),
// A_LDS TODO: There are 2 versions with different machine codes and constant ranges. Could possibly distinguish based on size of PC?
// Perhaps handle separately with a check on sub-architecture? Range check only important if smaller instruction code selected on larger arch
(numOperands: (1 shl 2); Operands: ((typ: top_reg; rt: rt_all), (typ: top_const; max: 65535; min: 0), (typ: top_none), (typ: top_none))),

View File

@ -343,7 +343,8 @@ Unit raavrgas;
AS_INTNUM,
AS_MINUS,
AS_PLUS:
AS_PLUS,
AS_NOT:
Begin
if (actasmtoken=AS_MINUS) and
(actopcode in [A_LD,A_ST]) then

View File

@ -794,7 +794,7 @@ unit raatt;
exit;
end;
'!' :
'!', '~' :
begin
actasmtoken:=AS_NOT;
c:=current_scanner.asmgetchar;

9
tests/webtbs/tw32039.pp Normal file
View File

@ -0,0 +1,9 @@
{ %cpu=avr }
{ %norun }
const
foo = %00011000;
begin
asm
andi r16, ~foo
end;
end.