2013-07-14 20:50:38 +00:00
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; crt0.s
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; Startup code for Ohio Scientific Challenger 1P
|
|
|
|
|
|
|
|
.export _init, _exit
|
|
|
|
.import _main
|
|
|
|
|
|
|
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
|
|
|
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
|
|
|
|
2013-07-24 20:35:58 +00:00
|
|
|
.import zerobss, initlib, donelib
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
.include "zeropage.inc"
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Place the startup code in a special segment
|
|
|
|
|
|
|
|
.segment "STARTUP"
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; A little light 6502 housekeeping
|
|
|
|
|
|
|
|
_init: LDX #$FF ; Initialize stack pointer to $01FF
|
|
|
|
TXS
|
|
|
|
CLD ; Clear decimal mode
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Set cc65 argument stack pointer
|
|
|
|
|
|
|
|
LDA #<(__RAM_START__ + __RAM_SIZE__)
|
|
|
|
STA sp
|
|
|
|
LDA #>(__RAM_START__ + __RAM_SIZE__)
|
|
|
|
STA sp+1
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Initialize memory storage
|
2013-07-15 20:45:09 +00:00
|
|
|
; copydata seems to be only necessary for special systems
|
2013-07-14 20:50:38 +00:00
|
|
|
|
2013-07-15 20:45:09 +00:00
|
|
|
JSR zerobss ; Clear BSS segment
|
|
|
|
; JSR copydata ; Initialize DATA segment
|
|
|
|
JSR initlib ; Run constructors
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Call main()
|
|
|
|
|
|
|
|
JSR _main
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Back from main (this is also the _exit entry): force a software break
|
|
|
|
|
|
|
|
_exit: JSR donelib ; Run destructors
|
|
|
|
BRK
|
|
|
|
|