Browse Source

* LDD/STD need always an offset, resolves #33086

git-svn-id: trunk@38072 -
florian 7 years ago
parent
commit
796eb542be
3 changed files with 25 additions and 10 deletions
  1. 1 0
      .gitattributes
  2. 15 10
      compiler/avr/agavrgas.pas
  3. 9 0
      tests/webtbs/tw33086.pp

+ 1 - 0
.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

+ 15 - 10
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];

+ 9 - 0
tests/webtbs/tw33086.pp

@@ -0,0 +1,9 @@
+{ %cpu=avr }
+program test;
+
+begin
+  asm
+    ldd r20, z+0
+    std y+0, r20
+  end;
+end.