mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 03:19:27 +02:00
* ti8086nodeutils.InsertMemorySizes: stack segment creation moved to a separate
method git-svn-id: trunk@27851 -
This commit is contained in:
parent
886159e73a
commit
70732aedbb
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user