aboutsummaryrefslogtreecommitdiff
path: root/boot/crt0.asm
diff options
context:
space:
mode:
authorThomas Albers Raviola <thomas@thomaslabs.org>2024-12-03 21:45:47 +0100
committerThomas Albers Raviola <thomas@thomaslabs.org>2024-12-03 21:45:47 +0100
commitd46862a5bd2319c595b11427f781201ca063d194 (patch)
treee83d3f40c60233a1da85334745b882f188b0be52 /boot/crt0.asm
parent9cd14efb76a4ddbcd013f44d50dc1ff93d56c4ca (diff)
Add bootloader
Diffstat (limited to 'boot/crt0.asm')
-rw-r--r--boot/crt0.asm79
1 files changed, 79 insertions, 0 deletions
diff --git a/boot/crt0.asm b/boot/crt0.asm
new file mode 100644
index 0000000..09e4166
--- /dev/null
+++ b/boot/crt0.asm
@@ -0,0 +1,79 @@
+#include <hardware.h>
+ .module crt0
+ .globl _main
+
+ .area _HEADER (ABS)
+ .org 0x8000
+start:
+ di
+ ld a, #0x80
+ ld i, a
+ ld sp, #0x0000
+ jr main
+ .org 0x8010
+_ctc0_isr_ptr::
+ .dw #0
+_ctc1_isr_ptr::
+ .dw #_ctc1_isr
+_ctc2_isr_ptr::
+ .dw #0
+_ctc3_isr_ptr::
+ .dw #0
+_port_a_isr_ptr::
+ .dw #0
+_port_b_isr_ptr::
+ .dw #0
+_rx_isr_ptr::
+ .dw #_rx_isr
+main:
+ 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