BigEd wrote:
Ah, thanks, I see. Having successful avoiding reusing &10, the problem is that one of the IRQ handlers detects STOP on the keyboard directly, and jumps into BASIC. Although the IRQ is vectored through RAM, that RAM pointer is updated in the tape-handling routines. So the puzzle is to repair the vector or avoid setting it... without duplicating too much of the ROM code.
Exactly! I can't be the first guy ever to attempt using the Commodore tape I/O from a new language.
The $10 issue is resolved. Zero page usage for now still has SWEET16's registers overlapping Forth registers, followed by the split stack. The first z.p. used by the kernel is TI at $8d, like so:
Code:
; SWEET16 registers
R0 - R15 $00 - $1f
; PETTIL registers and stack
TOS $02 - $03 ; top of stack
UP $04 - $05 ; user pointer for user variables
I $06 - $07 ; counter of innermost DO loop
ILIMIT $08 - $09 ; limit of innermost DO loop
N $0A - $11 ; 8 bytes of scratch area for primitives
STACKL $20 - $52 ; low order half of stack
STACKH $53 - $85 ; high order half of stack
STOREX $ff ; temp storage for the stack pointer / scratch area
; NEXT routine (15 clocks!)
; secondaries that straddle page boundaries run a word at $xxFD or $xxFE to bump IP+1
; avoiding the JMP ($xxFF) CPU bug
IP $8b - $8c
0086 NEXT INC IP
0088 INC IP
008a NEXTO JMP (IP)
; the rest of zero page is used by the kernel
TIME $8d - $8f
...
So when the IRQ handler at $e455 poops on $10, which occurs only when the user presses STOP, it only messes up N+6 or R8L, There is never any guarantee of either of these being safe across Forth word executiion, so not a problem.