mirror of
https://github.com/cc65/cc65.git
synced 2025-01-14 00:32:08 +00:00
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
This commit is contained in:
parent
5f36ad2d53
commit
8d6f5a2fca
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user