From dc4e898abd273970b52c9fbfda6d721c6ee77a09 Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 4 Nov 2012 15:23:05 +0000 Subject: [PATCH] Use the new declarations from the zeropage include file. In interrupt handlers that call C code, we don't need to save the register bank, because the C code will save it, when needed. git-svn-id: svn://svn.cc65.org/cc65/trunk@5909 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/common/_printf.s | 7 ++++--- libsrc/common/interrupt.s | 40 +++++++++++++++++++++------------------ libsrc/common/modload.s | 4 ++-- libsrc/dbg/dbgsupp.s | 9 +++++---- libsrc/runtime/zeropage.s | 9 +++------ 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/libsrc/common/_printf.s b/libsrc/common/_printf.s index a8470df3e..2169896ba 100644 --- a/libsrc/common/_printf.s +++ b/libsrc/common/_printf.s @@ -1,15 +1,16 @@ ; ; _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 @@ -750,7 +751,7 @@ HaveArg: .bss ; Save area for the zero page registers -RegSave: .res 6 +RegSave: .res regbanksize ; One character argument for OutFunc CharArg: .byte 0 diff --git a/libsrc/common/interrupt.s b/libsrc/common/interrupt.s index 574acab55..c7d0d896c 100644 --- a/libsrc/common/interrupt.s +++ b/libsrc/common/interrupt.s @@ -6,14 +6,31 @@ ; .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 @@ -59,8 +76,8 @@ 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 @@ -75,9 +92,9 @@ 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 @@ -87,16 +104,3 @@ .endproc -; --------------------------------------------------------------------------- - -.data - -irqvec: jmp $00FF ; Patched at runtime - -; --------------------------------------------------------------------------- - -.bss - -irqsp: .res 2 - -zpsave: .res zpspace diff --git a/libsrc/common/modload.s b/libsrc/common/modload.s index 63776f1c8..2a4371215 100644 --- a/libsrc/common/modload.s +++ b/libsrc/common/modload.s @@ -35,11 +35,11 @@ .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 @@ -58,7 +58,7 @@ TPtr = regbank+4 ; Pointer to module data for relocation ; 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 diff --git a/libsrc/dbg/dbgsupp.s b/libsrc/dbg/dbgsupp.s index 5ab0f5863..0f9a7041c 100644 --- a/libsrc/dbg/dbgsupp.s +++ b/libsrc/dbg/dbgsupp.s @@ -5,7 +5,7 @@ ; .export _DbgInit - .export _DbgSP, _DbgCS, _DbgHI + .export _DbgSP, _DbgCS, _DbgHI .import popax, return0, _DbgEntry, _set_brk, _end_brk .import _DbgBreaks .import _brk_pc @@ -63,7 +63,8 @@ DbgStack: 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 @@ -72,7 +73,7 @@ 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 @@ -91,7 +92,7 @@ Swap1: ldx 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 diff --git a/libsrc/runtime/zeropage.s b/libsrc/runtime/zeropage.s index ab87901dd..8d5818344 100644 --- a/libsrc/runtime/zeropage.s +++ b/libsrc/runtime/zeropage.s @@ -4,10 +4,7 @@ ; CC65 runtime: zeropage usage ; - .exportzp sp, sreg, regsave - .exportzp ptr1, ptr2, ptr3, ptr4 - .exportzp tmp1, tmp2, tmp3, tmp4 - .exportzp regbank +.include "zeropage.inc" ; ------------------------------------------------------------------------ @@ -15,7 +12,7 @@ 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 @@ -24,7 +21,7 @@ tmp1: .res 1 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 -- 2.39.5