1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-26 08:32:00 +00:00
cc65/libsrc/gamate/crt0.s

64 lines
1.6 KiB
ArmAsm
Raw Normal View History

2015-11-22 18:02:47 +00:00
.export Start, _exit
2015-11-22 18:02:47 +00:00
2015-11-29 00:14:59 +00:00
.import initlib, donelib, callmain
.import push0, _main, zerobss, copydata
2015-11-22 18:02:47 +00:00
2015-11-29 00:14:59 +00:00
; Linker generated symbols
.import __RAM_START__, __RAM_SIZE__
.include "zeropage.inc"
.include "gamate.inc"
2015-11-22 18:02:47 +00:00
Start:
2015-11-29 00:14:59 +00:00
; setup the CPU and System-IRQ
; Initialize CPU
sei
cld
2015-11-29 19:04:10 +00:00
ldx #0
stx ZP_IRQ_CTRL ; disable calling cartridge IRQ/NMI handler
; Set up stack and memory mapping
2015-11-29 19:04:10 +00:00
;ldx #$FF ; Stack top ($01FF)
dex
2015-11-29 00:14:59 +00:00
txs
; Clear the BSS data
jsr zerobss
; Copy the .data segment to RAM
jsr copydata
; Set up the stack
2015-11-29 00:14:59 +00:00
lda #<(__RAM_START__+__RAM_SIZE__)
ldx #>(__RAM_START__+__RAM_SIZE__)
2015-11-29 00:14:59 +00:00
sta sp
stx sp + 1
2015-11-29 00:14:59 +00:00
; Call module constructors
jsr initlib
2015-11-29 19:04:10 +00:00
lda #1
sta ZP_IRQ_CTRL ; enable calling cartridge IRQ/NMI handler
cli ; allow IRQ only after constructors have run
2015-11-29 00:14:59 +00:00
; Pass an empty command line
jsr push0 ; argc
jsr push0 ; argv
ldy #4 ; Argument size
jsr _main ; call the users code
; Call module destructors. This is also the _exit entry.
_exit:
jsr donelib ; Run module destructors
; reset (start over)
jmp Start
2015-11-22 18:02:47 +00:00
2015-11-29 00:14:59 +00:00
.export initmainargs
initmainargs:
rts