mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +00:00
6e37905b18
Added an assembler include _file.inc and changed asm code that uses struct FILE to be independent of its size. Fixed return codes in several files to use EOF instead of -1. git-svn-id: svn://svn.cc65.org/cc65/trunk@1205 b7a2c559-68d2-44c3-8de9-860c34a00d81
43 lines
796 B
ArmAsm
43 lines
796 B
ArmAsm
;
|
|
; Ullrich von Bassewitz, 17.06.1998
|
|
;
|
|
; int _fdesc (void);
|
|
; /* Find a free descriptor slot */
|
|
|
|
|
|
.export __fdesc
|
|
.import return0
|
|
|
|
.include "_file.inc"
|
|
|
|
.proc __fdesc
|
|
|
|
ldy #0
|
|
lda #_FOPEN
|
|
Loop: and __filetab + _FILE_f_flags,y ; load flags
|
|
beq Found ; jump if closed
|
|
.repeat ::_FILE_size
|
|
iny
|
|
.endrepeat
|
|
cpy #(FOPEN_MAX * _FILE_size) ; Done?
|
|
bne Loop
|
|
|
|
; File table is full
|
|
|
|
jmp return0
|
|
|
|
; Free slot found, get address
|
|
|
|
Found: tya ; Offset
|
|
clc
|
|
adc #<__filetab
|
|
ldx #>__filetab ; High byte
|
|
bcc @L1 ; Jump if no overflow
|
|
inx ; Bump high byte
|
|
@L1: rts
|
|
|
|
.endproc
|
|
|
|
|
|
|