Browse Source

* only check validity of assembler instructions in pass_2, after all
local operands have been resolved (mantis #8950)

git-svn-id: trunk@7516 -

Jonas Maebe 18 years ago
parent
commit
8bcb6e689d
4 changed files with 32 additions and 6 deletions
  1. 1 0
      .gitattributes
  2. 11 1
      compiler/ncgbas.pas
  3. 1 5
      compiler/x86/rax86.pas
  4. 19 0
      tests/webtbs/tw8950.pp

+ 1 - 0
.gitattributes

@@ -8270,6 +8270,7 @@ tests/webtbs/tw8861.pp svneol=native#text/plain
 tests/webtbs/tw8870.pp svneol=native#text/plain
 tests/webtbs/tw8883.pp svneol=native#text/plain
 tests/webtbs/tw8919.pp svneol=native#text/plain
+tests/webtbs/tw8950.pp svneol=native#text/plain
 tests/webtbs/tw8975.pp svneol=native#text/plain
 tests/webtbs/tw8975a.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain

+ 11 - 1
compiler/ncgbas.pas

@@ -268,8 +268,13 @@ interface
                              end;
                            end;
                         end;
+{$ifdef x86}
+                        { can only be checked now that all local operands }
+                        { have been resolved                              }
+                        taicpu(hp2).CheckIfValid;
+{$endif x86}
                      end;
-                   ait_marker :
+                  ait_marker :
                      begin
                      { it's not an assembler block anymore }
                        if (tai_marker(hp2).kind in [mark_AsmBlockStart, mark_AsmBlockEnd]) then
@@ -303,6 +308,11 @@ interface
                        { fixup the references }
                        for i:=1 to taicpu(hp).ops do
                          ResolveRef(taicpu(hp).oper[i-1]^);
+{$ifdef x86}
+                      { can only be checked now that all local operands }
+                      { have been resolved                              }
+                      taicpu(hp).CheckIfValid;
+{$endif x86}
                      end;
                 end;
                 hp:=tai(hp.next);

+ 1 - 5
compiler/x86/rax86.pas

@@ -744,11 +744,7 @@ begin
 
  { Concat the opcode or give an error }
   if assigned(ai) then
-   begin
-     { Check the instruction if it's valid }
-     ai.CheckIfValid;
-     p.concat(ai);
-   end
+    p.concat(ai)
   else
    Message(asmr_e_invalid_opcode_and_operand);
   result:=ai;

+ 19 - 0
tests/webtbs/tw8950.pp

@@ -0,0 +1,19 @@
+{ %cpu=i386,x86_64 }
+
+{$ifdef fpc}
+{$mode delphi}
+{$endif}
+
+procedure SetBitBuffer(var Value; const Bit: Cardinal);
+asm
+  BTS    [Value], Bit
+end;
+
+var
+  l: longint;
+begin
+  l := 0;
+  setbitbuffer(l,5);
+  if (l <> 32) then
+    halt(1);
+end.