2002-06-03 20:23:15 +00:00
|
|
|
|
;
|
|
|
|
|
; Startup code for cc65 (Oric version)
|
|
|
|
|
;
|
|
|
|
|
; By Debrune J<>r<EFBFBD>me <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
|
|
|
|
|
;
|
|
|
|
|
; This must be the *first* file on the linker command line
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
.export _exit
|
|
|
|
|
.import initlib, donelib
|
|
|
|
|
.import push0, _main, zerobss
|
|
|
|
|
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
|
|
|
|
|
2002-11-23 22:06:01 +00:00
|
|
|
|
.importzp sp
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2002-11-23 11:10:50 +00:00
|
|
|
|
; Create an empty LOWCODE segment to avoid linker warnings
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2002-11-23 11:10:50 +00:00
|
|
|
|
.segment "LOWCODE"
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2002-11-23 11:10:50 +00:00
|
|
|
|
; Place the startup code in a special segment.
|
|
|
|
|
|
|
|
|
|
.segment "STARTUP"
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
|
|
|
|
; Clear the BSS data
|
|
|
|
|
|
|
|
|
|
jsr zerobss
|
|
|
|
|
|
|
|
|
|
; Save system stuff and setup the stack
|
|
|
|
|
|
|
|
|
|
tsx
|
|
|
|
|
stx spsave ; save system stk ptr
|
|
|
|
|
|
|
|
|
|
lda #<(__RAM_START__ + __RAM_SIZE__)
|
|
|
|
|
sta sp
|
|
|
|
|
lda #>(__RAM_START__ + __RAM_SIZE__)
|
|
|
|
|
sta sp+1 ; Set argument stack ptr
|
|
|
|
|
|
|
|
|
|
; Call module constructors
|
|
|
|
|
|
|
|
|
|
jsr initlib
|
|
|
|
|
|
|
|
|
|
; Pass an empty command line
|
|
|
|
|
|
|
|
|
|
jsr push0 ; argc
|
|
|
|
|
jsr push0 ; argv
|
|
|
|
|
|
|
|
|
|
ldy #4 ; Argument size
|
|
|
|
|
jsr _main ; call the users code
|
|
|
|
|
|
|
|
|
|
; Call module destructors. This is also the _exit entry.
|
|
|
|
|
|
|
|
|
|
_exit: jsr donelib ; Run module destructors
|
|
|
|
|
|
|
|
|
|
; Restore system stuff
|
|
|
|
|
|
|
|
|
|
ldx spsave
|
|
|
|
|
txs
|
|
|
|
|
|
|
|
|
|
; Back to BASIC
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
2002-11-23 11:10:50 +00:00
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
|
; Data
|
|
|
|
|
|
2002-06-03 20:23:15 +00:00
|
|
|
|
.bss
|
|
|
|
|
spsave: .res 1
|
|
|
|
|
|
|
|
|
|
|