瀏覽代碼

* allow %seg. register:offset without (...), resolves #20035

git-svn-id: trunk@18861 -
florian 14 年之前
父節點
當前提交
7e537161c4
共有 4 個文件被更改,包括 54 次插入2 次删除
  1. 2 0
      .gitattributes
  2. 22 2
      compiler/x86/rax86att.pas
  3. 15 0
      tests/webtbs/tw20035a.pp
  4. 15 0
      tests/webtbs/tw20035b.pp

+ 2 - 0
.gitattributes

@@ -11751,6 +11751,8 @@ tests/webtbs/tw20003.pp svneol=native#text/pascal
 tests/webtbs/tw20005.pp svneol=native#text/pascal
 tests/webtbs/tw2001.pp svneol=native#text/plain
 tests/webtbs/tw2002.pp svneol=native#text/plain
+tests/webtbs/tw20035a.pp svneol=native#text/pascal
+tests/webtbs/tw20035b.pp svneol=native#text/pascal
 tests/webtbs/tw2004.pp svneol=native#text/plain
 tests/webtbs/tw2028.pp svneol=native#text/plain
 tests/webtbs/tw2030.pp svneol=native#text/plain

+ 22 - 2
compiler/x86/rax86att.pas

@@ -327,7 +327,7 @@ Implementation
                     begin
                       oper.opr.ref.refaddr:=addr_pic;
 {$ifdef x86_64}
-                      { local symbols don't have to 
+                      { local symbols don't have to
                         be accessed via the GOT
                       }
                       if (actasmpattern='GOTPCREL') and
@@ -449,7 +449,27 @@ Implementation
           begin
             MaybeBuildReference:=true;
             case actasmtoken of
-              AS_INTNUM,
+              AS_INTNUM:
+                Begin
+                  { allow %segmentregister:number }
+                  if oper.opr.ref.segment<>NR_NO then
+                    begin
+                      oper.InitRef;
+                      if oper.opr.Ref.Offset <> 0 Then
+                        Message(asmr_e_invalid_reference_syntax)
+                      else
+                        begin
+                          oper.opr.Ref.Offset:=BuildConstExpression(false,true);
+                          if actasmtoken=AS_LPAREN then
+                            BuildReference(oper);
+                        end;
+                    end
+                  else
+                    begin
+                      oper.opr.ref.offset:=BuildConstExpression(True,False);
+                      BuildReference(oper);
+                    end;
+                end;
               AS_MINUS,
               AS_PLUS:
                 Begin

+ 15 - 0
tests/webtbs/tw20035a.pp

@@ -0,0 +1,15 @@
+{ %cpu=i386 }
+{ %norun }
+program testasm;
+
+begin
+  {$asmmode intel}
+  asm
+    mov eax,gs:[0]
+  end;
+  {$asmmode att}
+  asm
+    mov %gs:0,%eax
+    mov %gs:(0),%eax
+  end;
+end.

+ 15 - 0
tests/webtbs/tw20035b.pp

@@ -0,0 +1,15 @@
+{ %cpu=x86_64 }
+{ %norun }
+program testasm;
+
+begin
+  {$asmmode intel}
+  asm
+    mov rax,gs:[0]
+  end;
+  {$asmmode att}
+  asm
+    mov %gs:0,%rax
+    mov %gs:(0),%rax
+  end;
+end.