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