瀏覽代碼

handle correctly "reg+const" operands in avr assembler, fixes issue #32016

git-svn-id: trunk@37328 -
florian 7 年之前
父節點
當前提交
1c69ae6a15
共有 3 個文件被更改,包括 17 次插入7 次删除
  1. 4 5
      compiler/avr/agavrgas.pas
  2. 12 2
      compiler/avr/raavrgas.pas
  3. 1 0
      tests/webtbs/tw32150.pp

+ 4 - 5
compiler/avr/agavrgas.pas

@@ -104,7 +104,7 @@ unit agavrgas;
                     NR_R30:
                       s:=s+'Z';
                     else
-                      s:=gas_regname(base);
+                      s:=s+gas_regname(base);
                   end;
                   if addressmode=AM_POSTINCREMENT then
                     s:=s+'+';
@@ -112,7 +112,7 @@ unit agavrgas;
                   if offset>0 then
                     s:=s+'+'+tostr(offset)
                   else if offset<0 then
-                    s:=s+tostr(offset)
+                    s:=s+tostr(offset);
                 end
               else if assigned(symbol) or (offset<>0) then
                 begin
@@ -157,9 +157,8 @@ unit agavrgas;
                 begin
                   hs:=ReplaceForbiddenAsmSymbolChars(o.ref^.symbol.name);
                   if o.ref^.offset>0 then
-                   hs:=hs+'+'+tostr(o.ref^.offset)
-                  else
-                   if o.ref^.offset<0 then
+                    hs:=hs+'+'+tostr(o.ref^.offset)
+                  else if o.ref^.offset<0 then
                     hs:=hs+tostr(o.ref^.offset);
                   getopstr:=hs;
                 end

+ 12 - 2
compiler/avr/raavrgas.pas

@@ -514,9 +514,19 @@ Unit raavrgas;
                   oper.opr.typ:=OPR_REFERENCE;
 
                   reference_reset_base(oper.opr.ref,tempreg,0,1,[]);
-                  oper.opr.ref.addressmode:=AM_POSTINCREMENT;
 
-                  consume(AS_PLUS);
+                  { add a constant expression? }
+                  if actasmtoken=AS_PLUS then
+                    begin
+                      consume(AS_PLUS);
+                      if actasmtoken in [AS_INTNUM,AS_ID] then
+                        begin
+                          l:=BuildConstExpression(true,false);
+                          inc(oper.opr.ref.offset,l);
+                        end
+                      else
+                        oper.opr.ref.addressmode:=AM_POSTINCREMENT;
+                    end;
                 end
               else if (actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) then
                 Begin

+ 1 - 0
tests/webtbs/tw32150.pp

@@ -7,6 +7,7 @@ procedure test(out x: byte); assembler; nostackframe;
 asm
   movw R30, R24
   st Z, R1
+  ldd r22, z+3
 end;
 
 var a8: byte;