blob: 325ef3099bfd5e1efd5cfe58461bd86cd2df1740 [file] [log] [blame]
;; File: crt0.s
;; Generic crt0.s for a Z80
;; From SDCC..
;; Modified to suit execution on the Amstrad CPC!
;; by H. Hansen 2003
.module crt0
.globl _main
.globl _progend
;; Ordering of segments for the linker.
; Things that go in RAM
.area _INITIALIZED
.area _DATA
.area _BSS
.area _HEAP
_progend::
;; Things that go in ROM
.area _HOME
.area _CODE (REL,CON)
.area _INITIALIZER (REL,CON)
.area _GSINIT (REL,CON)
.area _GSFINAL (REL,CON)
.area _CODE (REL,CON)
.db #1 ; Background ROM
.db #1 ; Version 1.4
.db #4
.db #0
.dw rsx_table
jp do_nothing
jp init
rsx_table:
.db 'K' + #0x80
.ascii "CONTIK"
.db 'I' + #0x80
.db #0
init:
; This is the program entry point. Execution starts here
;; Initialise global variables, clear BSS areas, initialize AMSDOS and setup heap.
ld bc, #l__INITIALIZER
ld a, b
or a, c
jr Z, gsinit_next
ld de, #s__INITIALIZED
ld hl, #s__INITIALIZER
ldir
gsinit_next:
; Clear BSS sections
ld hl,#s__DATA
ld (hl),#0
ld de,#s__DATA + #1
ld bc,#s__DATA + #0x200
ldir
; Initialize disk ROM
ld hl,#0xabff
ld de,#0x40
ld c,#7
call 0xbcce
; Init the heap. Do it after the disk ROM is ready, because that may change HIMEM
call __sdcc_heap_init
; Enter the C main.
jp _main
do_nothing:
LD A, #'K'
CALL #0xBB5A
scf
ret
_exit::
rst #0
; -----------------------------------------------------------------------------