* x86: Cleaned out addr_far,addr_far_ref used to encode far calls/jumps. NASM (and FPC x86 assembler based on it) already have opsize=S_FAR for this purpose.

git-svn-id: trunk@27037 -
This commit is contained in:
sergei 2014-03-08 22:54:43 +00:00
parent 06451dd9ab
commit 9c54cdc85d
5 changed files with 25 additions and 40 deletions

View File

@ -99,8 +99,6 @@ interface
{$ENDIF}
{$IFDEF i8086}
,addr_dgroup // the data segment group
,addr_far // used for emitting 'call/jmp far label' instructions
,addr_far_ref // used for emitting 'call far [reference]' instructions
,addr_seg // used for getting the segment of an object, e.g. 'mov ax, SEG symbol'
{$ENDIF}
);

View File

@ -192,15 +192,12 @@ unit cgcpu;
weak: boolean);
var
sym : tasmsymbol;
r : treference;
begin
if not(weak) then
sym:=current_asmdata.RefAsmSymbol(s)
else
sym:=current_asmdata.WeakRefAsmSymbol(s);
reference_reset_symbol(r,sym,0,sizeof(pint));
r.refaddr:=addr_far;
list.concat(taicpu.op_ref(A_CALL,S_NO,r));
list.concat(taicpu.op_sym(A_CALL,S_FAR,sym));
end;
@ -216,12 +213,9 @@ unit cgcpu;
procedure tcg8086.a_call_name_static_far(list: TAsmList; const s: string);
var
sym : tasmsymbol;
r : treference;
begin
sym:=current_asmdata.RefAsmSymbol(s);
reference_reset_symbol(r,sym,0,sizeof(pint));
r.refaddr:=addr_far;
list.concat(taicpu.op_ref(A_CALL,S_NO,r));
list.concat(taicpu.op_sym(A_CALL,S_FAR,sym));
end;
@ -251,8 +245,7 @@ unit cgcpu;
a_load_reg_ref(list,OS_32,OS_32,reg,href);
cg.getcpuregister(list,NR_BX);
cg.getcpuregister(list,NR_SI);
href.refaddr:=addr_far_ref;
list.concat(taicpu.op_ref(A_CALL,S_NO,href));
list.concat(taicpu.op_ref(A_CALL,S_FAR,href));
tg.ungettemp(list,href);
end;
@ -2193,11 +2186,7 @@ unit cgcpu;
lab:=current_asmdata.RefAsmSymbol(procdef.mangledname);
if current_settings.x86memorymodel in x86_far_code_models then
begin
reference_reset_symbol(href,lab,0,sizeof(pint));
href.refaddr:=addr_far;
list.concat(taicpu.op_ref(A_JMP,S_NO,href));
end
list.concat(taicpu.op_sym(A_JMP,S_FAR,lab))
else
list.concat(taicpu.op_sym(A_JMP,S_NO,lab));
end;

View File

@ -116,8 +116,9 @@ implementation
procedure ti8086callnode.do_call_ref(ref: treference);
begin
if current_settings.x86memorymodel in x86_far_code_models then
ref.refaddr:=addr_far_ref;
current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_CALL,S_NO,ref));
current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_CALL,S_FAR,ref))
else
current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_CALL,S_NO,ref));
end;

View File

@ -40,7 +40,7 @@ interface
function CodeSectionName: string;
procedure WriteReference(var ref : treference);
procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
procedure WriteOper_jmp(const o:toper; op : tasmop);
procedure WriteOper_jmp(const o:toper; ai : taicpu);
procedure WriteSection(atype:TAsmSectiontype;const aname:string);
public
procedure WriteTree(p:TAsmList);override;
@ -428,9 +428,7 @@ interface
asmwrite('dword ');
{$endif i386}
{$ifdef i8086}
if o.ref^.refaddr=addr_far then
asmwrite('far ')
else if o.ref^.refaddr=addr_seg then
if o.ref^.refaddr=addr_seg then
asmwrite('SEG ')
else
asmwrite('word ');
@ -454,39 +452,39 @@ interface
end;
procedure TX86NasmAssembler.WriteOper_jmp(const o:toper; op : tasmop);
procedure TX86NasmAssembler.WriteOper_jmp(const o:toper; ai : taicpu);
begin
case o.typ of
top_reg :
AsmWrite(nasm_regname(o.reg));
top_ref :
if o.ref^.refaddr in [addr_no{$ifdef i8086},addr_far_ref{$endif}] then
if o.ref^.refaddr=addr_no then
begin
{$ifdef i8086}
if o.ref^.refaddr=addr_far_ref then
if ai.opsize=S_FAR then
AsmWrite('far ');
{$endif i8086}
WriteReference(o.ref^);
end
else
begin
if ai.opsize=S_FAR then
AsmWrite('far ')
else
begin
{ NEAR forces NASM to emit near jumps, which are 386+ }
{$ifndef i8086}
if not(
(op=A_JCXZ) or (op=A_JECXZ) or
(ai.opcode=A_JCXZ) or (ai.opcode=A_JECXZ) or
{$ifdef x86_64}
(op=A_JRCXZ) or
(ai.opcode=A_JRCXZ) or
{$endif x86_64}
(op=A_LOOP) or (op=A_LOOPE) or
(op=A_LOOPNE) or (op=A_LOOPNZ) or
(op=A_LOOPZ)
(ai.opcode=A_LOOP) or (ai.opcode=A_LOOPE) or
(ai.opcode=A_LOOPNE) or (ai.opcode=A_LOOPNZ) or
(ai.opcode=A_LOOPZ)
) then
AsmWrite('NEAR ');
{$endif i8086}
{$ifdef i8086}
if o.ref^.refaddr=addr_far then
AsmWrite('far ');
{$endif i8086}
end;
AsmWrite(o.ref^.symbol.name);
if SmartAsm then
AddSymbol(o.ref^.symbol.name,false);
@ -1057,7 +1055,7 @@ interface
if is_calljmp(fixed_opcode) then
begin
AsmWrite(#9);
WriteOper_jmp(taicpu(hp).oper[0]^,fixed_opcode);
WriteOper_jmp(taicpu(hp).oper[0]^,taicpu(hp));
end
else
begin

View File

@ -2135,8 +2135,7 @@ Unit Rax86int;
if (instr.opcode=A_CALL) and (typ=OPR_SYMBOL) and (symbol<>nil) and (symbol.typ<>AT_DATA) then
if current_settings.x86memorymodel in x86_far_code_models then
begin
instr.operands[i].InitRef;
ref.refaddr:=addr_far;
instr.opsize:=S_FAR;
end;
{$endif i8086}
end;