Browse Source

+ 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 -

nickysn 10 năm trước cách đây
mục cha
commit
0fdc62e0f7
4 tập tin đã thay đổi với 26 bổ sung1 xóa
  1. 1 0
      compiler/cgbase.pas
  2. 5 1
      compiler/i8086/cgcpu.pas
  3. 8 0
      compiler/x86/agx86nsm.pas
  4. 12 0
      compiler/x86/cgx86.pas

+ 1 - 0
compiler/cgbase.pas

@@ -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}

+ 5 - 1
compiler/i8086/cgcpu.pas

@@ -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;
 

+ 8 - 0
compiler/x86/agx86nsm.pas

@@ -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);

+ 12 - 0
compiler/x86/cgx86.pas

@@ -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