Initialize BSS and disk ROM in CRT0.
* The BSS is needed for things to work (duh)
* The disk ROM must be initialized before allocating the heap.
diff --git a/contiki-cpc/arch/crt0.s b/contiki-cpc/arch/crt0.s
index 23b8513..3364bc3 100644
--- a/contiki-cpc/arch/crt0.s
+++ b/contiki-cpc/arch/crt0.s
@@ -6,7 +6,6 @@
.module crt0
.globl _main
-; .globl __jpbc
.globl _progend
.area _HEADER (ABS)
;; Ordering of segments for the linker.
@@ -19,24 +18,21 @@
_exit::
ret
-;__jpbc:
-; push bc
-; ret
.area _HOME
.area _CODE
.area _INITIALIZER
.area _GSINIT (REL)
.area _GSFINAL (REL)
-_progend::
- .area _DATA (REL)
.area _INITIALIZED
+ .area _DATA
.area _BSEG
- .area _BSS (REL)
- .area _HEAP (REL)
+ .area _BSS (REL)
+ .area _HEAP (REL)
+_progend::
- .area _GSINIT (REL)
+ .area _GSINIT (REL)
gsinit::
ld bc, #l__INITIALIZER
ld a, b
@@ -46,6 +42,20 @@
ld hl, #s__INITIALIZER
ldir
gsinit_next:
+; Clear BSS sections
+ ld hl,#s__DATA
+ ld (hl),#0
+ ld de,#s__DATA
+ inc de
+ ld bc,#l__DATA
+ ldir
+
+; Initialize disk ROM
+ ld hl,#0xabff
+ ld de,#0x40
+ ld c,#7
+ call 0xbcce
.area _GSFINAL
- ret
+ ; After the ROMs are initialized, initialize the heap.
+ jp __sdcc_heap_init