4 .import initlib, donelib, callmain
5 .import push0, _main, zerobss, copydata
7 ; Linker generated symbols
8 .import __RAM_START__, __RAM_SIZE__
10 .include "zeropage.inc"
14 ; setup the CPU and System-IRQ
21 stx ZP_IRQ_CTRL ; disable calling cartridge IRQ/NMI handler
23 ; Setup stack and memory mapping
24 ;ldx #$FF ; Stack top ($01FF)
31 ; Copy the .data segment to RAM
35 lda #<(__RAM_START__+__RAM_SIZE__)
37 lda #>(__RAM_START__+__RAM_SIZE__)
40 ; Call module constructors
44 sta ZP_IRQ_CTRL ; enable calling cartridge IRQ/NMI handler
45 cli ; allow IRQ only after constructors have run
47 ; Pass an empty command line
51 ldy #4 ; Argument size
52 jsr _main ; call the users code
54 ; Call module destructors. This is also the _exit entry.
56 jsr donelib ; Run module destructors