.MCALL .MODULE .MODULE TERMID,VERSION=08,COMMENT=,AUDIT=YES ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ;+ ; This program determines the nature of your console terminal. ; ; The list of the older terminals identified is hard-coded in TABL1. ; The list of the newer terminals identified is hard-coded in TABL2. ; ; All newer terminals i.e. VT100, VT200, VT300, LA34 and LA120 respond ; to the ANSI query message [0c by replying with an unique chara- ; cter string. The other, older terminals respond only to Z. ; An ANSI query has the unfortunate effect of hanging a VT52 because ; [ corresponds to the SET NOSCROLL command for a VT52. ; To forestall this risk the program sends an Z first to ; determine if the terminal is one of the older types. If there is ; no response to the Z the ANSI query is transmitted. ; ; It is conceivable that a VT52 fails to reply to an Z ; because of line or modem noise distorting the query. In this ; case the ANSI query will freeze the terminal. Therefore a ; SET UNSCROLL command in the form of \ is transmitted ; for safety before the program exits. In the event that the ; VT52 cursor was on the last line, the SET UNSCROLL command ; also wouldn't work. That is why, prior to sending the ANSI ; query [c, a "cursor up" (command A) for a VT52 is ; transmitted so that the final SET UNSCROLL command is ; effective. ; ; The user error byte is set to warning if the terminal is not of type ; VT100 because the program was specifically written to test ; for a VT100. However the setting of the user error byte can ; be modified in the relevant procedure if the information ; about the terminal ID is being passed on to a program that is ; being chained to. ; ; A message that displays the terminal type is printed whenever a ; /R (report) command is issued on the R, RUN, or CCL invocation. ; You will not be prompted for a command if it is omitted. ; Currently, any valid command string is accepted as though it were ; "/R". Examples: ; ; RUN TERMID ; will not print terminal type ; ; R TERMID /R ; will print terminal type ;- .SBTTL PSECT DEFINITIONS .PSECT CODE .PSECT DATA .PSECT TXTP .SBTTL MACROS AND DEFINITIONS .ENABL LC .MCALL .EXIT .GTLIN .PRINT .RCTRLO .TTINR .MCALL SOB .CKXX .ASSUME .BR ; ; macro definitions ; NO =: 0 YES =: 1 .MACRO TERM ID,TEXT,VT100=NO,?L1 .WORD L1 .SAVE .PSECT TXTP L1: .ASCIZ "TEXT" .RESTORE .BYTE VT100 .BYTE ID .ENDM TERM ; ; Bit and word definitions ; CHAIN =: 510 ;start of chain area USERRB =: 53 ;user error byte WARN$ =: 2 ;bit 2 warning JSW =: 44 ;job status word LCBIT$ =: 40000 ;lower case bit - 14 TTSPC$ =: 10000 ;terminal special mode bit - 12 TCBIT$ =: 100 ;inhibit wait on reads for FB - bit 6 MASK =: LCBIT$+TTSPC$+TCBIT$ ; ; symbols definition ; ESC =: 033 ;ESCAPE-first character in response OLDID =: '/ ;intermediate for old terminals CHAR.0 =: '0 ;The character "0" CHAR.9 =: '9 ;The character "9" CSI =: '[ ;ANSI Control Seguence Introducer DECPVT =: '? ;DEC Private Introducer DA =: 'c ;ANSI terminator SEP =: '; ;ANSI parameter separator NUM15 =: 15. ;VT102J/LA12 first parameter NUM2 =: 2. ;LA12 enhancement second parameter MAX =: 1000. ;arbitrary number to repeat read ; ; The table entry layouts definition ; T.MESG =: -4 T.TYPE =: -2 T.CHR =: -1 .SBTTL Start of Main Code .PSECT CODE START: BIS #MASK,@#JSW ;adjust JSW to enable lower case, ; terminal special mode and ; inhabit wait on reads .RCTRLO ;update intrn status to agree with JSW CLR REPFLG ;assume no "report" desired MOV #CHAIN,R4 ;R4 -> chain area CMP #1,(R4)+ ;is there a command? BGE 10$ ;branch if not .GTLIN #REPLY ;eat line to discard it MOV SP,REPFLG ;set "report" flag 10$: MOV #1,SMCLN ;indicate that no semicolons seen yet CLR PRMT ;Clear parameter accumulator MOV #REPLY,R1 ;pointer to store terminal reply MOV R1,R4 ;R4 -> reply buffer MOV #REPSIZ,R3 ;R3 = byte size of reply buffer 20$: CLRB (R4)+ ;clear out buffer SOB R3,20$ ; a byte at a time .PRINT #QUERY1 ;send query to the terminal CALL READ ;wait and read a response BCC CONT ;continue if received a response .PRINT #QUERY2 ;no, send new message CALL READ ;wait and read a response BCS ERR1 CONT: CMPB #ESC,R0 ;was it an ESC? BNE ERR1 MOVB R0,(R1)+ ;store response in input buffer CALL READ ;wait and read a response BCS ERR1 MOVB R0,(R1)+ ;store response in input buffer .SBTTL Old Type Terminal Processing ; The general format for OLD 3-CHARACTER ESCAPE SEQUENCE is: ; ; < / > + , ; ; with exception for special case of VT71 with additioanal information ; set through jumpers or thumbwheels. For this case format will be: ; ; < / > n n n ~ , where n is 0 to 7. ; ; Once TERMID has recognized your terminal as an older type, it deter- ; mines the specific model based on the third character which is distin- ; quishing in this case. CMPB #OLDID,R0 ; is it an old type of terminal? BNE CHNEW ; no, check if it is a new ; ; The terminal is identified as an old type. ; CALL READ ; wait and read a response BCS ERR1 ; MOV #TABL1,R2 ; R2 points to TABLE1 CALL CHKCHR ; search for specific type of TT BCC FOUND ; ; if not found, check if it is special case of VT71 ; response format for special case of VT71 is < ESC / n n n ~ > ; CHVT71: TSTB REPLY+4 ; got five characters? BNE SRVT71 ; yes, search TABL1 ; only number is valid CALL CHNUM ;check for number BCS ERR1 ; no, then error CALL READ ; get next character BCS ERR1 MOVB R0,(R1)+ ; store response in input buffer BR CHVT71 SRVT71: MOV #TABL1,R2 ; R2 points to TABLE1 CALL CHKCHR ; search for VT71 special BCC FOUND ; ERR1: JMP ERR .SBTTL New Type Terminal Processing ; ; For newer devices, the primary Device Attribute control is used to ; request or report the identification code associated with the fami- ; ly of devices in which the interface is implemented. ; The response for the primary DA request consists of a DA control ; sequence using a private parameter string with the introducer ; followed by a variable number of parameters. ; ; The general format for response of newer devices: ; ; < [ > < ? > < Ps1 > < ; > < Ps2 > < c > , where ; ; [ DA control sequence ; Introducer ; PS1, PS2 Parameters (only numbers are legal) ; <;> Delimiter ; Terminator ; ; Once TERMID determines your terminal is a newer device, it starts to ; collect the rest of parameters. The characters until the first ";" ; are transformed and accumulated into the decimal number. This number ; is used in the table search to find the match with hard coded standard ; responses. ; Exception: VT102J and LA12 both have DA primary ID 15. To distin- ; quish between these two, the second optional parameter after trailing ; semicolon has to be tested. Only LA12 has second parameter; "0" for ; standard LA12 or "2" for LA12 enhancement. ; ; Any terminal that replied with "61" for the first parameter is ; considered as VT1XX CLASS. ; Any terminal that replied with "62" is considered as VT2XX CLASS. ; Any terminal that replied with "63" is considered as VT3XX CLASS. ; .ENABL LSB CHNEW: CMPB #CSI,R0 ; is it a new type of terminal BEQ CHNEW1 ; yes, go check introducer MOVB #CSI,-1(R1) ; assume that we were sent ; an 8-bit CSI (233) but that ; we received an ESC (33) ; because RT-11 terminal service ; zeroed bit 7 BR CHNEW2 ; R0 already contains next char CHNEW1: CALL READ ; wait and read a response BCS ERR ; only "?" is valid for third character CHNEW2: CMPB #DECPVT,R0 ; is it a "?" ? BNE ERR ; if not, error 10$: MOVB R0,(R1)+ ; store response in input buffer CALL READ ; get next character BCS ERR ; "c" is a sequence terminator 20$: CMPB #DA,R0 ; is it a last character? BEQ SEARCH ; yes, search the table CALL CHNUM ;check if it is a number BCS CHSMC ;no, then check if it is a SMCLN TST SMCLN ;semicolon flag is set? BNE ACCUM ;no, then accum parameter CMP PAR1,#NUM15 ;is it LA12? BNE 10$ ;no, then save it and read next ACCUM: MOV PRMT,R2 ; CALL NUMCNV ;convert it to number BVS ERR ;too big, then error MOV R2,PRMT ;return number into param area BR 10$ ; CHSMC: CMPB #SEP,R0 ;is it a semicolon? BNE ERR ;no, then it is illegal char TST SMCLN ;was flag for SMCLN reset? BNE SETSMC ;no,then reset it CMP PAR1,#NUM15 ;is it LA12? BEQ ERR ;LA12 can have only one ";" BR 10$ SETSMC: MOV PRMT,PAR1 ;save first parameter CLR PRMT ; clear temp param area CLR SMCLN ;reset flag to indicate SMCLN BR 10$ .DSABL LSB SEARCH: TST SMCLN ;did we see a semicolon? BEQ 10$ ;branch if we did MOV PRMT,PAR1 ;save first parameter 10$: MOV PAR1,R0 ; MOV #TABL2,R2 ; R2 points to a TABL2 CALL CHKCHR ;search for term type BCS ERR ;no match, then error CMP PAR1,#NUM15 ;is it a VT102J/LA12 BNE FOUND ;no, then found TST SMCLN ;only LA12 has PAR2 BNE FOUND ;it is a VT102J PAR20: CLR T.TYPE(R2) ;LA12 is not a VT100 type TST PRMT ;PAR2 = 0? BNE PAR22 ; no, check if it is LA12 enhancement MOV #LA12ST,T.MESG(R2) ;yes, then it is LA12 standard BR FOUND PAR22: CMP PRMT,#NUM2 ;PAR2 = 2? BNE ERR ;no, then unidentified MOV #LA12EN,T.MESG(R2) ;yes, then it is LA12 enhancement FOUND: TSTB T.TYPE(R2) ;is it VT100 type? BNE VT100M ;branch if yes BISB #WARN$,@#USERRB ;set error byte to warn VT100M: TST REPFLG ;is report desired? BEQ 10$ ;branch if not .PRINT #MSG ;print corresponding .PRINT T.MESG(R2) ; message 10$: JMP EXIT ERR: BISB #WARN$,@#USERRB ;set user byte for warning TST REPFLG ;is report desired? BEQ 10$ ;branch if not .PRINT #MSG ;print corresponding .PRINT #UNKNWN ; message 10$: .BR EXIT EXIT: .PRINT #SAFETY ;set unscroll for safety .EXIT ;before exit in case it VT52 .SBTTL CHKCHR - Parsing Routine ;CHKCHR ;Parsing routine. Compares a character in R0 with a character in a table ;passed in R2. If the character is found in the table it returns to the ;main code. ;If the character is not found in the table the C-bit is set on return. ; ;Input: R0 = ASCII character to compare against table ; R2 = Points to the table ;Call: CALL CHKCHR ;Check for character match ; ;Output: C-bit set if no match. .CKXX CHKCHR:: TST @R2 ; end of table? BEQ 5$ ;unindentified terminal CK.R2=T.MESG ; TST (R2)+ ; TEXT part of the table CK.R2 T.MESG,+2 TSTB (R2)+ ; skip VT100 type indicator CK.R2 T.TYPE,+1 CMPB R0,(R2)+ ;check terminal ID against the table CK.R2 T.CHR,+1 BNE CHKCHR ;no, check next entry in the table TST (PC)+ 5$: SEC ;Set C-bit for error RETURN .SBTTL READ - read a character ;READ ;Read a character, if didn't get repeat attempt for MAX number of times ; ;c-bit is cleared and character is returned in R0 if character was received ; ;c-bit set if didn't get ; READ: MOV #MAX,R2 ;set R2 for arbitrary MAX num 1$: .TTINR ;read BCC GOT ;character received then return SOB R2,1$ ;decrement and if not=0,read again GOT: RETURN .SBTTL NUMCNV - convert a character to a number ;NUMCNV ;Converts each subsequent character into a decimal number and ;accumulates result in R2 ; INPUT R0 - character to convert ; R2 - parameter to be accumulated ; ; OUTPUT R2 - accumulated parameter NUMCNV::SUB #'0,R0 ;convert it to decimal ASL R2 ;mul 2 MOV R2,-(SP) ;save it ASL R2 ;mul 4 ASL R2 ;mul 8 ADD (SP)+,R2 ;mul 10 ADD R0,R2 ;accumulate parameter RETURN .SBTTL CHNUM - Check for number ;CHNUM ;Checks if subsequent character read in is a number ; ;INPUT R0 - Character to check ; ;OUTPUT c-bit is set if character is not a number ; CHNUM: CMPB R0,#CHAR.0 ; is it < 0? BLO 1$ ; yes, then return CMPB #CHAR.9,R0 ;is it > 9? 1$: RETURN .SBTTL Data area .PSECT TXTP QUERY1: .ASCII <33>/Z/<200> ;query message valid for older ;type of terminals ; Prior to sending an ANSI query a "move cursor up by one line" ; for a VT52 is issued. This will be necessary only if the VT52 ; did not respond to the first query due to line noise. Moving the ; cursor up by one line ensures that a SET SCROLL issued before the ; end of the program will unclog the VT52, if the VT52 is hung up by ; the ANSI query. ; QUERY2: .ASCII <33>/A/<33>/[c/<200> ;query message valid for newer ; type of terminals SAFETY: .ASCII <33>/\/<200> ;SET SCROLL for VT52 for safety MSG: .ASCII /The terminal is of type /<200> UNKNWN: .ASCIZ /UNKNOWN/ LA12ST: .ASCIZ /LA12 standard/ LA12EN: .ASCIZ /LA12 enhancement/ .EVEN .PSECT DATA REPLY: .BLKB 120. ;longer than the longest reply REPSIZ =: .-REPLY ;byte size of reply buffer .EVEN PAR1: .WORD 0 ;PAR1 area to accumulate first parameter PRMT: .WORD 0 ;PRMT temporary area to accumulate parameter SMCLN: .WORD 1 ;SMCLN is reset to 0 after first semicolon read in REPFLG: .WORD 0 ;"report" flag ; ; Table 1 contains the responses of older terminals which are replying ; to a query of Z. The third byte of the reply is unique for every ; terminal, if any. ; TABL1: .ENABL LSB TERM <'A>, ;esc /A is VT50 TERM <'B>, ;esc /B is VT50 w/copier TERM <'C>, ;esc /C is a VT55 TERM <'E>, ;esc /E is a VT55 UC/LC TERM <'H>, ;esc /H is a VT50H TERM <'J>, ;esc /J is a VT50H w/copier TERM <'K>, TERM <'L>, ;esc /K is a VT52 TERM <'M>, ;esc /L is a VT52 w/copier TERM <'Q>, ;esc /M is VT52 w/printer TERM <'R>, ;esc /Q is VT52J 8 bit TERM <'S>, ;esc /R is VT52J 7 bit TERM <'T>, ;esc /S is VT52J 8bit w/copier TERM <'Z>,,VT100=YES ;esc /Z VT1__ running as VT TERM <'`>, ;esc /` is a VT61 TERM <'a>, ;esc /a is a VT61 w/copier TERM <'b>, ;esc /b is VT61 w/printer TERM <'c>, ;esc /c is VT61 w/copier&prnt TERM <'~>, ;esc /~ is VT71 .WORD 0 ;end of old fashioned list .DSABL LSB ; ; Table 2 is a list of replies of newer terminals that respond to the ; ANSI query [c. ; TABL2: .ENABL LSB TERM <1.>,,VT100=YES ;VT100 (may be supported as VT102) TERM <2.>, ; (LA120 unsupported) TERM <3.>, ;LA34/38 TERM <4.>,,VT100=YES ;VT132 supported as VT102 TERM <5.>, ;VK100 unsupported TERM <6.>,,VT100=yes ;VT102 TERM <7.>,,VT100=yes ;VT131 TERM <8.>, ;VT278 TERM <9.>, ;LQPSE TERM <10.>, ;LA100 TERM <11.>, ;LA120J TERM <12.>,,VT100=YES ;VT125 TERM <13.>, ;LQP02 ;14 unused TERM <15.>,,VT100=YES ;VT102J/LA12 TERM <61.>,,VT100=YES TERM <62.>,,VT100=YES TERM <63.>,,VT100=YES TERM <64.>,,VT100=YES .WORD 0 .DSABL LSB .END START