浏览代码

* added hack to support stack exceeding 32kb in size in the i8086 far data
memory models

git-svn-id: trunk@27827 -

nickysn 11 年之前
父节点
当前提交
47a7a9835a
共有 1 个文件被更改,包括 19 次插入2 次删除
  1. 19 2
      compiler/i8086/n8086util.pas

+ 19 - 2
compiler/i8086/n8086util.pas

@@ -38,18 +38,35 @@ interface
 implementation
 
   uses
-    globals,cpuinfo,
+    sysutils,cutils,
+    globtype,globals,cpuinfo,
     aasmbase,aasmdata,aasmtai;
 
 
   class procedure ti8086nodeutils.InsertMemorySizes;
+    var
+      stacksizeleft,stackblock: LongInt;
+      i: Integer;
     begin
       inherited;
       if current_settings.x86memorymodel in x86_far_data_models then
         begin
           maybe_new_object_file(current_asmdata.asmlists[al_globals]);
           new_section(current_asmdata.asmlists[al_globals],sec_stack,'__stack', 16);
-          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create('___stack', stacksize));
+          current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___stack', AT_DATA, stacksize));
+          { HACK: since tai_datablock's size parameter is aint, which cannot be
+            larger than 32767 on i8086, but we'd like to support stack size of
+            up to 64kb, we may need to use several tai_datablocks to reserve
+            the stack segment }
+          i:=0;
+          stacksizeleft:=stacksize;
+          while stacksizeleft>0 do
+            begin
+              stackblock:=min(stacksizeleft,high(aint));
+              current_asmdata.asmlists[al_globals].concat(tai_datablock.Create('___stackblock'+IntToStr(i),stackblock));
+              dec(stacksizeleft,stackblock);
+              inc(i);
+            end;
         end;
     end;