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
20 ; Setup stack and memory mapping
21 ldx #$FF ; Stack top ($01FF)
27 ; Copy the .data segment to RAM
31 lda #<(__RAM_START__+__RAM_SIZE__)
33 lda #>(__RAM_START__+__RAM_SIZE__)
36 ; Call module constructors
39 cli ; allow IRQ only after constructors have run
41 ; Pass an empty command line
45 ldy #4 ; Argument size
46 jsr _main ; call the users code
48 ; Call module destructors. This is also the _exit entry.
50 jsr donelib ; Run module destructors