; Define and export the ZP variables for the C64 runtime
.exportzp sp, sreg, regsave
- .exportzp ptr1, ptr2, ptr3, ptr4
- .exportzp tmp1, tmp2, tmp3, tmp4
- .exportzp regbank, zpspace
-
-; These zero page entries overlap with the sweet-16 registers.
-; must be changed if sweet-16 is to be supported
-sp = $00 ; stack pointer
-sreg = $02 ; secondary register/high 16 bit for longs
-regsave = $04 ; slot to save/restore (E)AX into
-ptr1 = $08 ;
-ptr2 = $0A
-ptr3 = $0C
-ptr4 = $0E
-tmp1 = $10
-tmp2 = $11
-tmp3 = $12
-tmp4 = $13
-regbank = $14 ; 6 byte register bank
-zpspace = $1A ; Zero page space allocated
+ .exportzp ptr1, ptr2, ptr3, ptr4
+ .exportzp tmp1, tmp2, tmp3, tmp4
+ .exportzp regbank, zpspace
+
+; These zero page entries overlap with the sweet-16 registers in
+; the standard apple2 linker config. They must be changed if sweet-16
+; is to be supported
+
+.zeropage
+
+zpstart = *
+sp: .res 2 ; Stack pointer
+sreg: .res 2 ; Secondary register/high 16 bit for longs
+regsave: .res 2 ; slot to save/restore (E)AX into
+ptr1: .res 2
+ptr2: .res 2
+ptr3: .res 2
+ptr4: .res 2
+tmp1: .res 1
+tmp2: .res 1
+tmp3: .res 1
+tmp4: .res 1
+regbank: .res 6 ; 6 byte register bank
+
+zpspace = * - zpstart ; Zero page space allocated
+
+.code
; ------------------------------------------------------------------------
; Actual code
.exportzp tmp1, tmp2, tmp3, tmp4
.exportzp fntemp, regbank, zpspace
-sp = $D2 ; (2bytes) stack pointer
-sreg = $D4 ; (2bytes) secondary register/high 16 bit for longs
-regsave = $D6 ; (4bytes) slot to save/restore (E)AX into
-ptr1 = $DA ; (2bytes)
-ptr2 = $DC ; (2bytes)
-ptr3 = $DE ; (2bytes)
-ptr4 = $E0 ; (2bytes)
-tmp1 = $E2 ; (1byte)
-tmp2 = $E3 ; (1byte)
-tmp3 = $E4 ; (1byte)
-tmp4 = $E5 ; (1byte)
-fntemp = $E6 ; (2bytes) pointer to file name
-regbank = $E8 ; (6bytes) 6 byte register bank
-zpspace = $EE - sp ; Zero page space allocated
+
+.zeropage
+
+zpstart = *
+sp: .res 2 ; Stack pointer
+sreg: .res 2 ; Secondary register/high 16 bit for longs
+regsave: .res 2 ; slot to save/restore (E)AX into
+ptr1: .res 2
+ptr2: .res 2
+ptr3: .res 2
+ptr4: .res 2
+tmp1: .res 1
+tmp2: .res 1
+tmp3: .res 1
+tmp4: .res 1
+fntemp: .res 2 ; Pointer to file name
+regbank: .res 6 ; 6 byte register bank
+
+zpspace = * - zpstart ; Zero page space allocated
+
+.code
; ------------------------------------------------------------------------
; EXE header
sta appmsav+1
jsr getmemtop ; adjust for graphics mode to use
-
+
sta sp
sta APPMHI
stx sp+1 ; Set argument stack ptr
stx APPMHI+1
-
+
; set left margin to 0
lda LMARGN
ldx SHFLOK
stx old_shflok
sta SHFLOK
-
+
; Initialize the heap
jsr __hinit
sta SHFLOK
; restore APPMHI
-
+
lda appmsav
sta APPMHI
lda appmsav+1
; 220 GRAPHICS 0
; 230 FOR I=0 TO 31:PRINT #1;I;":",G(I);" - ";G(0)-G(I):NEXT I
; 240 CLOSE #1
-; 999 END
+; 999 END
; 1000 VAL=PEEK(741)+256*PEEK(742)
-; 1010 RETURN
+; 1010 RETURN
.bss
.exportzp tmp1, tmp2, tmp3, tmp4
.exportzp regbank, zpspace
-sp = $02 ; stack pointer
-sreg = $04 ; secondary register/high 16 bit for longs
-regsave = $06 ; slot to save/restore (E)AX into
-ptr1 = $0A ;
-ptr2 = $0C
-ptr3 = $0E
-ptr4 = $10
-tmp1 = $12
-tmp2 = $13
-tmp3 = $14
-tmp4 = $15
-regbank = $16 ; 6 byte register bank
-zpspace = $1A ; Zero page space allocated
+.zeropage
+
+zpstart = *
+sp: .res 2 ; Stack pointer
+sreg: .res 2 ; Secondary register/high 16 bit for longs
+regsave: .res 2 ; slot to save/restore (E)AX into
+ptr1: .res 2
+ptr2: .res 2
+ptr3: .res 2
+ptr4: .res 2
+tmp1: .res 1
+tmp2: .res 1
+tmp3: .res 1
+tmp4: .res 1
+regbank: .res 6 ; 6 byte register bank
+
+zpspace = * - zpstart ; Zero page space allocated
+
+.code
; ------------------------------------------------------------------------
; BASIC header with a SYS call
.exportzp tmp1, tmp2, tmp3, tmp4
.exportzp regbank, zpspace
-sp = $02 ; stack pointer
-sreg = $04 ; secondary register/high 16 bit for longs
-regsave = $06 ; slot to save/restore (E)AX into
-ptr1 = $0A ;
-ptr2 = $0C
-ptr3 = $0E
-ptr4 = $10
-tmp1 = $12
-tmp2 = $13
-tmp3 = $14
-tmp4 = $15
-regbank = $16 ; 6 byte register bank
-zpspace = $1A ; Zero page space allocated
+.zeropage
+
+zpstart = *
+sp: .res 2 ; Stack pointer
+sreg: .res 2 ; Secondary register/high 16 bit for longs
+regsave: .res 2 ; slot to save/restore (E)AX into
+ptr1: .res 2
+ptr2: .res 2
+ptr3: .res 2
+ptr4: .res 2
+tmp1: .res 1
+tmp2: .res 1
+tmp3: .res 1
+tmp4: .res 1
+regbank: .res 6 ; 6 byte register bank
+
+zpspace = * - zpstart ; Zero page space allocated
+
+.code
; ------------------------------------------------------------------------
; BASIC header with a SYS call
.exportzp crtc, sid, IPCcia, cia, acia, tpi1, tpi2
.exportzp ktab1, ktab2, ktab3, ktab4, time, RecvBuf, SendBuf
-sp = $02 ; stack pointer
-sreg = $04 ; secondary register/high 16 bit for longs
-regsave = $06 ; slot to save/restore (E)AX into
-ptr1 = $0A ;
-ptr2 = $0C
-ptr3 = $0E
-ptr4 = $10
-tmp1 = $12
-tmp2 = $13
-tmp3 = $14
-tmp4 = $15
-regbank = $16 ; 6 byte register bank
-zpspace = $1A ; Zero page space allocated
+.zeropage
+
+zpstart = *
+sp: .res 2 ; Stack pointer
+sreg: .res 2 ; Secondary register/high 16 bit for longs
+regsave: .res 2 ; slot to save/restore (E)AX into
+ptr1: .res 2
+ptr2: .res 2
+ptr3: .res 2
+ptr4: .res 2
+tmp1: .res 1
+tmp2: .res 1
+tmp3: .res 1
+tmp4: .res 1
+regbank: .res 6 ; 6 byte register bank
+
+zpspace = * - zpstart ; Zero page space allocated
+
+.code
; ------------------------------------------------------------------------
; BASIC header and a small BASIC program. Since it is not possible to start
.exportzp tmp1, tmp2, tmp3, tmp4
.exportzp regbank, zpspace
-sp = $02 ; stack pointer
-sreg = $04 ; secondary register/high 16 bit for longs
-regsave = $06 ; slot to save/restore (E)AX into
-ptr1 = $0A ;
-ptr2 = $0C
-ptr3 = $0E
-ptr4 = $10
-tmp1 = $12
-tmp2 = $13
-tmp3 = $14
-tmp4 = $15
-regbank = $16 ; 6 byte register bank
-zpspace = $1A ; Zero page space allocated
+.zeropage
+
+zpstart = *
+sp: .res 2 ; Stack pointer
+sreg: .res 2 ; Secondary register/high 16 bit for longs
+regsave: .res 2 ; slot to save/restore (E)AX into
+ptr1: .res 2
+ptr2: .res 2
+ptr3: .res 2
+ptr4: .res 2
+tmp1: .res 1
+tmp2: .res 1
+tmp3: .res 1
+tmp4: .res 1
+regbank: .res 6 ; 6 byte register bank
+
+zpspace = * - zpstart ; Zero page space allocated
+
+.code
; ------------------------------------------------------------------------
; BASIC header with a SYS call
.exportzp tmp1, tmp2, tmp3, tmp4
.exportzp regbank, zpspace
-sp = $02 ; stack pointer
-sreg = $04 ; secondary register/high 16 bit for longs
-regsave = $06 ; slot to save/restore (E)AX into
-ptr1 = $0A ;
-ptr2 = $0C
-ptr3 = $0E
-ptr4 = $10
-tmp1 = $12
-tmp2 = $13
-tmp3 = $14
-tmp4 = $15
-regbank = $16 ; 6 byte register bank
-zpspace = $1A ; Zero page space allocated
+.zeropage
+
+zpstart = *
+sp: .res 2 ; Stack pointer
+sreg: .res 2 ; Secondary register/high 16 bit for longs
+regsave: .res 2 ; slot to save/restore (E)AX into
+ptr1: .res 2
+ptr2: .res 2
+ptr3: .res 2
+ptr4: .res 2
+tmp1: .res 1
+tmp2: .res 1
+tmp3: .res 1
+tmp4: .res 1
+regbank: .res 6 ; 6 byte register bank
+
+zpspace = * - zpstart ; Zero page space allocated
+
+.code
; ------------------------------------------------------------------------
; BASIC header with a SYS call