diff --git a/compiler/x86/nx86add.pas b/compiler/x86/nx86add.pas index 042844b750..6adcd58ae9 100644 --- a/compiler/x86/nx86add.pas +++ b/compiler/x86/nx86add.pas @@ -247,8 +247,9 @@ unit nx86add; procedure tx86addnode.emit_op_right_left(op:TAsmOp;opsize:TCgsize); -{$ifdef x86_64} var + tmpref: treference; +{$ifdef x86_64} tmpreg : tregister; {$endif x86_64} begin @@ -263,7 +264,16 @@ unit nx86add; LOC_CREFERENCE : begin tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,right.location.reference); - current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(op,TCGSize2Opsize[opsize],right.location.reference,left.location.register)); + 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)); end; LOC_CONSTANT : begin