2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; This must be the *second* file on the linker command line
|
|
|
|
; (.cvt header must be the *first* one)
|
|
|
|
|
2001-08-15 16:08:15 +00:00
|
|
|
; Maciej 'YTM/Elysium' Witkowiak
|
|
|
|
; 26.10.99, 10.3.2000, 15.8.2001
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; no __hinit
|
|
|
|
|
2000-11-22 22:19:09 +00:00
|
|
|
.export _exit
|
|
|
|
.import initlib, donelib
|
2000-05-28 13:40:48 +00:00
|
|
|
.import pushax
|
|
|
|
.import _main
|
2000-11-22 22:19:09 +00:00
|
|
|
.import zerobss
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Define and export the ZP variables for the C64 runtime
|
|
|
|
|
|
|
|
.exportzp sp, sreg, regsave, regbank
|
|
|
|
.exportzp ptr1, ptr2, ptr3, ptr4
|
|
|
|
.exportzp tmp1, tmp2, tmp3, tmp4
|
|
|
|
|
|
|
|
sp = $72 ; stack pointer
|
|
|
|
sreg = $74 ; secondary register/high 16 bit for longs
|
|
|
|
regsave = $76 ; slot to save/restore (E)AX into
|
|
|
|
ptr1 = $7A ;
|
|
|
|
ptr2 = $7C
|
|
|
|
ptr3 = $7E
|
|
|
|
ptr4 = $70
|
|
|
|
tmp1 = $fb
|
|
|
|
tmp2 = $fc
|
|
|
|
tmp3 = $fd
|
|
|
|
tmp4 = $fe
|
|
|
|
|
|
|
|
regbank = $a3 ; 6 bytes hopefully not used by Kernal
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
|
|
|
|
; .org $0400-508 ; $0400 - length of .cvt header
|
|
|
|
; .include "cvthead.s"
|
|
|
|
|
|
|
|
.reloc
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Actual code
|
|
|
|
|
|
|
|
; Clear the BSS data
|
|
|
|
|
|
|
|
jsr zerobss
|
|
|
|
|
|
|
|
; Setup stack
|
|
|
|
|
2001-08-15 16:08:15 +00:00
|
|
|
lda #<$6000
|
2000-05-28 13:40:48 +00:00
|
|
|
sta sp
|
2001-08-15 16:08:15 +00:00
|
|
|
lda #>$6000
|
2000-05-28 13:40:48 +00:00
|
|
|
sta sp+1 ; Set argument stack ptr
|
|
|
|
|
2000-11-22 22:19:09 +00:00
|
|
|
; Call module constructors
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2000-11-22 22:19:09 +00:00
|
|
|
jsr initlib
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; Pass an empty command line
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
tax
|
|
|
|
jsr pushax ; argc
|
|
|
|
jsr pushax ; argv
|
|
|
|
|
2002-04-06 17:37:12 +00:00
|
|
|
cli
|
2000-05-28 13:40:48 +00:00
|
|
|
ldy #4 ; Argument size
|
|
|
|
jsr _main ; call the users code
|
|
|
|
jmp $c1c3 ; jump to GEOS MainLoop
|
|
|
|
|
2000-11-22 22:19:09 +00:00
|
|
|
; Call module destructors. This is also the _exit entry which must be called
|
|
|
|
; explicitly by the code.
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2000-11-22 22:19:09 +00:00
|
|
|
_exit: jsr donelib ; Run module destructors
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2000-11-22 22:19:09 +00:00
|
|
|
jmp $c22c ; EnterDeskTop
|
|
|
|
|