;
; _printf: Basic layer for all printf type functions.
;
-; Ullrich von Bassewitz, 21.10.2000
+; Ullrich von Bassewitz, 2000-10-21
;
+
+ .include "zeropage.inc"
.export __printf
.import popax, pushax, pusheax, decsp6, push1, axlong, axulong
.import _ltoa, _ultoa
.import _strlower, _strlen
- .importzp sp, ptr1, ptr2, tmp1, regbank, sreg
.macpack generic
.bss
; Save area for the zero page registers
-RegSave: .res 6
+RegSave: .res regbanksize
; One character argument for OutFunc
CharArg: .byte 0
;
.export _set_irq, _reset_irq
- .interruptor clevel_irq, 1 ; Export as low priority IRQ handler
+ .interruptor clevel_irq, 1 ; Export as low priority IRQ handler
.import popax
+ .importzp __ZP_START__
.include "zeropage.inc"
.macpack generic
+; ---------------------------------------------------------------------------
+
+.data
+
+irqvec: jmp $00FF ; Patched at runtime
+
+; ---------------------------------------------------------------------------
+
+.bss
+
+irqsp: .res 2
+
+zpsave: .res zpsavespace
+
+; ---------------------------------------------------------------------------
+
.proc _set_irq
; Keep clevel_irq from being called right now
rts
; Save our zero page locations
-@L1: ldx #zpspace-1
-@L2: lda sp,x
+@L1: ldx #.sizeof(::zpsave)-1
+@L2: lda __ZP_START__,x
sta zpsave,x
dex
bpl @L2
jsr irqvec
; Copy back our zero page content
- ldx #zpspace-1
+ ldx #.sizeof(::zpsave)-1
@L3: ldy zpsave,x
- sty sp,x
+ sty __ZP_START__,x
dex
bpl @L3
.endproc
-; ---------------------------------------------------------------------------
-
-.data
-
-irqvec: jmp $00FF ; Patched at runtime
-
-; ---------------------------------------------------------------------------
-
-.bss
-
-irqsp: .res 2
-
-zpsave: .res zpspace
.include "o65.inc"
.include "modload.inc"
+ .include "zeropage.inc"
.import pushax, pusha0, push0, push1, decax1
.import _malloc, _free, _bzero
.import __ZP_START__ ; Linker generated
- .importzp sp, ptr1, tmp1, regbank
.macpack generic
; Save areas and error recovery data
Stack: .byte 0 ; Old stackpointer
-RegBankSave: .res 6 ; Save area for register bank
+RegBankSave: .res regbanksize ; Save area for register bank
; The header of the o65 file. Since we don't need the first 8 bytes any
; longer, once we've checked them, we will overlay them with other data to
;
.export _DbgInit
- .export _DbgSP, _DbgCS, _DbgHI
+ .export _DbgSP, _DbgCS, _DbgHI
.import popax, return0, _DbgEntry, _set_brk, _end_brk
.import _DbgBreaks
.import _brk_pc
CTemp:
_DbgCS: .res 2 ; sp
_DbgHI: .res 2 ; sreg
- .res (zpspace-4) ; Other stuff
+ .res (zpsavespace-4) ; Other stuff
+
_DbgSP: .res 1
retsav: .res 2 ; Save buffer for return address
; Swap the C temporaries
DbgSwapZP:
- ldy #zpspace-1
+ ldy #zpsavespace-1
Swap1: ldx CTemp,y
lda <__ZP_START__,y
sta CTemp,y
; reset the breakpoints. See declaration of struct breakpoint in the C
; source
-MaxBreaks = 48 ; 4*12
+MaxBreaks = 48 ; 4*12
ResetDbgBreaks:
ldy #0
; CC65 runtime: zeropage usage
;
- .exportzp sp, sreg, regsave
- .exportzp ptr1, ptr2, ptr3, ptr4
- .exportzp tmp1, tmp2, tmp3, tmp4
- .exportzp regbank
+.include "zeropage.inc"
; ------------------------------------------------------------------------
sp: .res 2 ; Stack pointer
sreg: .res 2 ; Secondary register/high 16 bit for longs
-regsave: .res 4 ; slot to save/restore (E)AX into
+regsave: .res 4 ; Slot to save/restore (E)AX into
ptr1: .res 2
ptr2: .res 2
ptr3: .res 2
tmp2: .res 1
tmp3: .res 1
tmp4: .res 1
-regbank: .res 6 ; 6 byte register bank
+regbank: .res regbanksize ; Register bank
; Add an empty EXTZP zeropage segment to avoid linker warnings that this
; segment does not exist (it does not exist in most builtin linker configs