diff --git a/compiler/i8086/cgcpu.pas b/compiler/i8086/cgcpu.pas index 3bcb35006c..8d6b87878c 100644 --- a/compiler/i8086/cgcpu.pas +++ b/compiler/i8086/cgcpu.pas @@ -346,13 +346,6 @@ unit cgcpu; tmpref:=ref; make_simple_ref(list,tmpref); - if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then - begin - list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment)); - list.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); - tmpref.segment:=NR_ES; - end; - if size in [OS_64, OS_S64] then internalerror(2013050801); if size in [OS_32, OS_S32] then @@ -498,13 +491,6 @@ unit cgcpu; make_simple_ref(list,tmpref); check_register_size(size,reg); - if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then - begin - list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment)); - list.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); - tmpref.segment:=NR_ES; - end; - if size in [OS_64, OS_S64] then internalerror(2013030902); @@ -536,13 +522,6 @@ unit cgcpu; make_simple_ref(list,tmpref); check_register_size(size,reg); - if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then - begin - list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment)); - list.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); - tmpref.segment:=NR_ES; - end; - if size in [OS_64, OS_S64] then internalerror(2013050803); @@ -853,13 +832,6 @@ unit cgcpu; tmpref:=ref; make_simple_ref(list,tmpref); - if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then - begin - list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment)); - list.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); - tmpref.segment:=NR_ES; - end; - if tosize in [OS_S32,OS_32] then begin a_load_const_ref(list,OS_16,longint(a and $ffff),tmpref); @@ -882,13 +854,6 @@ unit cgcpu; make_simple_ref(list,tmpref); check_register_size(fromsize,reg); - if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then - begin - list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment)); - list.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); - tmpref.segment:=NR_ES; - end; - case tosize of OS_8,OS_S8: if fromsize in [OS_8,OS_S8] then @@ -973,13 +938,6 @@ unit cgcpu; { if tcgsize2size[tosize]<=tcgsize2size[fromsize] then fromsize:=tosize;} - if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then - begin - list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment)); - list.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); - tmpref.segment:=NR_ES; - end; - case tosize of OS_8,OS_S8: if fromsize in [OS_8,OS_S8] then diff --git a/compiler/i8086/n8086add.pas b/compiler/i8086/n8086add.pas index 6701a17dd5..813fc8bbfd 100644 --- a/compiler/i8086/n8086add.pas +++ b/compiler/i8086/n8086add.pas @@ -556,12 +556,6 @@ interface begin tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,right.location.reference); href:=right.location.reference; - if (href.segment<>NR_NO) and (not is_segment_reg(href.segment)) then - begin - current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_PUSH,S_W,href.segment)); - current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); - href.segment:=NR_ES; - end; inc(href.offset,2); emit_ref_reg(A_CMP,S_W,href,GetNextReg(left.location.register)); firstjmp32bitcmp; diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas index 34d23cf20c..7ffc5582ae 100644 --- a/compiler/x86/cgx86.pas +++ b/compiler/x86/cgx86.pas @@ -576,7 +576,15 @@ unit cgx86; { let the register allocator find a suitable register for the reference } list.Concat(Taicpu.op_reg_reg(A_MOV, S_W, NR_SP, href.base)); ref:=href; - end + end; + + { if there is a segment in an int register, move it to ES } + if (ref.segment<>NR_NO) and (not is_segment_reg(ref.segment)) then + begin + list.concat(taicpu.op_reg(A_PUSH,S_W,ref.segment)); + list.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); + ref.segment:=NR_ES; + end; {$endif} end; diff --git a/compiler/x86/nx86add.pas b/compiler/x86/nx86add.pas index e69dd96cce..bb4450f944 100644 --- a/compiler/x86/nx86add.pas +++ b/compiler/x86/nx86add.pas @@ -249,9 +249,6 @@ unit nx86add; procedure tx86addnode.emit_op_right_left(op:TAsmOp;opsize:TCgsize); var tmpref: treference; -{$ifdef x86_64} - tmpreg : tregister; -{$endif x86_64} begin if (right.location.loc in [LOC_CSUBSETREG,LOC_SUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true); @@ -264,16 +261,7 @@ unit nx86add; LOC_CREFERENCE : begin tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,right.location.reference); - tmpref:=right.location.reference; -{$ifdef i8086} - if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then - begin - current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment)); - current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_POP,S_W,NR_ES)); - tmpref.segment:=NR_ES; - end; -{$endif i8086} - current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(op,TCGSize2Opsize[opsize],tmpref,left.location.register)); + current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(op,TCGSize2Opsize[opsize],right.location.reference,left.location.register)); end; LOC_CONSTANT : begin