From 9450beb99cc4879c53b139d2a8bf8daebede48b3 Mon Sep 17 00:00:00 2001 From: nickysn Date: Tue, 31 Oct 2017 16:49:38 +0000 Subject: [PATCH] * 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 - --- compiler/rautils.pas | 7 +++++++ compiler/x86/rax86int.pas | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/rautils.pas b/compiler/rautils.pas index fb7d229c09..f3f3e2db04 100644 --- a/compiler/rautils.pas +++ b/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; diff --git a/compiler/x86/rax86int.pas b/compiler/x86/rax86int.pas index 41e4919518..576dbf756a 100644 --- a/compiler/x86/rax86int.pas +++ b/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