.Title CtlMatch Device Control String Search Routine. .Psect Alvin,Gbl,Con .Ident /LVL51 / .Mcall $Alvin $Alvin ;+ ;;********************************************************************** ;; CTLMATCH - Alvin interrupt handler subroutine used to compare an ;; input character in REGISTER 0 to a control string (CTLSTR) ;; defined in the device descriptor, the address of which is ;; in REGISTER 2. The control string is of the form: ;; CTLSTR(R2) -> high byte - low byte ;; ;; continued for number of control chars ;; terminated with an all zero word. ;; The control type is limited to the set defined in the handler ;; and is a low order value from zero to some maximum. For each ;; type a subroutine is defined which will process the condition ;; as a result of the occurance of this character. ;; A continuous set of types from zero thru the maximum must be ;; defined as a vector of entry points, the base address of which ;; is passed from the calling interrupt handler. The maximum ;; type value allowed is also passed. ;; Expects calls of the form: ;; JSR R5,CTLMATCH ;Enter with char in R0, device R2 ;; .WORD (maximum control type value) ;; .WORD (address of subroutine entry point stack) ;; BR (no match found) ;- CTLMATCH:: MOV R3,-(SP) ;Save work register MOV R1,-(SP) ;Save another work register MOV R0,-(SP) ;Save character with original parity MOV CTLSTR(R2),R3 ;Get the pointer to the control string BNE CTLENTER ;Proceed if not zero CTLNONE: CMP (R5)+,(R5)+ ;Select no match found exit BR CTLEXIT ;Exit CTLENTER: BIC #177600,R0 ;Clear parity bit and high order byte CTLOOP: MOV (R3)+,R1 ;Get an option word BEQ CTLNONE ;If zero word found, no match CMPB R0,R1 ;Is this a match? BNE CTLOOP ;No, loop for next option SWAB R1 ;Put type in low order byte MOVB R1,1(SP) ;Save control type with original character BIC #177760,R1 ;Allow up to 16 types CMP R1,(R5)+ ;Is this within the defined limit? BHI CTLMERROR ;No, error branch ASL R1 ;Convert for word offset ADD (R5)+,R1 ;Add base address of the type handlers MOV (R1),R1 ;Get the subroutine address BEQ CTLEXIT ;No subroutine, no match - exit. Mov (SP)+,R0 ;Put type and original char in R0. JSR PC,(R1) ;Process this control type Tst (R5)+ ;Match found, return appropriately. Br CTLMout ;(R0 already restored so subr can override) CTLMERROR: INC ERRCNT(R2) ;Count this as an input error & no match TST (R5)+ CTLEXIT: MOV (SP)+,R0 ;restore character CTLMout: MOV (SP)+,R1 ;Restore work registers MOV (SP)+,R3 RTS R5 ;Return via REGISTER 5. ;;************************************************************************* .End