X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fcommon%2Fatexit.s;h=6edfd4a5dc220806c9a69191de704d68dceab611;hb=934a78731fe1b7fc8d08814fa2321534c20fbc62;hp=b66cce8e8d312d262d88886021b9bbb621ba96c8;hpb=8f7b91eea643dd6d0f1e280d976e4c7e04bad606;p=cc65 diff --git a/libsrc/common/atexit.s b/libsrc/common/atexit.s index b66cce8e8..6edfd4a5d 100644 --- a/libsrc/common/atexit.s +++ b/libsrc/common/atexit.s @@ -4,44 +4,44 @@ ; int atexit (void (*f) (void)); ; - .export _atexit - .destructor doatexit, 5 - .import callax + .export _atexit + .destructor doatexit, 17 + .import callax - .include "errno.inc" + .include "errno.inc" .macpack cpu ; --------------------------------------------------------------------------- -.proc _atexit +.proc _atexit - ldy exitfunc_index - cpy #exitfunc_max ; Slot available? - beq @Error ; Jump if no + ldy exitfunc_index + cpy #exitfunc_max ; Slot available? + beq @Error ; Jump if no ; Enter the function into the table - sta exitfunc_table,y - iny - txa - sta exitfunc_table,y - iny - sty exitfunc_index + sta exitfunc_table,y + iny + txa + sta exitfunc_table,y + iny + sty exitfunc_index ; Done, return zero - lda #0 - tax - rts + lda #0 + tax + rts ; Error, no space left -@Error: lda #ENOSPC ; No space left +@Error: lda #ENOSPC ; No space left jsr __seterrno - ldx #$FF ; Return -1 - txa - rts + ldx #$FF ; Return -1 + txa + rts .endproc @@ -51,24 +51,24 @@ .code -.proc doatexit - - ldy exitfunc_index ; Get index - beq @L9 ; Jump if done - dey - lda exitfunc_table,y - tax - dey - lda exitfunc_table,y - sty exitfunc_index - jsr callax ; Call the function +.proc doatexit + + ldy exitfunc_index ; Get index + beq @L9 ; Jump if done + dey + lda exitfunc_table,y + tax + dey + lda exitfunc_table,y + sty exitfunc_index + jsr callax ; Call the function .if (.cpu .bitand ::CPU_ISET_65SC02) - bra doatexit + bra doatexit .else - jmp doatexit ; Next one + jmp doatexit ; Next one .endif -@L9: rts +@L9: rts .endproc @@ -77,8 +77,8 @@ ; --------------------------------------------------------------------------- .bss -exitfunc_index: .res 1 ; Index into table, inc'ed by 2 -exitfunc_table: .res 10 ; 5 exit functions -exitfunc_max = <(* - exitfunc_table) +exitfunc_index: .res 1 ; Index into table, inc'ed by 2 +exitfunc_table: .res 10 ; 5 exit functions +exitfunc_max = <(* - exitfunc_table)