Selaa lähdekoodia

* fixed bug in intel syntax i8086 inline asm, when certain 'jmp/call [v]'
instructions got erroneously converted to 'jmp/call v', if 'v' is an external
far variable that points to certain things (like a local label, exported via
public)

git-svn-id: trunk@37538 -

nickysn 7 vuotta sitten
vanhempi
commit
9450beb99c
2 muutettua tiedostoa jossa 10 lisäystä ja 1 poistoa
  1. 7 0
      compiler/rautils.pas
  2. 3 1
      compiler/x86/rax86int.pas

+ 7 - 0
compiler/rautils.pas

@@ -87,6 +87,10 @@ type
   TOperand = class
     opr    : TOprRec;
     typesize : byte;
+    haslabelref,      { if the operand has a label, used in a reference like a
+                        var (e.g. 'mov ax, word ptr [label+5]', but *not*
+                        e.g. 'jmp label') }
+    hasproc,          { if the operand has a procedure/function reference }
     hastype,          { if the operand has typecasted variable }
     hasvar : boolean; { if the operand is loaded with a variable }
     size   : TCGSize;
@@ -636,6 +640,7 @@ end;
 constructor TOperand.Create;
 begin
   size:=OS_NO;
+  hasproc:=false;
   hastype:=false;
   hasvar:=false;
   FillChar(Opr,sizeof(Opr),0);
@@ -964,6 +969,7 @@ Begin
         else
           Message(asmr_e_invalid_operand_type);
         end;
+        hasproc:=true;
         hasvar:=true;
         SetupVar:=TRUE;
         Exit;
@@ -984,6 +990,7 @@ Begin
               exit;
             end;
         end;
+        haslabelref:=true;
         hasvar:=true;
         SetupVar:=TRUE;
         Exit;

+ 3 - 1
compiler/x86/rax86int.pas

@@ -2332,7 +2332,9 @@ Unit Rax86int;
             begin
               { convert 'call/jmp [proc/label]' to 'call/jmp proc/label'. Ugly,
                 but Turbo Pascal 7 compatible. }
-              if (instr.opcode in [A_CALL,A_JMP]) and (typ=OPR_REFERENCE) and
+              if (instr.opcode in [A_CALL,A_JMP]) and
+                 (instr.operands[i].haslabelref or instr.operands[i].hasproc)
+                 and (typ=OPR_REFERENCE) and
                  assigned(ref.symbol) and (ref.symbol.typ in [AT_FUNCTION,AT_LABEL,AT_ADDR]) and
                  (ref.base=NR_NO) and (ref.index=NR_NO) then
                 begin