2 ; Ullrich von Bassewitz, 30.05.1998
4 ; int read (int fd, void* buf, int count);
10 .import popax, _cputc, RDKEY
11 .importzp ptr1, ptr2, ptr3
13 _read: jsr popax ; get count
15 stx ptr2+1 ; save it for later
19 jsr popax ; get fd and discard it
22 sta ptr3+1 ; set count
25 ora ptr2+1 ; count zero?
28 and #$7F ; clear high bit.
32 ldy #$00 ; offset into string
33 sta (ptr1),y ; save char
37 L2: inc ptr3 ; increment count
43 ; Done, return the count