2 ; Ullrich von Bassewitz, 2012-06-01
4 ; Helper functions for open-/read-/closedir
9 .include "zeropage.inc"
15 ;---------------------------------------------------------------------------
17 ; unsigned char __fastcall__ _dirread1 (DIR* dir, void* buf);
18 ; /* Read one byte from the directory into the supplied buffer. Makes sure,
19 ; ** errno is set in case of a short read. Return true if the read was
20 ; ** successful and false otherwise.
26 lda #1 ; Load count = 1
28 ; Run directly into __dirread
30 ;---------------------------------------------------------------------------
32 ; unsigned char __fastcall__ _dirread (DIR* dir, void* buf, unsigned char count);
33 ; /* Read characters from the directory into the supplied buffer. Makes sure,
34 ; ** errno is set in case of a short read. Return true if the read was
35 ; ** successful and false otherwise.
44 ; Replace dir by dir->fd
63 ; Get count, save it again, clear the high byte and call read(). By the
64 ; previous actions, the stack frame is as read() needs it, and read() will
77 ; read() returned an error, so errno is already set
84 ; read() was successful, check number of bytes read. We assume that read will
85 ; not return more than count, so X is zero if we come here.
87 L3: sta tmp1 ; Save returned count
90 beq L2 ; Ok, return count
92 ; Didn't read enough bytes. This is an error for us, but errno is not set
96 stx __errno+1 ; X is zero
97 bne L1 ; Branch always