瀏覽代碼

* ti8086nodeutils.InsertMemorySizes: stack segment creation moved to a separate
method

git-svn-id: trunk@27851 -

nickysn 11 年之前
父節點
當前提交
70732aedbb
共有 1 個文件被更改,包括 23 次插入18 次删除
  1. 23 18
      compiler/i8086/n8086util.pas

+ 23 - 18
compiler/i8086/n8086util.pas

@@ -32,6 +32,7 @@ interface
   type
     ti8086nodeutils = class(tnodeutils)
       class procedure InsertMemorySizes; override;
+      class procedure InsertStackSegment;
     end;
 
 
@@ -44,29 +45,33 @@ implementation
 
 
   class procedure ti8086nodeutils.InsertMemorySizes;
+    begin
+      inherited;
+      if current_settings.x86memorymodel in x86_far_data_models then
+        InsertStackSegment;
+    end;
+
+
+  class procedure ti8086nodeutils.InsertStackSegment;
     var
       stacksizeleft,stackblock: LongInt;
       i: Integer;
     begin
-      inherited;
-      if current_settings.x86memorymodel in x86_far_data_models then
+      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_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
-          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_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;
+          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;