]> git.sur5r.net Git - cc65/blob - libsrc/cbm/filedes.s
Add support for computed gotos
[cc65] / libsrc / cbm / filedes.s
1 ;
2 ; Ullrich von Bassewitz, 16.11.2002
3 ;
4 ; File descriptor management for the POSIX I/O routines
5 ;
6
7
8         .include        "cbm.inc"
9         .include        "filedes.inc"
10
11 .code
12
13 ;--------------------------------------------------------------------------
14 ; freefd: Find a free file handle and return it in X. Return carry clear if we
15 ; found one, return a carry if no free lfns are left.
16
17 .proc   freefd
18
19         ldx     #0
20         clc
21 loop:   lda     fdtab,x
22         beq     found
23         inx
24         cpx     #MAX_FDS
25         bcc     loop
26 found:  rts
27
28 .endproc
29
30 ;--------------------------------------------------------------------------
31 ; Data
32
33 .data
34
35 fdtab:  .byte   LFN_READ
36         .byte   LFN_WRITE
37         .byte   LFN_WRITE
38         .res    MAX_FDS-3
39
40 unittab:.byte   CBMDEV_KBD
41         .byte   CBMDEV_SCREEN
42         .byte   CBMDEV_SCREEN
43         .res    MAX_FDS-3