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
10 .import _atexit, BRKVec
23 oldvec: .res 2 ; Old vector
27 uservec: jmp $FFFF ; Patched at runtime
32 ; Set the break vector
36 stx uservec+2 ; Set the user vector
39 ora oldvec+1 ; Did we save the vector already?
40 bne L1 ; Jump if we installed the handler already
45 sta oldvec+1 ; Save the old vector
47 L1: lda #<brk_handler ; Set the break vector to our routine
56 ; Reset the break vector
61 beq @L9 ; Jump if vector not installed
65 sta oldvec ; Clear the old vector
73 ; Break handler, called if a break occurs
86 and #$EF ; Clear break bit
90 sbc #2 ; Point to start of brk
96 jsr uservec ; Call the user's routine