1
0
mirror of https://github.com/cc65/cc65.git synced 2024-10-30 12:28:25 +00:00
cc65/libsrc/common/_fdesc.s
uz 53dd513176 This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3 b7a2c559-68d2-44c3-8de9-860c34a00d81
2000-05-28 13:40:48 +00:00

40 lines
466 B
ArmAsm

;
; Ullrich von Bassewitz, 17.06.1998
;
; int _fdesc (void);
; /* Find a free descriptor slot */
.export __fdesc
.import return0, __filetab
.importzp tmp1
__fdesc:
ldy #0
L1: lda __filetab+1,y ; load flags
beq L2 ; jump if empty (== CLOSED)
iny
iny
cpy #16 ; Done?
bne L1
; File table is full
jmp return0
; Free slot found
L2: sty tmp1 ; Offset
lda #<__filetab
ldx #>__filetab
clc
adc tmp1
tay
txa
adc #0
tax
tya
rts