2 ; Ullrich von Bassewitz, 27.09.1998
4 ; void set_brk (unsigned Addr);
5 ; void reset_brk (void);
8 .export _set_brk, _reset_brk
10 .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
22 oldvec: .res 2 ; Old vector
26 uservec: jmp $FFFF ; Patched at runtime
31 ; Set the break vector
35 stx uservec+2 ; Set the user vector
38 ora oldvec+1 ; Did we save the vector already?
39 bne L1 ; Jump if we installed the handler already
44 sta oldvec+1 ; Save the old vector
46 L1: lda #<brk_handler ; Set the break vector to our routine
55 ; Reset the break vector
61 beq @L9 ; Jump if vector not installed
70 ; Break handler, called if a break occurs
76 sbc #$02 ; Point to start of brk
84 adc #$04 ; Adjust stack pointer
87 lda _brk_sr ; Clear brk
91 jsr uservec ; Call the user's routine