d8c31cf1d3
The name RAM doesn't make much sense in general for a memeory area because i.e. the zero page is for sure RAM but is not part of the memory area named RAM. For disk based targets it makes sense to put the disk file more into focus and here MAIN means the main part of the file - in contrast to some header. Only for ROM based targets the name RAM is kept as it makes sense to focus on the difference between RAM and ROM.
63 lines
1.6 KiB
ArmAsm
63 lines
1.6 KiB
ArmAsm
|
|
.export Start, _exit
|
|
|
|
.import initlib, donelib, callmain
|
|
.import push0, _main, zerobss, copydata
|
|
|
|
; Linker generated symbols
|
|
.import __RAM_START__, __RAM_SIZE__
|
|
|
|
.include "zeropage.inc"
|
|
.include "gamate.inc"
|
|
|
|
Start:
|
|
; setup the CPU and System-IRQ
|
|
|
|
; Initialize CPU
|
|
sei
|
|
cld
|
|
|
|
ldx #0
|
|
stx ZP_IRQ_CTRL ; disable calling cartridge IRQ/NMI handler
|
|
|
|
; Setup stack and memory mapping
|
|
;ldx #$FF ; Stack top ($01FF)
|
|
dex
|
|
txs
|
|
|
|
; Clear the BSS data
|
|
jsr zerobss
|
|
|
|
; Copy the .data segment to RAM
|
|
jsr copydata
|
|
|
|
; setup the stack
|
|
lda #<(__RAM_START__+__RAM_SIZE__)
|
|
ldx #>(__RAM_START__+__RAM_SIZE__)
|
|
sta sp
|
|
stx sp + 1
|
|
|
|
; Call module constructors
|
|
jsr initlib
|
|
|
|
lda #1
|
|
sta ZP_IRQ_CTRL ; enable calling cartridge IRQ/NMI handler
|
|
cli ; allow IRQ only after constructors have run
|
|
|
|
; Pass an empty command line
|
|
jsr push0 ; argc
|
|
jsr push0 ; argv
|
|
|
|
ldy #4 ; Argument size
|
|
jsr _main ; call the users code
|
|
|
|
; Call module destructors. This is also the _exit entry.
|
|
_exit:
|
|
jsr donelib ; Run module destructors
|
|
|
|
; reset (start over)
|
|
jmp Start
|
|
|
|
.export initmainargs
|
|
initmainargs:
|
|
rts
|