Update bootstrap code
Was missing some things like initializing the stack pointer, clearing BSS, and things like that
This commit is contained in:
70
sw/boot.s
70
sw/boot.s
@@ -1,15 +1,59 @@
|
|||||||
.import _main
|
; ---------------------------------------------------------------------------
|
||||||
|
; crt0.s
|
||||||
.export __STARTUP__ : absolute = 1
|
; ---------------------------------------------------------------------------
|
||||||
|
;
|
||||||
|
; Startup code for cc65 (Single Board Computer version)
|
||||||
|
|
||||||
.segment "VECTORS"
|
.export _init, _exit
|
||||||
|
.import _main
|
||||||
.addr _init
|
|
||||||
.addr _init
|
|
||||||
.addr _init
|
|
||||||
|
|
||||||
.segment "STARTUP"
|
|
||||||
|
|
||||||
_init: jsr _main
|
|
||||||
|
|
||||||
end: jmp end
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||||
|
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
||||||
|
|
||||||
|
.import copydata, zerobss, initlib, donelib
|
||||||
|
|
||||||
|
.include "zeropage.inc"
|
||||||
|
|
||||||
|
.segment "VECTORS"
|
||||||
|
|
||||||
|
.addr _init
|
||||||
|
.addr _init
|
||||||
|
.addr _init
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; 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
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; Back from main (this is also the _exit entry): force a software break
|
||||||
|
|
||||||
|
_exit: JSR donelib ; Run destructors
|
||||||
|
BRK
|
||||||
|
|||||||
Reference in New Issue
Block a user