瀏覽代碼

* support local labels in references

git-svn-id: trunk@764 -
peter 20 年之前
父節點
當前提交
2e00bd1480
共有 4 個文件被更改,包括 42 次插入2 次删除
  1. 2 0
      .gitattributes
  2. 9 2
      compiler/i386/ra386int.pas
  3. 16 0
      tests/webtbf/tw3931b.pp
  4. 15 0
      tests/webtbs/tw3931a.pp

+ 2 - 0
.gitattributes

@@ -5489,6 +5489,7 @@ tests/webtbf/tw3738.pp svneol=native#text/plain
 tests/webtbf/tw3740.pp svneol=native#text/plain
 tests/webtbf/tw3790.pp svneol=native#text/plain
 tests/webtbf/tw3841.pp svneol=native#text/plain
+tests/webtbf/tw3931b.pp svneol=native#text/plain
 tests/webtbf/tw3969.pp svneol=native#text/plain
 tests/webtbf/tw4103.pp svneol=native#text/plain
 tests/webtbf/tw4104.pp svneol=native#text/plain
@@ -6114,6 +6115,7 @@ tests/webtbs/tw3898.pp svneol=native#text/plain
 tests/webtbs/tw3899.pp svneol=native#text/plain
 tests/webtbs/tw3900.pp svneol=native#text/plain
 tests/webtbs/tw3913.pp svneol=native#text/plain
+tests/webtbs/tw3931a.pp svneol=native#text/plain
 tests/webtbs/tw3939.pp svneol=native#text/plain
 tests/webtbs/tw3953a.pp svneol=native#text/plain
 tests/webtbs/tw3953b.pp svneol=native#text/plain

+ 9 - 2
compiler/i386/ra386int.pas

@@ -1095,6 +1095,7 @@ Unit Ra386int;
         hreg : tregister;
         GotStar,GotOffset,HadVar,
         GotPlus,Negative : boolean;
+        hl : tasmlabel;
       Begin
         Consume(AS_LBRACKET);
         if not(oper.opr.typ in [OPR_LOCAL,OPR_REFERENCE]) then
@@ -1114,8 +1115,6 @@ Unit Ra386int;
               Begin
                 if not GotPlus then
                   Message(asmr_e_invalid_reference_syntax);
-                if actasmpattern[1] = '@' then
-                 Message(asmr_e_local_label_not_allowed_as_ref);
                 GotStar:=false;
                 GotPlus:=false;
                 if SearchIConstant(actasmpattern,l) or
@@ -1168,6 +1167,14 @@ Unit Ra386int;
                       if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then
                         oper.SetSize(typesize,true);
                     end
+                   else
+                    if is_locallabel(tempstr) then
+                      begin
+                        CreateLocalLabel(tempstr,hl,false);
+                        oper.InitRef;
+                        oper.opr.ref.symbol:=hl;
+                        oper.hasvar:=true;
+                      end
                    else
                     if oper.SetupVar(tempstr,GotOffset) then
                      begin

+ 16 - 0
tests/webtbf/tw3931b.pp

@@ -0,0 +1,16 @@
+{ %fail }
+{ %cpu=i386 }
+
+{$asmmode intel}
+
+procedure SmallForwardMove_3; assembler;
+asm
+jmp dword ptr [@@FwdJumpTable+@@FwdJumpTable+ecx*4]
+nop {Align Jump Table}
+@@Done:
+@@FwdJumpTable:
+dd @@Done {Removes need to test for zero size move}
+end;
+
+begin
+end.

+ 15 - 0
tests/webtbs/tw3931a.pp

@@ -0,0 +1,15 @@
+{ %cpu=i386 }
+
+{$asmmode intel}
+
+procedure SmallForwardMove_3; assembler;
+asm
+jmp dword ptr [@@FwdJumpTable+ecx*4]
+nop {Align Jump Table}
+@@Done:
+@@FwdJumpTable:
+dd @@Done {Removes need to test for zero size move}
+end;
+
+begin
+end.