1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 17:29:50 +00:00
cc65/libsrc/sym1/crt0.s

58 lines
1.5 KiB
ArmAsm
Raw Normal View History

;
2021-06-07 02:28:03 +00:00
; Startup code for cc65 (Sym-1 version)
;
.export _init, _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import _main
.import initlib, donelib, copydata, zerobss
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.import __STACKSIZE__ ; Linker generated
.include "zeropage.inc"
.include "sym1.inc"
2021-06-07 02:28:03 +00:00
; Place the startup code in a special segment
.segment "STARTUP"
2021-06-07 02:28:03 +00:00
; A little light housekeeping
_init: jsr ACCESS ; Unlock System RAM
cld ; Clear decimal mode
2021-06-07 02:28:03 +00:00
; Turn off console echo
lda TECHO
and #$7F
sta TECHO
2021-06-07 02:28:03 +00:00
; Set cc65 argument stack pointer
lda #<(__RAM_START__ + __RAM_SIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__)
sta sp+1
2021-06-07 02:28:03 +00:00
; Initialize memory storage
jsr zerobss ; Clear BSS segment
jsr copydata ; Initialize DATA segment
jsr initlib ; Run constructors
2021-06-07 02:28:03 +00:00
; Call main()
jsr _main
2021-06-07 02:28:03 +00:00
; Back from main (this is also the _exit entry)
_exit: jsr donelib ; Run destructors
lda TECHO
ora #$80 ; Re-enable console echo
sta TECHO
2022-02-02 22:02:01 +00:00
jmp NACCES ; Lock System RAM
; Re-enter Sym-1 monitor