1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00
cc65/libsrc/rp6502/crt0.s

55 lines
1.0 KiB
ArmAsm
Raw Normal View History

2023-11-17 02:46:16 +00:00
; Copyright (c) 2023 Rumbledethumps
;
; SPDX-License-Identifier: Zlib
; SPDX-License-Identifier: BSD-3-Clause
; SPDX-License-Identifier: Unlicense
; Boilerplate crt0.s
.export _init, _exit
.import _main
.export __STARTUP__ : absolute = 1
.import __RAM_START__, __RAM_SIZE__
.import copydata, zerobss, initlib, donelib
.include "rp6502.inc"
.include "zeropage.inc"
.segment "STARTUP"
; Essential 6502 startup the CPU doesn't do
_init:
ldx #$FF
txs
cld
; Set cc65 argument stack pointer
lda #<(__RAM_START__ + __RAM_SIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__)
sta sp+1
; Initialize memory storage
jsr zerobss ; Clear BSS segment
jsr copydata ; Initialize DATA segment
jsr initlib ; Run constructors
; Call main()
jsr _main
; Back from main() also the _exit entry
; Stack the exit value in case destructors call OS
_exit:
phx
pha
jsr donelib ; Run destructors
pla
sta RIA_A
plx
stx RIA_X
lda #$FF ; exit()
sta RIA_OP
stp