2 ; Ullrich von Bassewitz, 27.09.1998
4 ; void set_brk (unsigned Addr);
5 ; void reset_brk (void);
8 .export _set_brk, _reset_brk
9 .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
12 .include "zeropage.inc"
24 oldvec: .res 2 ; Old vector
28 uservec: jmp $FFFF ; Patched at runtime
33 ; Set the break vector
37 stx uservec+2 ; Set the user vector
40 ora oldvec+1 ; Did we save the vector already?
41 bne L1 ; Jump if we installed the handler already
46 sta oldvec+1 ; Save the old vector
48 L1: lda #<brk_handler ; Set the break vector to our routine
57 ; Reset the break vector
63 beq @L9 ; Jump if vector not installed
72 ; Break handler, called if a break occurs
83 and #$EF ; Clear break bit
87 sbc #2 ; Point to start of brk
97 jsr uservec ; Call the user's routine