diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-11-21 15:55:03 +0100 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-11-21 15:55:03 +0100 |
commit | 6d4ad089c5b758ad8af4f68bf385a26ec4e9653a (patch) | |
tree | 2fd65006b57d646b53e121aef42bba5ee5852840 /asm |
Initial commit
Diffstat (limited to 'asm')
-rw-r--r-- | asm/crt0.asm | 64 | ||||
-rw-r--r-- | asm/delay.asm | 13 | ||||
-rw-r--r-- | asm/isr.asm | 17 |
3 files changed, 94 insertions, 0 deletions
diff --git a/asm/crt0.asm b/asm/crt0.asm new file mode 100644 index 0000000..6f92149 --- /dev/null +++ b/asm/crt0.asm @@ -0,0 +1,64 @@ +#include <hardware.h> + + .module crt0 + .globl _main + + .area _HEADER (ABS) + .org 0x0000 +start: + xor a + ld i, a + ld sp, #0x0000 + di + + 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 diff --git a/asm/delay.asm b/asm/delay.asm new file mode 100644 index 0000000..f04f046 --- /dev/null +++ b/asm/delay.asm @@ -0,0 +1,13 @@ + .module delay + +__delay_ms:: + ld b, a +1$: + ld hl, #400 +2$: + dec hl + ld a, h + or l + jr nz, 2$ + djnz 1$ + ret diff --git a/asm/isr.asm b/asm/isr.asm new file mode 100644 index 0000000..ad810e5 --- /dev/null +++ b/asm/isr.asm @@ -0,0 +1,17 @@ + .module isr + + .area _ISR_TABLE (REL) +_ctc0_isr_ptr:: + .dw #0 +_ctc1_isr_ptr:: + .dw #_ctc1_isr +_ctc2_isr_ptr:: + .dw #_timer +_ctc3_isr_ptr:: + .dw #_blink_cursor +_port_a_isr_ptr:: + .dw #0 +_port_b_isr_ptr:: + .dw #_input_event +_rx_isr_ptr:: + .dw #_rx_isr |