1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00
cc65/libsrc/common/_fdesc.s

40 lines
466 B
ArmAsm
Raw Normal View History

;
; 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