aboutsummaryrefslogtreecommitdiff
path: root/asm
diff options
context:
space:
mode:
authorThomas Albers Raviola <thomas@thomaslabs.org>2025-02-12 01:27:44 +0100
committerThomas Albers Raviola <thomas@thomaslabs.org>2025-02-12 01:27:44 +0100
commit779b9834e30de1ba0b4f0755388bebd0c45aa1dc (patch)
tree218edb656e329884e4b9cab7e84f4ba4b4af0c4a /asm
parent8ac78b9953908d2a4ffece855296fb7597440cce (diff)
Restructure rom image and use dependencies for makefiles
Diffstat (limited to 'asm')
-rw-r--r--asm/crt0.asm75
1 files changed, 30 insertions, 45 deletions
diff --git a/asm/crt0.asm b/asm/crt0.asm
index fd03997..a53c9e8 100644
--- a/asm/crt0.asm
+++ b/asm/crt0.asm
@@ -1,32 +1,17 @@
#include <hardware.h>
- .module crt0
- .globl _main
+ .module crt0
+ .globl _main
.area _HEADER (ABS)
- .org 0x0000
+ .org 0x8000
start:
- di
- xor a
- ld i, a
- ld sp, #0x0000
- ;; Init PIO and check for KEY2
- ld a, #PIO_MODE_3
- out (PORT_B_CTRL), a
- ld a, #0x7F
- out (PORT_B_CTRL), a
- in a, (PORT_B_DATA)
- and #KEY2 ; is KEY2 pressed? If so, start booloader
- jr NZ, main
- ;; Load payload (bootloader)
- ld hl, #0x7000 ; src
- ld de, #0x8000 ; dest
- ld bc, #0x1000 ; size
- ldir
- ;; Start bootloader
- jp 0x8000
+ di
+ ld a, #0x80
+ ld i, a
+ ld sp, #0x0000
main:
- call gsinit
+ call gsinit
call _main
1$:
halt
@@ -36,44 +21,44 @@ main:
.area _HOME
.area _CODE
.area _INITIALIZER
- .area _GSINIT
- .area _GSFINAL
+ .area _GSINIT
+ .area _GSFINAL
.area _DATA
.area _INITIALIZED
.area _BSEG
- .area _BSS
- .area _HEAP
+ .area _BSS
+ .area _HEAP
- .area _CODE
+ .area _CODE
- .area _GSINIT
+ .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
+ 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
+ jr z, gsinit_next
ld de, #s__INITIALIZED
ld hl, #s__INITIALIZER
ldir
gsinit_next:
- .area _GSFINAL
+ .area _GSFINAL
ret