2 ; 2013-12-24, Greg King
4 ; int read (int fd, void* buf, unsigned count);
6 ; This function is a hack! It lets us get text from the stdin console.
12 .importzp ptr1, ptr2, ptr3
20 stx ptr3+1 ; save count as result
25 sta ptr2+1 ; Remember -count-1
30 jsr popax ; get fd and discard
35 bze L9 ; no more room in buf
37 ; If there are no more characters in BASIC's input buffer, then get a line from
38 ; the console into that buffer.
47 bnz L4 ; (zero-terminated buffer)
49 lda #$0A ; return newline char. at end of line
56 bnz L1 ; branch always
58 ; No error, return count.