mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 15:29:13 +02:00
+ clear the .bss section on startup in the ZX Spectrum RTL
git-svn-id: trunk@45624 -
This commit is contained in:
parent
4a78b7e073
commit
de08108b27
@ -21,6 +21,8 @@ interface
|
||||
|
||||
implementation
|
||||
|
||||
{$GOTO ON}
|
||||
|
||||
var
|
||||
FPC_SAVE_IY: word; external name 'FPC_SAVE_IY';
|
||||
fpc_stackarea_start: word; external name '__fpc_stackarea_start';
|
||||
@ -30,10 +32,46 @@ procedure PascalMain; external name 'PASCALMAIN';
|
||||
|
||||
{ this *must* always remain the first procedure with code in this unit }
|
||||
procedure _start; assembler; nostackframe; public name 'start';
|
||||
label
|
||||
bstart,bend,loop;
|
||||
asm
|
||||
{ init the stack }
|
||||
ld sp, offset fpc_stackarea_end
|
||||
|
||||
{ zero the .bss section }
|
||||
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
|
||||
|
||||
{ save IY (must be done after zeroing the .bss section) }
|
||||
ld (FPC_SAVE_IY), iy
|
||||
|
||||
{ ready to run the main program }
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user