From 29b51c0dfdd27de76b489cd77ea70d25d9d74fdc Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 13 Apr 2026 06:24:18 -0400 Subject: Zero the BSS in the throwaway STARTUP segment. 7764 bytes free. --- src/crt0.s | 41 +++++++++++++++++++++++++++++++++++++++-- src/main.c | 2 -- 2 files changed, 39 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/crt0.s b/src/crt0.s index 44a1c93..564ca3d 100644 --- a/src/crt0.s +++ b/src/crt0.s @@ -13,10 +13,13 @@ .export __STARTUP__ : absolute = 1 ; Mark as startup .export _exit, start - .import _main, zerobss + .import _main; not any more: , zerobss .import __RESERVED_MEMORY__ .import __MAIN_START__, __MAIN_SIZE__ .import __LOWCODE_RUN__, __LOWCODE_SIZE__ + .import __BSS_RUN__, __BSS_SIZE__ + .import _scr_init, _init_channels + .importzp ptr1 .include "zeropage.inc" .include "atari.inc" @@ -35,7 +38,36 @@ start: ; Clear the BSS data. - jsr zerobss +; This routine was copied from libsrc/common/zerobss.s. +;zerobss: + lda #<__BSS_RUN__ + sta ptr1 + lda #>__BSS_RUN__ + sta ptr1+1 + lda #0 + tay + +; Clear full pages + +L1: ldx #>__BSS_SIZE__ + beq L3 +L2: sta (ptr1),y + iny + bne L2 + inc ptr1+1 + dex + bne L2 + +; Clear remaining page (y is zero on entry) + +L3: cpy #<__BSS_SIZE__ + beq L4 + sta (ptr1),y + iny + bne L3 + +L4: +; Done clearing BSS. ; Set up the stack lda MEMTOP @@ -50,6 +82,11 @@ start: sty SHFLOK ; Turn off Caps Lock sty SOUNDR ; Turn off SIO beep/click +; These 2 used to be called from main(). Moving the calls here saves 6 bytes. +; Do not call _edbox_clear from here (we're *running* in the edbox area). + jsr _scr_init + jsr _init_channels + ; Go directly to main(). No support for CLI arguments, no saving ; any machine state for a clean exit, because we don't exit. jmp _main diff --git a/src/main.c b/src/main.c index cfc9641..3b24182 100644 --- a/src/main.c +++ b/src/main.c @@ -132,8 +132,6 @@ void main(void) { bell_type = config.alert_type; /* TODO: have bell.s read staight from the struct */ edbox_clear(); - scr_init(); - init_channels(); while(1) { if(fn_connect()) { -- cgit v1.2.3