1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-27 15:29:46 +00:00
cc65/libsrc/atari5200/crt0.s

48 lines
1.1 KiB
ArmAsm
Raw Normal View History

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