From ad2623d8c4bc51638343ae9a628f8647ff558155 Mon Sep 17 00:00:00 2001 From: Thomas Albers Date: Mon, 14 Aug 2023 10:47:54 +0200 Subject: Initial commit --- stn/crt0.asm | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 stn/crt0.asm (limited to 'stn/crt0.asm') diff --git a/stn/crt0.asm b/stn/crt0.asm new file mode 100644 index 0000000..2fdef59 --- /dev/null +++ b/stn/crt0.asm @@ -0,0 +1,66 @@ +#include + + .module crt0 + .globl _main + + .area _HEADER (ABS) + ;; Reset vector + .org 0x4000 + ld SP, #0x00 + jp init + ;; ISR table + + ;; Init code +init: + call gsinit + call _main +1$: + halt + jr 1$ + + ;; Ordering of segments for the linker. + .area _HOME + .area _CODE + .area _INITIALIZER + .area _GSINIT + .area _GSFINAL + + .area _DATA + .area _INITIALIZED + .area _BSEG + .area _BSS + .area _HEAP + + .area _CODE + + .area _GSINIT +gsinit: + ;; Default-initialized global variables. + ld bc, #l__DATA + ld a, b + or a, c + jr Z, zeroed_data + ld hl, #s__DATA + ld (hl), #0x00 + dec bc + ld a, b + or a, c + jr Z, zeroed_data + ld e, l + ld d, h + inc de + ldir +zeroed_data: + ;; Explicitly initialized global variables. + 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: + + .area _GSFINAL + ret -- cgit v1.2.3