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
23 oldvec: .res 2 ; Old vector
27 uservec: jmp $FFFF ; Patched at runtime
31 ; Where will we put the break stub?
32 stub_addr = $0E00 ; BASIC sprite area
36 ; Set the break vector
40 stx uservec+2 ; Set the user vector
43 ora oldvec+1 ; Did we save the vector already?
44 bne L2 ; Jump if we installed the handler already
49 sta oldvec+1 ; Save the old vector
51 ldy #stub_size-1 ; Copy our stub into the low mem area
57 L2: lda #<stub_addr ; Set the break vector to our stub
66 ; Reset the break vector
72 beq @L9 ; Jump if vector not installed
81 ; Break handler, called if a break occurs
92 and #$EF ; Clear break bit
96 sbc #2 ; Point to start of brk
102 jsr uservec ; Call the user's routine
120 pla ; Get original MMU value
121 sta MMU_CR ; Re-enable our config
122 jmp brk_handler ; Jump to the user handler
125 stub_size = * - brk_stub