2014-03-01 16:20:09 +00:00
|
|
|
;
|
|
|
|
; Startup code for cc65 (Atari5200 version)
|
|
|
|
;
|
2014-04-25 01:02:44 +00:00
|
|
|
; Christian Groessler (chris@groessler.org), 2014
|
2014-03-01 16:20:09 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
.export _exit, start
|
|
|
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
2014-03-13 01:36:10 +00:00
|
|
|
.import __RAM_START__, __RAM_SIZE__
|
|
|
|
.import __RESERVED_MEMORY__
|
2014-03-01 16:20:09 +00:00
|
|
|
|
|
|
|
.import initlib, donelib, callmain
|
|
|
|
.import zerobss, copydata
|
|
|
|
|
|
|
|
.include "zeropage.inc"
|
|
|
|
.include "atari5200.inc"
|
|
|
|
|
|
|
|
start:
|
|
|
|
|
2014-08-23 18:05:36 +00:00
|
|
|
; Clear the BSS data.
|
2014-03-01 16:20:09 +00:00
|
|
|
|
|
|
|
jsr zerobss
|
|
|
|
|
2014-08-23 18:05:36 +00:00
|
|
|
; Initialize the data.
|
2014-03-01 16:20:09 +00:00
|
|
|
jsr copydata
|
|
|
|
|
2014-08-23 18:05:36 +00:00
|
|
|
; Set up the stack.
|
2014-03-01 16:20:09 +00:00
|
|
|
|
2014-03-13 01:36:10 +00:00
|
|
|
lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
2014-03-01 16:20:09 +00:00
|
|
|
sta sp
|
2014-03-13 01:36:10 +00:00
|
|
|
lda #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
2014-03-01 16:20:09 +00:00
|
|
|
sta sp+1 ; Set argument stack ptr
|
|
|
|
|
2014-08-23 18:05:36 +00:00
|
|
|
; Call the module constructors.
|
2014-03-01 16:20:09 +00:00
|
|
|
|
|
|
|
jsr initlib
|
|
|
|
|
2014-08-23 18:05:36 +00:00
|
|
|
; Push the command-line arguments; and, call main().
|
2014-03-01 16:20:09 +00:00
|
|
|
|
|
|
|
jsr callmain
|
|
|
|
|
2014-08-23 18:05:36 +00:00
|
|
|
; Call the module destructors. This is also the exit() entry.
|
2014-03-01 16:20:09 +00:00
|
|
|
|
|
|
|
_exit: jsr donelib ; Run module destructors
|
|
|
|
|
2014-04-25 01:02:44 +00:00
|
|
|
; A 5200 program isn't supposed to exit.
|
2014-03-01 16:20:09 +00:00
|
|
|
|
2014-04-25 01:02:44 +00:00
|
|
|
halt: jmp halt
|