.title terminalio Perform Terminal IO .ident /V1.0/ ; ; Author: Rodrick A. Eldridge ; 104 Computer Science ; Iowa State University ; Ames, Iowa 50011 ; (515) 294-5659 ; ; Created: April 1986 ; ; Description: This module contains a set of routines for performing ; single character and line-oriented terminal I/O. ; ; Format: external module terminal_io ; ; external module read_ln ; external module read - ; ; external module read_string - ; ; external module read_again ; ; external module write_ln ; external module write - ; ; external module write_string - ; ; global module terminal_io - psect=terminal_io const $dscdef ; descriptor definitions $rabdef ; record access block definitons max_length = 512 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_ln - psect=terminal_io begin ; read a string from the input device and position input pointer if eql then terminal_io 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 read - psect=terminal_io begin ; read single character from the input device if eql then terminal_io end if gtr then read_ln end movzwl input_position,r1 movb input_buffer[r1],@read.char(ap) incw input_position return end global module read_string - psect=terminal_io - mask= begin ; read a string from the input device if eql then terminal_io end $get rab=input_rab ; read string moval input_rab,r1 movw rab$w_rsz(r1),input_descr ; actual length read pushr #^M movq @read_string.descr(ap),r6 ; r6=string length,r7=address movc5 #max_length,input_buffer,#^a/ /,r6,(r7) popr #^M return end global module read_again - psect=terminal_io begin ; Reset position input pointer if eql then terminal_io read_ln end clrw input_position return end global module write_ln - 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 terminal_io 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 global module write - psect=terminal_io begin ; write a character to the output device if eql then terminal_io end movzwl output_position,r1 movb @write.char(ap),output_buffer[r1] incw output_position return end global module write_string - psect=terminal_io - mask= begin ; write a string to the output device if eql then terminal_io end movq @write_string.descr(ap),r6 ; r6=string length, r7=buffer movc5 r6,(r7),#^a/ /,#max_length,output_buffer movw r6,output_position write_ln return end .end