.export _read
.constructor initstdin
- .import SETLFS, OPEN, CHKIN, BASIN, CLRCH, BSOUT, READST
.import rwcommon
.import popax
.importzp ptr1, ptr2, ptr3, tmp1, tmp2, tmp3
;--------------------------------------------------------------------------
; initstdin: Open the stdin file descriptors for the keyboard
-.segment "INIT"
+.segment "ONCE"
.proc initstdin
- lda #LFN_READ
- sta fdtab+STDIN_FILENO
lda #STDIN_FILENO + LFN_OFFS
ldx #CBMDEV_KBD
- stx unittab+STDIN_FILENO
ldy #$FF
jsr SETLFS
jmp OPEN ; Will always succeed
ldy #0
lda tmp1
- sta (ptr2),y
- inc ptr2
+ sta (ptr1),y
+ inc ptr1
bne @L1
- inc ptr2+1 ; *buf++ = A;
+ inc ptr1+1 ; *buf++ = A;
; Increment the byte count
; Decrement the count
-@L3: inc ptr1
+@L3: inc ptr2
bne @L0
- inc ptr1+1
+ inc ptr2+1
bne @L0
beq done ; Branch always
.bss
unit: .res 1
-
-