2 ; Startup code for cc65 (Oric version)
4 ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
6 ; This must be the *first* file on the linker command line
10 .import initlib, donelib
11 .import push0, _main, zerobss
12 .import __RAM_START__, __RAM_SIZE__ ; Linker generated
15 ; ------------------------------------------------------------------------
16 ; Define and export the ZP variables for the Oric runtime
18 .exportzp sp, sreg, regsave
19 .exportzp ptr1, ptr2, ptr3, ptr4
20 .exportzp tmp1, tmp2, tmp3, tmp4
21 .exportzp regbank, zpspace
26 sp: .res 2 ; Stack pointer
27 sreg: .res 2 ; Secondary register/high 16 bit for longs
28 regsave: .res 2 ; slot to save/restore (E)AX into
37 regbank: .res 6 ; 6 byte register bank
39 zpspace = * - zpstart ; Zero page space allocated
43 ; ------------------------------------------------------------------------
50 ; Save system stuff and setup the stack
53 stx spsave ; save system stk ptr
55 lda #<(__RAM_START__ + __RAM_SIZE__)
57 lda #>(__RAM_START__ + __RAM_SIZE__)
58 sta sp+1 ; Set argument stack ptr
60 ; Call module constructors
64 ; Pass an empty command line
69 ldy #4 ; Argument size
70 jsr _main ; call the users code
72 ; Call module destructors. This is also the _exit entry.
74 _exit: jsr donelib ; Run module destructors
76 ; Restore system stuff