-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrt0.s
38 lines (28 loc) · 852 Bytes
/
crt0.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
; ======[crt0.s]======
;
; Startup code for cc65 (athena version)
.export _init, _exit
.import _main
.export __STARTUP__ : absolute = 1 ; mark as startup
.import __RAM_START__, __RAM_SIZE__ ; linker generated
.import copydata, zerobss, initlib, donelib
.include "zeropage.inc"
; Place startup code in its segment
.segment "STARTUP"
; 6502 cpu setup
_init:
ldx #$ff ; set the 6502 stack pointer
txs
cld ; disable decimal
; set the C stack pointer
lda #<(__RAM_START__ + __RAM_SIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__)
sta sp+1
jsr zerobss ; initialize BSS segment
jsr copydata ; copy variables from ROM to RAM
jsr initlib
jsr _main ; jump to entry point
_exit:
jsr donelib
brk ; software interrupt