.title TerminalIO Perform Terminal IO ; ; Author: Rodrick A. Eldridge ; 104 Computer Science ; Iowa State University ; Ames, Iowa 50011 ; (515) 294-5659 ; ; Created: April 1986 ; ; Modification History: ; ; Description: This module contains a set of routines for performing ; single character and line-oriented terminal I/O ; ; The routines that are available are: ; ; routine name parameters ; ------------ ---------- ; ; TerminalIo ; ; Read char ; ReadString string ; ReadLn ; ReadAgain ; ; Write char ; WriteString string ; WriteLn ; external module TerminalIo <> external module Read external module ReadString external module ReadLn <> external module ReadAgain <> external module Write external module WriteString external module WriteLn <> const $dscdef ; descriptor definitions $rabdef ; record access block definitons max_length=512 global module TerminalIo - psect=terminal_io var input_fab: $fab fac=get,fnm= input_rab: $rab fab=input_fab,- ubf=input_buffer,- usz=max_length output_fab: $fab fac=put,fnm= output_rab: $rab fab=output_fab,- rbf=output_buffer,- rsz=max_length input_descr: descr .blkb max_length input_buffer * output_descr: descr .blkb max_length output_buffer * input_position: .word 0 output_position: .word 0 open_flag: .word 0 cr_lf: .byte 13,10 begin ; ; Initialize the terminal i/o routines ; $open fab=input_fab $connect rab=input_rab $open fab=output_fab $connect rab=output_rab movw #max_length+1,input_position clrw output_position movw #1,open_flag return end global module Read - psect=terminal_io begin ; ; Read single character from the input device ; if eql then TerminalIo end if gtr then Readln end movzwl input_position,r1 movb input_buffer[r1],@read.char(ap) incw input_position return end global module ReadString - psect=terminal_io - mask= begin ; ; Read a string from the input device ; if eql then TerminalIo end $get rab=input_rab ; read string moval input_rab,r1 movw rab$w_rsz(r1),input_descr ; actual length read pushr r0 movq @ReadString.descr(ap),r6 ; r6=string length,r7=address movc5 #max_length,input_buffer,#^a/ /,r6,(r7) popr r0 return end global module ReadLn - psect=terminal_io begin ; ; Read a string from the input device and position input pointer ; if eql then TerminalIo end $get rab=input_rab ; read string moval input_rab,r1 movw rab$w_rsz(r1),input_descr ; actual length read clrw input_position return end global module ReadAgain - psect=terminal_io begin ; ; Reset position input pointer ; if eql then TerminalIo Readln end clrw input_position return end global module Write - psect=terminal_io begin ; ; Write a character to the output device ; if eql then TerminalIo end movzwl output_position,r1 movb @Write.char(ap),output_buffer[r1] incw output_position return end global module WriteString - psect=terminal_io - mask= begin ; ; Write a string to the output device ; if eql then TerminalIo end movq @WriteString.descr(ap),r6 ; r6=string length, r7=buffer movc5 r6,(r7),#^a/ /,#max_length,output_buffer movw r6,output_position WriteLn return end global module WriteLn - psect=terminal_io begin ; ; Write a carriage control and line feed to the output device and ; optionally, write a string to the output device ; if eql then TerminalIo end $rab_store rab=output_rab,- rbf=cr_lf,- rsz=#2 $put rab=output_rab if neq then $rab_store rab=output_rab,- rbf=output_buffer,- rsz=r6 $put rab=output_rab ; write string clrw output_position end return end .end