From 796eb542be51256ef392a4cf93e9406fe4e4125c Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 28 Jan 2018 21:06:13 +0000 Subject: [PATCH] * LDD/STD need always an offset, resolves #33086 git-svn-id: trunk@38072 - --- .gitattributes | 1 + compiler/avr/agavrgas.pas | 25 +++++++++++++++---------- tests/webtbs/tw33086.pp | 9 +++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 tests/webtbs/tw33086.pp diff --git a/.gitattributes b/.gitattributes index 8ad7bf889d..d1f542dab2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15965,6 +15965,7 @@ tests/webtbs/tw3294a.pp svneol=native#text/plain tests/webtbs/tw3298.pp svneol=native#text/plain tests/webtbs/tw33004.pp svneol=native#text/pascal tests/webtbs/tw3301.pp svneol=native#text/plain +tests/webtbs/tw33086.pp svneol=native#text/pascal tests/webtbs/tw3309.pp svneol=native#text/plain tests/webtbs/tw3320.pp svneol=native#text/plain tests/webtbs/tw3324.pp svneol=native#text/plain diff --git a/compiler/avr/agavrgas.pas b/compiler/avr/agavrgas.pas index f3b9e9b5fe..89d807cbbc 100644 --- a/compiler/avr/agavrgas.pas +++ b/compiler/avr/agavrgas.pas @@ -75,6 +75,9 @@ unit agavrgas; Procedure TAVRInstrWriter.WriteInstruction(hp : tai); + var + op: TAsmOp; + function getreferencestring(var ref : treference) : string; var s : string; @@ -107,12 +110,14 @@ unit agavrgas; s:=s+gas_regname(base); end; if addressmode=AM_POSTINCREMENT then - s:=s+'+'; - - if offset>0 then - s:=s+'+'+tostr(offset) - else if offset<0 then - s:=s+tostr(offset); + s:=s+'+' + else if addressmode = AM_UNCHANGED then + begin + if (offset>0) or ((offset=0) and (op in [A_LDD,A_STD])) then + s:=s+'+'+tostr(offset) + else if offset<0 then + s:=s+tostr(offset); + end; end else if assigned(symbol) or (offset<>0) then begin @@ -174,10 +179,10 @@ unit agavrgas; end; end; - var op: TAsmOp; - s: string; - i: byte; - sep: string[3]; + var + s: string; + i: byte; + sep: string[3]; begin op:=taicpu(hp).opcode; s:=#9+gas_op2str[op]+cond2str[taicpu(hp).condition]; diff --git a/tests/webtbs/tw33086.pp b/tests/webtbs/tw33086.pp new file mode 100644 index 0000000000..24a2c05061 --- /dev/null +++ b/tests/webtbs/tw33086.pp @@ -0,0 +1,9 @@ +{ %cpu=avr } +program test; + +begin + asm + ldd r20, z+0 + std y+0, r20 + end; +end.