aboutsummaryrefslogtreecommitdiff
path: root/crt0.s
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-05-03 08:21:10 +0100
committerJuan J. Martinez <jjm@usebox.net>2021-05-03 10:00:00 +0100
commitc3b0fa04a663fe233765b83d3be41a42aa08c25d (patch)
tree0befda349001ef6ce306b39378f9c70ad917363e /crt0.s
downloadreturn-of-traxtor-cpc-main.tar.gz
return-of-traxtor-cpc-main.zip
Initial import for public releaseHEADmain
Diffstat (limited to 'crt0.s')
-rw-r--r--crt0.s55
1 files changed, 55 insertions, 0 deletions
diff --git a/crt0.s b/crt0.s
new file mode 100644
index 0000000..37c5fae
--- /dev/null
+++ b/crt0.s
@@ -0,0 +1,55 @@
+.module crt0
+.globl _main
+.globl _main_init
+
+ .area _HOME
+ .area _CODE
+ .area _INITIALIZER
+ .area _GSINIT
+ .area _GSFINAL
+
+ .area _DATA
+ .area _INITIALIZED
+ .area _BSEG
+ .area _BSS
+ .area _HEAP
+
+ .area _CODE
+
+_main_init::
+
+ di
+ ; disable the firmware
+ ld hl, #0x38
+ ld (hl), #0xfb
+ inc hl
+ ld (hl), #0xc9
+
+ ; disable upper/lower roms
+ ld bc, #0x7f8c
+ out (c), c
+
+ ; put the stack as high as we can
+ ld sp, #0xc000
+ ei
+
+ call gsinit
+ call _main
+
+halt0:
+ halt
+ jr halt0
+
+ .area _GSINIT
+gsinit::
+ 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