1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-18 15:05:14 +00:00
cc65/libsrc/rp6502/crt0.s

52 lines
899 B
ArmAsm
Raw Normal View History

2023-11-17 02:46:16 +00:00
;
2023-11-17 19:08:51 +00:00
; 2023, Rumbledethumps
;
; crt0.s
2023-11-17 02:46:16 +00:00
.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