From 98b2b2544db2390978c0532040a7922ed7d55bc2 Mon Sep 17 00:00:00 2001 From: bauen1 Date: Thu, 4 Jan 2018 12:07:35 +0100 Subject: [PATCH] Added crt0 to none.lib --- cfg/none.cfg | 1 + libsrc/none/crt0.s | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 libsrc/none/crt0.s diff --git a/cfg/none.cfg b/cfg/none.cfg index 6742da7c8..44bbcdfec 100644 --- a/cfg/none.cfg +++ b/cfg/none.cfg @@ -7,6 +7,7 @@ MEMORY { } SEGMENTS { ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro, optional = yes; LOWCODE: load = MAIN, type = ro, optional = yes; ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = rw; diff --git a/libsrc/none/crt0.s b/libsrc/none/crt0.s new file mode 100644 index 000000000..fb26fb2af --- /dev/null +++ b/libsrc/none/crt0.s @@ -0,0 +1,25 @@ + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + .import zerobss, _main + .import initlib, donelib + .import __MAIN_START__, __MAIN_SIZE__ ; Linker generated + .import __STACKSIZE__ ; Linker generated + + .include "zeropage.inc" + + .segment "STARTUP" + + cld + ldx #$FF + txs + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + sta sp + stx sp+1 + jsr zerobss + jsr initlib + jsr _main +_exit: pha + jsr donelib + pla + brk -- 2.39.5