Procházet zdrojové kódy

* inline asm fix for accessing record variables when using the unitname (e.g.
'mov ax, unitname.varname.fieldname')

git-svn-id: trunk@38755 -

nickysn před 7 roky
rodič
revize
bbc364b245
3 změnil soubory, kde provedl 36 přidání a 0 odebrání
  1. 1 0
      .gitattributes
  2. 10 0
      compiler/rautils.pas
  3. 25 0
      tests/test/tasm26.pp

+ 1 - 0
.gitattributes

@@ -12577,6 +12577,7 @@ tests/test/tasm25ss0.pp svneol=native#text/plain
 tests/test/tasm25ss1.pp svneol=native#text/plain
 tests/test/tasm25ss1.pp svneol=native#text/plain
 tests/test/tasm25ss2.pp svneol=native#text/plain
 tests/test/tasm25ss2.pp svneol=native#text/plain
 tests/test/tasm25ss3.pp svneol=native#text/plain
 tests/test/tasm25ss3.pp svneol=native#text/plain
+tests/test/tasm26.pp svneol=native#text/plain
 tests/test/tasm2a.pp svneol=native#text/plain
 tests/test/tasm2a.pp svneol=native#text/plain
 tests/test/tasm3.pp svneol=native#text/plain
 tests/test/tasm3.pp svneol=native#text/plain
 tests/test/tasm4.pp svneol=native#text/plain
 tests/test/tasm4.pp svneol=native#text/plain

+ 10 - 0
compiler/rautils.pas

@@ -1509,6 +1509,16 @@ Begin
   else
   else
    begin
    begin
      asmsearchsym(base,sym,srsymtable);
      asmsearchsym(base,sym,srsymtable);
+     { allow unitname.identifier }
+     if assigned(sym) and (sym.typ=unitsym) then
+       begin
+         i:=pos('.',s);
+         if i=0 then
+          i:=255;
+         base:=base+'.'+Copy(s,1,i-1);
+         delete(s,1,i);
+         asmsearchsym(base,sym,srsymtable);
+       end;
      st:=nil;
      st:=nil;
      { we can start with a var,type,typedconst }
      { we can start with a var,type,typedconst }
      if assigned(sym) then
      if assigned(sym) then

+ 25 - 0
tests/test/tasm26.pp

@@ -0,0 +1,25 @@
+{ %CPU=i8086,i386,x86_64 }
+
+{$IFDEF FPC}
+{$MODE TP}
+{$ASMMODE INTEL}
+{$PIC OFF}
+{$ENDIF FPC}
+
+program tasm26;
+
+type
+  t = record
+    a: word;
+  end;
+
+var
+  v: t;
+
+procedure x; assembler;
+asm
+  mov ax, tasm26.v.a;
+end;
+
+begin
+end.