+ initialize DS with the current unit's data segment in the function entry code

generated in the huge memory model

git-svn-id: trunk@31500 -
This commit is contained in:
nickysn 2015-09-03 21:44:16 +00:00
parent 2725b1160b
commit 0fdc62e0f7
4 changed files with 26 additions and 1 deletions

View File

@ -101,6 +101,7 @@ interface
{$ENDIF}
{$IFDEF i8086}
,addr_dgroup // the data segment group
,addr_fardataseg // the far data segment of the current pascal module (unit or program)
,addr_seg // used for getting the segment of an object, e.g. 'mov ax, SEG symbol'
{$ENDIF}
{$IFDEF AARCH64}

View File

@ -1776,7 +1776,11 @@ unit cgcpu;
cg.a_op_const_reg(list,OP_ADD,OS_ADDR,stacksize,current_procinfo.framepointer);
end
else
generate_leave(list);
begin
if current_settings.x86memorymodel=mm_huge then
list.concat(Taicpu.Op_reg(A_POP,S_W,NR_DS));
generate_leave(list);
end;
list.concat(tai_regalloc.dealloc(current_procinfo.framepointer,nil));
end;

View File

@ -387,6 +387,10 @@ interface
begin
AsmWrite('DGROUP');
end
else if o.ref^.refaddr=addr_fardataseg then
begin
AsmWrite(current_module.modulename^+'_DATA');
end
{$endif i8086}
else
begin
@ -603,14 +607,18 @@ interface
var
i: Integer;
begin
{$ifdef i8086}
if target_info.system=system_i8086_msdos then
begin
if current_settings.x86memorymodel=mm_huge then
WriteSection(sec_data,'',2);
AsmLn;
AsmWrite('GROUP DGROUP');
for i:=0 to FSectionsInDGROUP.Count-1 do
AsmWrite(' '+FSectionsInDGROUP.NameOfIndex(i));
AsmLn;
end;
{$endif i8086}
end;
procedure TX86NasmAssembler.WriteTree(p:TAsmList);

View File

@ -2847,6 +2847,7 @@ unit cgx86;
regsize: longint;
{$ifdef i8086}
dgroup: treference;
fardataseg: treference;
{$endif i8086}
procedure push_regs;
@ -2975,6 +2976,17 @@ unit cgx86;
current_procinfo.final_localsize:=localsize;
end;
{$ifdef i8086}
if current_settings.x86memorymodel=mm_huge then
begin
list.concat(Taicpu.op_reg(A_PUSH,S_W,NR_DS));
reference_reset(fardataseg,0);
fardataseg.refaddr:=addr_fardataseg;
list.concat(Taicpu.Op_ref_reg(A_MOV,S_W,fardataseg,NR_AX));
list.concat(Taicpu.Op_reg_reg(A_MOV,S_W,NR_AX,NR_DS));
end;
{$endif i8086}
{$ifdef i386}
if (not paramanager.use_fixed_stack) and
(current_procinfo.framepointer<>NR_STACK_POINTER_REG) and