2002-11-16 23:45:15 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 16.11.2002
|
|
|
|
;
|
|
|
|
; File descriptor management for the POSIX I/O routines
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2015-10-14 20:52:09 +00:00
|
|
|
.include "cbm.inc"
|
2002-11-16 23:45:15 +00:00
|
|
|
.include "filedes.inc"
|
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
;--------------------------------------------------------------------------
|
|
|
|
; freefd: Find a free file handle and return it in X. Return carry clear if we
|
|
|
|
; found one, return a carry if no free lfns are left.
|
|
|
|
|
|
|
|
.proc freefd
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
clc
|
|
|
|
loop: lda fdtab,x
|
|
|
|
beq found
|
|
|
|
inx
|
|
|
|
cpx #MAX_FDS
|
|
|
|
bcc loop
|
|
|
|
found: rts
|
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
;--------------------------------------------------------------------------
|
|
|
|
; Data
|
|
|
|
|
2015-10-14 20:52:09 +00:00
|
|
|
.data
|
2002-11-16 23:45:15 +00:00
|
|
|
|
2015-10-14 20:52:09 +00:00
|
|
|
fdtab: .byte LFN_READ
|
|
|
|
.byte LFN_WRITE
|
|
|
|
.byte LFN_WRITE
|
|
|
|
.res MAX_FDS-3
|
2002-11-16 23:45:15 +00:00
|
|
|
|
2015-10-14 20:52:09 +00:00
|
|
|
unittab:.byte CBMDEV_KBD
|
|
|
|
.byte CBMDEV_SCREEN
|
|
|
|
.byte CBMDEV_SCREEN
|
|
|
|
.res MAX_FDS-3
|