From: cpg Date: Wed, 3 Oct 2001 16:09:14 +0000 (+0000) Subject: clriocb and findfreeiocb moved from open.s to fdtable.s (they are now also X-Git-Tag: V2.12.0~2582 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8d6f5a2fca38aa7378180a26ca43fcfbcefafe45;p=cc65 clriocb and findfreeiocb moved from open.s to fdtable.s (they are now also used by graphics.s) git-svn-id: svn://svn.cc65.org/cc65/trunk@1008 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/atari/fdtable.s b/libsrc/atari/fdtable.s index 700cabed9..5a8063c38 100644 --- a/libsrc/atari/fdtable.s +++ b/libsrc/atari/fdtable.s @@ -9,8 +9,10 @@ .importzp tmp1,tmp2,tmp3,ptr4,sp .import fd_table,fd_index .import fdt_to_fdi + .export clriocb .export fdtoiocb .export fdtoiocb_down + .export findfreeiocb .export fddecusage .export newfd @@ -61,12 +63,30 @@ ok_notlast: lda #1 ; clears Z jmp retiocb -.endproc +.endproc ; fdtoiocb_down inval: ldx #$ff ; sets N rts +; clear iocb except for ICHID field +; expects X to be index to IOCB (0,$10,$20,etc.) +; all registers destroyed + +.proc clriocb + + inx ; don't clear ICHID + ldy #15 + lda #0 +loop: sta ICHID,x + inx + dey + bne loop + rts + +.endproc + + ; gets fd in ax ; return iocb index in X ; return N bit set for invalid fd @@ -90,7 +110,31 @@ inval: ldx #$ff ; sets N lda fd_table+ft_iocb,x ; get iocb rts -.endproc +.endproc ; fdtoiocb + +; find a free iocb +; no entry parameters +; return ZF = 0/1 for not found/found +; index in X if found +; all registers destroyed + +.proc findfreeiocb + + ldx #0 + ldy #$FF +loop: tya + cmp ICHID,x + beq found + txa + clc + adc #$10 + tax + cmp #$80 + bcc loop + inx ; return ZF cleared +found: rts + +.endproc ; findfreeiocb ; decrements usage counter for fd ; if 0 reached, it's marked as unused @@ -123,7 +167,7 @@ inval: ldx #$ff ; sets N sta fd_table+ft_iocb,x ; clear table entry ret: rts -.endproc +.endproc ; fddecusage ; newfd ; @@ -334,5 +378,5 @@ finish: lda ptr4 pla rts -.endproc +.endproc ; newfd diff --git a/libsrc/atari/open.s b/libsrc/atari/open.s index 7904586f2..48568b083 100644 --- a/libsrc/atari/open.s +++ b/libsrc/atari/open.s @@ -10,7 +10,9 @@ UCASE_FILENAME = 1 ; comment it out if filename shouldn't be uppercased .include "../common/fmode.inc" .include "../common/errno.inc" .export _open + .import clriocb .import fddecusage,newfd + .import findfreeiocb .import __do_oserror,__seterrno,incsp4 .import ldaxysp,addysp,subysp .import _strupr,__oserror @@ -165,46 +167,3 @@ ok: lda tmp2 ; get fd rts .endproc - - -; find a free iocb -; no entry parameters -; return ZF = 0/1 for not found/found -; index in X if found -; all registers destroyed - -.proc findfreeiocb - - ldx #0 - ldy #$FF -loop: tya - cmp ICHID,x - beq found - txa - clc - adc #$10 - tax - cmp #$80 - bcc loop - inx ; return ZF cleared -found: rts - -.endproc - - -; clear iocb except for ICHID field -; expects X to be index to IOCB (0,$10,$20,etc.) -; all registers destroyed - -.proc clriocb - - inx ; don't clear ICHID - ldy #15 - lda #0 -loop: sta ICHID,x - inx - dey - bne loop - rts - -.endproc