Adding files for telemon30
This commit is contained in:
101
libsrc/telemon30/crt0.s
Normal file
101
libsrc/telemon30/crt0.s
Normal file
@@ -0,0 +1,101 @@
|
||||
;
|
||||
; Startup code for cc65 (Oric version)
|
||||
;
|
||||
; By Debrune J<>r<EFBFBD>me <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
|
||||
; 2016-03-18, Greg King
|
||||
;
|
||||
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
|
||||
.import initlib, donelib
|
||||
.import callmain, zerobss
|
||||
.import __MAIN_START__, __MAIN_SIZE__
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "telemon30.inc"
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Place the startup code in a special segment.
|
||||
|
||||
.segment "STARTUP"
|
||||
|
||||
tsx
|
||||
stx spsave ; Save system stk ptr
|
||||
|
||||
; Save space by putting some of the start-up code in a segment
|
||||
; that will be re-used.
|
||||
|
||||
jsr init
|
||||
|
||||
; Clear the BSS variables (after the constructors have been run).
|
||||
|
||||
jsr zerobss
|
||||
|
||||
; Push the command-line arguments; and, call main().
|
||||
|
||||
jsr callmain
|
||||
|
||||
; Call the module destructors. This is also the exit() entry.
|
||||
|
||||
_exit: jsr donelib
|
||||
|
||||
; Restore the system stuff.
|
||||
|
||||
ldx spsave
|
||||
txs
|
||||
; lda stsave
|
||||
; sta STATUS
|
||||
|
||||
; Copy back the zero-page stuff.
|
||||
|
||||
ldx #zpspace - 1
|
||||
L2: lda zpsave,x
|
||||
sta sp,x
|
||||
dex
|
||||
bpl L2
|
||||
|
||||
; Back to BASIC.
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Put this code in a place that will be re-used by BSS, the heap,
|
||||
; and the C stack.
|
||||
|
||||
.segment "ONCE"
|
||||
|
||||
; Save the zero-page area that we're about to use.
|
||||
|
||||
init: ldx #zpspace - 1
|
||||
L1: lda sp,x
|
||||
sta zpsave,x
|
||||
dex
|
||||
bpl L1
|
||||
|
||||
; Currently, color isn't supported on the text screen.
|
||||
; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
|
||||
|
||||
; lda STATUS
|
||||
; sta stsave
|
||||
; and #%11011111
|
||||
; sta STATUS
|
||||
|
||||
; Set up the C stack.
|
||||
|
||||
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
||||
sta sp
|
||||
stx sp+1 ; Set argument stack ptr
|
||||
|
||||
; Call the module constructors.
|
||||
|
||||
jmp initlib
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
spsave: .res 1
|
||||
stsave: .res 1
|
||||
zpsave: .res zpspace
|
||||
Reference in New Issue
Block a user