Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; -----------------------------------------------------------------------------
- ; crt0.s
- ; -----------------------------------------------------------------------------
- ;
- ; Startup code for cc65 (RPC8e version)
- ;
- .export _init, _exit
- .import _main
- .export __STARTUP__ : absolute = 1 ; Mark as startup
- .import __RAM_START__, __RAM_SIZE__ ; Linker generated
- ; FIXME: We should probe in _init to determine the actual ram size,
- ; instead of assuming a full 64k...
- .import copydata, zerobss, initlib, donelib
- .include "zeropage.inc"
- .bss
- ; -----------------------------------------------------------------------------
- ; Place the startup code in a special segment.
- .segment "STARTUP"
- ; -----------------------------------------------------------------------------
- ; A little light 6502 housekeeping.
- _init: ; LDX #$FF ; Initialize stack pointer to $01FF.
- ; TXS
- ; CLD ; Clear decimal mode.
- ; -----------------------------------------------------------------------------
- ; 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
- ; -----------------------------------------------------------------------------
- ; Cleanup and exit.
- _exit: ; JSR donelib ; Run destructors
- exitloop: JMP exitloop
- ; Do we really want to BRK here? Or ought we enter an infinite WAI
- ; loop instead?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement