From: cpg Date: Sun, 5 Jan 2003 23:36:16 +0000 (+0000) Subject: added closeallfiles: close all files at program exit X-Git-Tag: V2.12.0~1791 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0c50092c3e9cec7248f09a09ceb19f99c56d86fd;p=cc65 added closeallfiles: close all files at program exit git-svn-id: svn://svn.cc65.org/cc65/trunk@1892 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/atari/open.s b/libsrc/atari/open.s index e45f7813f..7d97a7dff 100644 --- a/libsrc/atari/open.s +++ b/libsrc/atari/open.s @@ -1,5 +1,5 @@ ; -; Christian Groessler, May-2002 +; Christian Groessler, Jan-2003 ; ; int open(const char *name,int flags,...); ; @@ -7,7 +7,12 @@ .include "atari.inc" .include "fcntl.inc" .include "errno.inc" + .include "fd.inc" + .export _open + .destructor closeallfiles, 17 + + .import _close .import clriocb .import fddecusage,newfd .import findfreeiocb @@ -47,7 +52,6 @@ iocbok: stx tmp4 jsr clriocb ; init with zero ldy #1 jsr ldaxysp ; get mode - ;brk ldx tmp4 pha and #O_APPEND @@ -149,3 +153,20 @@ ok: lda tmp2 ; get fd rts .endproc + + +; closeallfiles: Close all files opened by the program. + +.proc closeallfiles + + lda #MAX_FD_INDEX-1 +loop: ldx #0 + pha + jsr _close + pla + clc + sbc #0 + bpl loop + rts + +.endproc