1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-18 11:29:45 +00:00

Use a destructor instead of atexit

git-svn-id: svn://svn.cc65.org/cc65/trunk@515 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-12-01 17:58:40 +00:00
parent b46dab6d44
commit e02b3e91c8
7 changed files with 77 additions and 91 deletions

View File

@ -6,8 +6,8 @@
; ;
.export _set_brk, _reset_brk .export _set_brk, _reset_brk
.destructor _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit
.include "apple2.inc" .include "apple2.inc"
@ -43,10 +43,6 @@ uservec: jmp $FFFF ; Patched at runtime
lda BRKVec+1 lda BRKVec+1
sta oldvec+1 ; Save the old vector sta oldvec+1 ; Save the old vector
lda #<_reset_brk
ldx #>_reset_brk
jsr _atexit ; Install an exit handler
L1: lda #<brk_handler ; Set the break vector to our routine L1: lda #<brk_handler ; Set the break vector to our routine
sta BRKVec sta BRKVec
lda #>brk_handler lda #>brk_handler
@ -59,11 +55,13 @@ L1: lda #<brk_handler ; Set the break vector to our routine
; Reset the break vector ; Reset the break vector
.proc _reset_brk .proc _reset_brk
lda oldvec lda oldvec
sta BRKVec bne @L1
lda oldvec+1 ldx oldvec
sta BRKVec+1 beq @L9 ; Jump if vector not installed
rts @L1: sta BRKVec
stx BRKVec+1
@L9: rts
.endproc .endproc
@ -102,8 +100,8 @@ L1: lda #<brk_handler ; Set the break vector to our routine
ldx _brk_x ldx _brk_x
ldy _brk_y ldy _brk_y
lda _brk_a lda _brk_a
rti ; Jump back... rti ; Jump back...
.endproc .endproc

View File

@ -6,8 +6,8 @@
; ;
.export _set_brk, _reset_brk .export _set_brk, _reset_brk
.destructor _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit
.include "atari.inc" .include "atari.inc"
@ -43,10 +43,6 @@ uservec: jmp $FFFF ; Patched at runtime
lda VBREAK+1 lda VBREAK+1
sta oldvec+1 ; Save the old vector sta oldvec+1 ; Save the old vector
lda #<_reset_brk
ldx #>_reset_brk
jsr _atexit ; Install an exit handler
L1: lda #<brk_handler ; Set the break vector to our routine L1: lda #<brk_handler ; Set the break vector to our routine
sta VBREAK sta VBREAK
lda #>brk_handler lda #>brk_handler
@ -59,11 +55,13 @@ L1: lda #<brk_handler ; Set the break vector to our routine
; Reset the break vector ; Reset the break vector
.proc _reset_brk .proc _reset_brk
lda oldvec lda oldvec
sta VBREAK bne @L1
lda oldvec+1 ldx oldvec
sta VBREAK+1 beq @L9 ; Jump if vector not installed
rts @L1: sta VBREAK
stx VBREAK+1
@L9: rts
.endproc .endproc

View File

@ -6,8 +6,8 @@
; ;
.export _set_brk, _reset_brk .export _set_brk, _reset_brk
.destructor _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit
.importzp ptr1 .importzp ptr1
.include "c128.inc" .include "c128.inc"
@ -54,10 +54,6 @@ L1: lda brk_stub,y
dey dey
bpl L1 bpl L1
lda #<_reset_brk
ldx #>_reset_brk
jsr _atexit ; Install an exit handler
L2: lda #<stub_addr ; Set the break vector to our stub L2: lda #<stub_addr ; Set the break vector to our stub
sta BRKVec sta BRKVec
lda #>stub_addr lda #>stub_addr
@ -70,11 +66,13 @@ L2: lda #<stub_addr ; Set the break vector to our stub
; Reset the break vector ; Reset the break vector
.proc _reset_brk .proc _reset_brk
lda oldvec lda oldvec
sta BRKVec bne @L1
lda oldvec+1 ldx oldvec
sta BRKVec+1 beq @L9 ; Jump if vector not installed
rts @L1: sta BRKVec
stx BRKVec+1
@L9: rts
.endproc .endproc

View File

@ -6,24 +6,24 @@
; ;
.export _set_brk, _reset_brk .export _set_brk, _reset_brk
.destructor _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit
.include "c64.inc" .include "c64.inc"
.bss .bss
_brk_a: .res 1 _brk_a: .res 1
_brk_x: .res 1 _brk_x: .res 1
_brk_y: .res 1 _brk_y: .res 1
_brk_sr: .res 1 _brk_sr: .res 1
_brk_pc: .res 2 _brk_pc: .res 2
oldvec: .res 2 ; Old vector oldvec: .res 2 ; Old vector
.data .data
uservec: jmp $FFFF ; Patched at runtime uservec: jmp $FFFF ; Patched at runtime
.code .code
@ -31,26 +31,22 @@ uservec: jmp $FFFF ; Patched at runtime
; Set the break vector ; Set the break vector
.proc _set_brk .proc _set_brk
sta uservec+1 sta uservec+1
stx uservec+2 ; Set the user vector stx uservec+2 ; Set the user vector
lda oldvec lda oldvec
ora oldvec+1 ; Did we save the vector already? ora oldvec+1 ; Did we save the vector already?
bne L1 ; Jump if we installed the handler already bne L1 ; Jump if we installed the handler already
lda BRKVec lda BRKVec
sta oldvec sta oldvec
lda BRKVec+1 lda BRKVec+1
sta oldvec+1 ; Save the old vector sta oldvec+1 ; Save the old vector
lda #<_reset_brk L1: lda #<brk_handler ; Set the break vector to our routine
ldx #>_reset_brk sta BRKVec
jsr _atexit ; Install an exit handler lda #>brk_handler
sta BRKVec+1
L1: lda #<brk_handler ; Set the break vector to our routine
sta BRKVec
lda #>brk_handler
sta BRKVec+1
rts rts
.endproc .endproc
@ -59,11 +55,13 @@ L1: lda #<brk_handler ; Set the break vector to our routine
; Reset the break vector ; Reset the break vector
.proc _reset_brk .proc _reset_brk
lda oldvec lda oldvec
sta BRKVec bne @L1
lda oldvec+1 ldx oldvec
sta BRKVec+1 beq @L9 ; Jump if vector not installed
rts @L1: sta BRKVec
stx BRKVec+1
@L9: rts
.endproc .endproc

View File

@ -8,7 +8,7 @@
.export _set_brk, _reset_brk .export _set_brk, _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit .import _atexit
.include "zeropage.inc" .include "zeropage.inc"
.include "page3.inc" .include "page3.inc"
@ -45,10 +45,6 @@ uservec: jmp $FFFF ; Patched at runtime
lda BRKVec+1 lda BRKVec+1
sta oldvec+1 ; Save the old vector sta oldvec+1 ; Save the old vector
lda #<_reset_brk
ldx #>_reset_brk
jsr _atexit ; Install an exit handler
L1: lda #<brk_handler ; Set the break vector to our routine L1: lda #<brk_handler ; Set the break vector to our routine
sta BRKVec sta BRKVec
lda #>brk_handler lda #>brk_handler
@ -61,11 +57,13 @@ L1: lda #<brk_handler ; Set the break vector to our routine
; Reset the break vector ; Reset the break vector
.proc _reset_brk .proc _reset_brk
lda oldvec lda oldvec
sta BRKVec bne @L1
lda oldvec+1 ldx oldvec
sta BRKVec+1 beq @L9 ; Jump if vector not installed
rts @L1: sta BRKVec
stx BRKVec+1
@L9: rts
.endproc .endproc

View File

@ -6,8 +6,8 @@
; ;
.export _set_brk, _reset_brk .export _set_brk, _reset_brk
.destructor _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit
.include "pet.inc" .include "pet.inc"
@ -43,10 +43,6 @@ uservec: jmp $FFFF ; Patched at runtime
lda BRKVec+1 lda BRKVec+1
sta oldvec+1 ; Save the old vector sta oldvec+1 ; Save the old vector
lda #<_reset_brk
ldx #>_reset_brk
jsr _atexit ; Install an exit handler
L1: lda #<brk_handler ; Set the break vector to our routine L1: lda #<brk_handler ; Set the break vector to our routine
sta BRKVec sta BRKVec
lda #>brk_handler lda #>brk_handler
@ -59,11 +55,13 @@ L1: lda #<brk_handler ; Set the break vector to our routine
; Reset the break vector ; Reset the break vector
.proc _reset_brk .proc _reset_brk
lda oldvec lda oldvec
sta BRKVec bne @L1
lda oldvec+1 ldx oldvec
sta BRKVec+1 beq @L9 ; Jump if vector not installed
rts @L1: sta BRKVec
stx BRKVec+1
@L9: rts
.endproc .endproc
@ -106,4 +104,4 @@ L1: lda #<brk_handler ; Set the break vector to our routine
.endproc .endproc

View File

@ -6,8 +6,8 @@
; ;
.export _set_brk, _reset_brk .export _set_brk, _reset_brk
.destructor _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc .export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit
.include "plus4.inc" .include "plus4.inc"
@ -43,10 +43,6 @@ uservec: jmp $FFFF ; Patched at runtime
lda BRKVec+1 lda BRKVec+1
sta oldvec+1 ; Save the old vector sta oldvec+1 ; Save the old vector
lda #<_reset_brk
ldx #>_reset_brk
jsr _atexit ; Install an exit handler
L1: lda #<brk_handler ; Set the break vector to our routine L1: lda #<brk_handler ; Set the break vector to our routine
sta BRKVec sta BRKVec
lda #>brk_handler lda #>brk_handler
@ -59,11 +55,13 @@ L1: lda #<brk_handler ; Set the break vector to our routine
; Reset the break vector ; Reset the break vector
.proc _reset_brk .proc _reset_brk
lda oldvec lda oldvec
sta BRKVec bne @L1
lda oldvec+1 ldx oldvec
sta BRKVec+1 beq @L9 ; Jump if vector not installed
rts @L1: sta BRKVec
stx BRKVec+1
@L9: rts
.endproc .endproc