Bläddra i källkod

* ensure that the BSS section for MSX-DOS is correctly initialized to 0

git-svn-id: trunk@45642 -
svenbarth 5 år sedan
förälder
incheckning
4ec76072b4
2 ändrade filer med 34 tillägg och 0 borttagningar
  1. 1 0
      compiler/systems/t_msxdos.pas
  2. 33 0
      rtl/msxdos/si_prc.pp

+ 1 - 0
compiler/systems/t_msxdos.pas

@@ -375,6 +375,7 @@ procedure TInternalLinkerMSXDOS.DefaultLinkScript;
     LinkScript.Concat('ENDEXESECTION');
     LinkScript.Concat('ENDEXESECTION');
     LinkScript.Concat('EXESECTION .bss');
     LinkScript.Concat('EXESECTION .bss');
     LinkScript.Concat('  OBJSECTION _BSS');
     LinkScript.Concat('  OBJSECTION _BSS');
+    LinkScript.Concat('  OBJSECTION _BSSEND');
     LinkScript.Concat('  OBJSECTION _HEAP');
     LinkScript.Concat('  OBJSECTION _HEAP');
     LinkScript.Concat('  OBJSECTION _STACK');
     LinkScript.Concat('  OBJSECTION _STACK');
     LinkScript.Concat('ENDEXESECTION');
     LinkScript.Concat('ENDEXESECTION');

+ 33 - 0
rtl/msxdos/si_prc.pp

@@ -16,6 +16,7 @@
 unit si_prc;
 unit si_prc;
 
 
 {$SMARTLINK OFF}
 {$SMARTLINK OFF}
+{$GOTO ON}
 
 
 interface
 interface
 
 
@@ -28,9 +29,41 @@ procedure PascalMain; external name 'PASCALMAIN';
 
 
 { this *must* always remain the first procedure with code in this unit }
 { this *must* always remain the first procedure with code in this unit }
 procedure _start; assembler; nostackframe; public name 'start';
 procedure _start; assembler; nostackframe; public name 'start';
+label
+  bstart, bend, loop;
 asm
 asm
+    { first init BSS }
+    ld bc, offset bstart
+    ld hl, offset bend
+    scf
+    ccf
+    sbc hl, bc
+    ld a, 0
+loop:
+    ld (bc), a
+    inc bc
+    dec hl
+    cp a, l
+    jr NZ, loop
+    cp a, h
+    jr NZ, loop
+
+    { now we can store the top of the stack }
     ld (stktop), sp
     ld (stktop), sp
     jp PASCALMAIN
     jp PASCALMAIN
+
+    { When using the SDCC-SDLDZ80 linker, the first object module defines the
+      order of areas (sections). Since this module contains the startup code,
+      it is loaded first, so we define all the sections we use in the proper
+      order. }
+    area '_DATA'
+    area '_BSS'
+bstart:
+    area '_BSSEND'
+bend:
+    area '_HEAP'
+    area '_STACK'
+    area '_CODE'
 end;
 end;
 
 
 end.
 end.