2 ; Ullrich von Bassewitz, 06.06.1998
4 ; int atexit (void (*f) (void));
8 .destructor doatexit, 17
15 ; ---------------------------------------------------------------------------
20 cpy #exitfunc_max ; Slot available?
21 beq @Error ; Jump if no
23 ; Enter the function into the table
38 ; Error, no space left
40 @Error: lda #ENOSPC ; No space left
50 ; ---------------------------------------------------------------------------
56 ldy exitfunc_index ; Get index
57 beq @L9 ; Jump if done
64 jsr callax ; Call the function
65 .if (.cpu .bitand ::CPU_ISET_65SC02)
68 jmp doatexit ; Next one
77 ; ---------------------------------------------------------------------------
80 exitfunc_index: .res 1 ; Index into table, inc'ed by 2
81 exitfunc_table: .res 10 ; 5 exit functions
82 exitfunc_max = <(* - exitfunc_table)