- Put a BASIC-language stub at the beginning. - Removed the Autostart flag. Those changes make it easy to give command-line arguments to a program. * Made the Atmos configure file accept a special symbol definition on ld65's command line. We can use "__RAMEND__" to increase the amount of RAM that's available to programs.
101 lines
2.2 KiB
ArmAsm
101 lines
2.2 KiB
ArmAsm
;
|
|
; Startup code for cc65 (Oric version)
|
|
;
|
|
; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
|
|
; 2014-11-09, Greg King
|
|
;
|
|
|
|
.export _exit
|
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
|
.import initlib, donelib
|
|
.import callmain, zerobss
|
|
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
|
|
|
|
.include "zeropage.inc"
|
|
.include "atmos.inc"
|
|
|
|
; ------------------------------------------------------------------------
|
|
; Place the startup code in a special segment.
|
|
|
|
.segment "STARTUP"
|
|
|
|
; Save the zero-page area that we're about to use.
|
|
|
|
ldx #zpspace-1
|
|
L1: lda sp,x
|
|
sta zpsave,x
|
|
dex
|
|
bpl L1
|
|
|
|
; Clear the BSS data.
|
|
|
|
jsr zerobss
|
|
|
|
; Unprotect screen columns 0 and 1.
|
|
|
|
lda STATUS
|
|
sta stsave
|
|
and #%11011111
|
|
sta STATUS
|
|
|
|
; Save some system stuff; and, set up the stack.
|
|
|
|
tsx
|
|
stx spsave ; Save system stk ptr
|
|
|
|
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
|
sta sp
|
|
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
|
sta sp+1 ; Set argument stack ptr
|
|
|
|
; Call the module constructors.
|
|
|
|
jsr initlib
|
|
|
|
; 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
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
.segment "ZPSAVE"
|
|
|
|
zpsave:
|
|
|
|
; This padding is needed by a bug in the ROM.
|
|
; (The CLOAD command starts BASIC's variables table on top of the last byte
|
|
; that was loaded [instead of at the next address].)
|
|
|
|
.byte 0
|
|
|
|
.res zpspace - 1
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
.bss
|
|
|
|
spsave: .res 1
|
|
stsave: .res 1
|