mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +00:00
e02b3e91c8
git-svn-id: svn://svn.cc65.org/cc65/trunk@515 b7a2c559-68d2-44c3-8de9-860c34a00d81
116 lines
1.6 KiB
ArmAsm
116 lines
1.6 KiB
ArmAsm
;
|
|
; Ullrich von Bassewitz, 27.09.1998
|
|
;
|
|
; void set_brk (unsigned Addr);
|
|
; void reset_brk (void);
|
|
;
|
|
|
|
.export _set_brk, _reset_brk
|
|
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
|
|
.import _atexit
|
|
|
|
.include "zeropage.inc"
|
|
.include "page3.inc"
|
|
|
|
|
|
.bss
|
|
_brk_a: .res 1
|
|
_brk_x: .res 1
|
|
_brk_y: .res 1
|
|
_brk_sr: .res 1
|
|
_brk_pc: .res 2
|
|
_brk_01: .res 1
|
|
|
|
oldvec: .res 2 ; Old vector
|
|
|
|
|
|
.data
|
|
uservec: jmp $FFFF ; Patched at runtime
|
|
|
|
|
|
.code
|
|
|
|
; Set the break vector
|
|
.proc _set_brk
|
|
|
|
sta uservec+1
|
|
stx uservec+2 ; Set the user vector
|
|
|
|
lda oldvec
|
|
ora oldvec+1 ; Did we save the vector already?
|
|
bne L1 ; Jump if we installed the handler already
|
|
|
|
lda BRKVec
|
|
sta oldvec
|
|
lda BRKVec+1
|
|
sta oldvec+1 ; Save the old vector
|
|
|
|
L1: lda #<brk_handler ; Set the break vector to our routine
|
|
sta BRKVec
|
|
lda #>brk_handler
|
|
sta BRKVec+1
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
; Reset the break vector
|
|
.proc _reset_brk
|
|
|
|
lda oldvec
|
|
bne @L1
|
|
ldx oldvec
|
|
beq @L9 ; Jump if vector not installed
|
|
@L1: sta BRKVec
|
|
stx BRKVec+1
|
|
@L9: rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
; Break handler, called if a break occurs
|
|
|
|
.proc brk_handler
|
|
|
|
pla
|
|
sta _brk_y
|
|
pla
|
|
sta _brk_x
|
|
pla
|
|
sta _brk_a
|
|
pla
|
|
and #$EF ; Clear break bit
|
|
sta _brk_sr
|
|
pla ; PC low
|
|
sec
|
|
sbc #2 ; Point to start of brk
|
|
sta _brk_pc
|
|
pla ; PC high
|
|
sbc #0
|
|
sta _brk_pc+1
|
|
lda IndReg
|
|
sta _brk_01
|
|
lda ExecReg
|
|
sta IndReg
|
|
|
|
jsr uservec ; Call the user's routine
|
|
|
|
lda _brk_01
|
|
sta IndReg
|
|
|
|
lda _brk_pc+1
|
|
pha
|
|
lda _brk_pc
|
|
pha
|
|
lda _brk_sr
|
|
pha
|
|
ldx _brk_x
|
|
ldy _brk_y
|
|
lda _brk_a
|
|
rti ; Jump back...
|
|
|
|
.endproc
|
|
|
|
|