|
@@ -33,6 +33,7 @@ interface
|
|
|
ti8086nodeutils = class(tnodeutils)
|
|
|
class procedure InsertMemorySizes; override;
|
|
|
class procedure InsertStackSegment;
|
|
|
+ class procedure InsertHeapSegment;
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -49,6 +50,7 @@ implementation
|
|
|
inherited;
|
|
|
if current_settings.x86memorymodel<>mm_tiny then
|
|
|
InsertStackSegment;
|
|
|
+ InsertHeapSegment;
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -77,6 +79,31 @@ implementation
|
|
|
end;
|
|
|
|
|
|
|
|
|
+ class procedure ti8086nodeutils.InsertHeapSegment;
|
|
|
+ var
|
|
|
+ heapsizeleft,heapblock: LongInt;
|
|
|
+ i: Integer;
|
|
|
+ begin
|
|
|
+ maybe_new_object_file(current_asmdata.asmlists[al_globals]);
|
|
|
+ new_section(current_asmdata.asmlists[al_globals],sec_heap,'__heap', 16);
|
|
|
+ current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___heap', AT_DATA, heapsize));
|
|
|
+ { HACK: since tai_datablock's size parameter is aint, which cannot be
|
|
|
+ larger than 32767 on i8086, but we'd like to support heap size of
|
|
|
+ up to 640kb, we may need to use several tai_datablocks to reserve
|
|
|
+ the heap segment }
|
|
|
+ i:=0;
|
|
|
+ heapsizeleft:=heapsize;
|
|
|
+ while heapsizeleft>0 do
|
|
|
+ begin
|
|
|
+ heapblock:=min(heapsizeleft,high(aint));
|
|
|
+ current_asmdata.asmlists[al_globals].concat(tai_datablock.Create('___heapblock'+IntToStr(i),heapblock));
|
|
|
+ dec(heapsizeleft,heapblock);
|
|
|
+ inc(i);
|
|
|
+ end;
|
|
|
+ current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___heaptop',AT_DATA,0));
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
begin
|
|
|
cnodeutils:=ti8086nodeutils;
|
|
|
end.
|