2013-07-14 20:50:38 +00:00
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; crt0.s
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; Startup code for Ohio Scientific Challenger 1P
|
|
|
|
|
|
|
|
.export _init, _exit
|
|
|
|
.import _main
|
|
|
|
|
2015-02-18 17:38:42 +00:00
|
|
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
2016-03-07 00:28:55 +00:00
|
|
|
.import __MAIN_START__, __MAIN_SIZE__ ; Linker generated
|
2015-02-25 22:48:57 +00:00
|
|
|
.import __STACKSIZE__
|
2013-07-14 20:50:38 +00:00
|
|
|
|
2013-07-24 20:35:58 +00:00
|
|
|
.import zerobss, initlib, donelib
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
.include "zeropage.inc"
|
2014-11-23 14:32:48 +00:00
|
|
|
.include "extzp.inc"
|
2015-02-05 22:21:59 +00:00
|
|
|
.include "osic1p.inc"
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Place the startup code in a special segment
|
|
|
|
|
|
|
|
.segment "STARTUP"
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; A little light 6502 housekeeping
|
|
|
|
|
2015-02-18 17:38:42 +00:00
|
|
|
_init: ldx #$FF ; Initialize stack pointer to $01FF
|
2015-01-05 20:28:39 +00:00
|
|
|
txs
|
2015-02-18 17:38:42 +00:00
|
|
|
cld ; Clear decimal mode
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Set cc65 argument stack pointer
|
|
|
|
|
2016-03-07 00:28:55 +00:00
|
|
|
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
|
|
|
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
2015-01-05 20:28:39 +00:00
|
|
|
sta sp
|
2016-03-07 00:28:55 +00:00
|
|
|
stx sp+1
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Initialize memory storage
|
|
|
|
|
2015-02-18 17:38:42 +00:00
|
|
|
jsr zerobss ; Clear BSS segment
|
|
|
|
jsr initlib ; Run constructors
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Call main()
|
|
|
|
|
2015-01-05 20:28:39 +00:00
|
|
|
jsr _main
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
2015-02-18 17:38:42 +00:00
|
|
|
; Back from main (this is also the _exit entry):
|
2013-07-14 20:50:38 +00:00
|
|
|
|
2015-02-18 17:38:42 +00:00
|
|
|
_exit: jsr donelib ; Run destructors
|
|
|
|
jmp RESET ; Display boot menu after program exit
|