; > TubeIO.mac ; General I/O routines and interface to PDPTube ; General routines ; ================ ; Print text at R1 ; ---------------- ; On entry, R1=>zero-terminated string ; .PrintR1 ; Print text pointed to by R1, term. by &00 movb (r1)+,r0 ; get byte from r1, inc r1 beq PrintR1End ; exit if final byte jsr pc,IO_ASCI br PrintR1 ; loop back .PrintR1End rts pc ; and exit ; Read line of text ; ----------------- ; On entry, R1=>memory to read string to ; On exit, CC=ok, CS=Escape pressed ; R1 preserved ; R2=length of string ; R0, R3 corrupted ; .IO_READLINE mov r1,-(sp) ; Save pointer to buffer mov #0,r2 ; Zero number of characters read .IO_RDLNloop jsr pc,IO_RDCH ; Get a character bcs IO_RDLNesc ; Escape state ;cmp r0,#27;beq IO_RDLNesc ; Escape character (remove later) cmp r0,#13 beq IO_RDLNcr ; - End of line cmp r0,#10 beq IO_RDLNcr ; - End of line cmp r0,#21 beq IO_RDLNu ; Ctrl-U - delete line cmp r0,#127 beq IO_RDLNdel ; - del a character cmp r0,#8 beq IO_RDLNdel ; - del a character cmp r0,#ASC" " bcs IO_RDLNloop ; Ignore other control characters cmp r2,#240 bcc IO_RDLNloop ; No more room for characters movb r0,(r1)+ ; Put character into memory add #1,r2 ; Inc. number of characters jsr pc,IO_WRCH ; Output the character br IO_RDLNloop ; Go back for another ; .IO_RDLNu mov r2,r3 ; We want to delete all characters br IO_RDLNdelete .IO_RDLNdel mov #1,r3 ; We only want to delete one char .IO_RDLNdelete cmp r2,#0 beq IO_RDLNloop mov #127,r0 jsr pc,IO_WRCH ; Output character sub #1,r1 ; Back address pointer sub #1,r2 ; Dec character counter sub #1,r3 ; Dec number to delete bne IO_RDLNdelete ; Delete more br IO_RDLNloop ; Go back into ReadLine loop ; .IO_RDLNesc jsr pc,IO_NEWL ; Print newline mov #0,r2 ; Length = 0 sec ; Set carry - escape bcs IO_RDLNend ; .IO_RDLNcr movb r0,(r1)+ ; Put terminator in jsr pc,IO_NEWL ; Returns with r0= clc ; Clear carry - ok .IO_RDLNend mov (sp)+,r1 ; Get buffer address back rts pc ; r0=, r1=buffer, r2=length ; Interface to PDPTube ; ------------------ .IO_QUIT emt 0 rts pc ; Won't actually get back! ; .IO_CLI emt 1 ; r1=>command string rts pc ; .IO_BYTE emt 2 ; Osbyte r0,r1,r2 rts pc ; .IO_WORD emt 3 ; Osword r0,r1=>block rts pc ; .IO_ASCI ; Print ASCII character CMP R0,#13 BNE IO_WRCH .IO_NEWL ; Print NEWL MOV #10,R0 JSR PC,IO_WRCH .IO_WRCR ; Print CR MOV #13,R0 .IO_WRCH emt 4 ; Oswrch r0=char rts pc ; .IO_RDCH emt 5 ; Osrdch r0=char rts pc ; .IO_FILE emt 6 ; Osfile r0=action, r1=>block rts pc ; .IO_ARGS emt 7 ; Osargs r0=action, r1=>block, r2=handle rts pc ; .IO_BGET emt 8 ; Osbget r1=handle rts pc ; .IO_BPUT emt 9 ; Osbput r0=byte, r1=handle rts pc ; .IO_GBPB emt 10 ; Osgbpb r0=action, r1=>block rts pc ; .IO_FIND emt 11 ; Osfind r0=action, r1=>filename or handle rts pc ; .IO_MISC emt 12 rts pc ; .IO_SYS emt 13 rts pc .IO_READ emt 14 rts pc .IO_WRITE emt 15 rts pc