.TITLE COMPARE INPUT STRING WITH COMPARATOR (STRING WITH # AND ?'S) ; ; THIS ROUTINE CHECKS A NAME AGAINST A SEARCH STRING FOR MATCHES ; ; WRITTEN BY: LOU PERAZZOLI 10-JUN-1978 ; ; .IDENT /1.0/ ; ; CALL WITH 4(AP) = ADDRESS OF INPUT STRING DESCRIPTOR ; 8(AP) = ADDRESS OF COMPARATOR STRING DESCRIPTOR ; RETURN SUCCESS OR FAILURE THROUGH R0 IN THE STANDARD WAY ; COMPARE:: .WORD ^M MOVL 4(AP),R5 ;ADDRESS OF INPUT DESCRIPTOR MOVL (R5)+,R2 ;LEN OF STRING MOVL (R5),R3 ;ADDRESS OF STRING MOVL R2,R0 ;LEN OF STRING IN R0 FOR LOOP CONTROL MOVL R3,R1 ;SAVE STARTING ADDRESS OF STRING MOVL 8(AP),R5 ;ADDRESS OF COMPARATOR DESCRIPTOR MOVL (R5)+,R4 ;LEN OF COMPARATOR STRING MOVL (R5),R5 ;ADDRESS OF COMPARATOR STRING ; ; DO THE COMPARES LOOPING ON LEN OF INPUT STRING (IN R0) ; 10$: CMPB (R5),#^A/?/ ;IS IT A WILD CHARACTER BNEQ 20$ ;BR IF NOT TSTL R0 ;ANY MORE CHARACTERS IN INPUT STRING BLEQ NOGO ;BRANCH IF NOT INCL R3 ;WILD CHAR INCREMENT ADDRESS INCL R5 ;INCREMENT ADDRESS BRB 60$ 20$: CMPB (R5),#^A/#/ ; IS CHAR A # BNEQ 50$ ;BR IF NOT ; FOUND A # ADJUST STRING DECL R4 ;DECREMENT LEN OF COMPARATOR BEQL DONE ;IF NO MORE CHARACTER - DONE SUCCESS INCL R5 ;MOVE ADDRESS OF COMPARATOR OVER # CMPL R4,R2 ;IS SUBSTRING LONGER THAN ORGIONAL BGTR NOGO ;ERROR IF IT IS SUBL3 R4,R2,R0 ;NUMBER OF CHARACTERS INTO STRING TO GO ADDL3 R0,R1,R3 ;START OF SUBSTRING MOVL R4,R0 ;LENGTH OF SUBSTRING BRB 10$ ;START COMPARING 50$: TSTL R0 ;ANY MORE CHARACTERS IN INPUT STRING BEQL NOGO ;BRANCH IF NOT CMPB (R5)+,(R3)+ ;DO CHARACTERS MATCH BNEQ NOGO ;NO - COMPARE FAILS 60$: DECL R4 ;ONE LESS CHARACTER IN COMPARATOR BEQL DONE ;IF NO MORE THAN COMPARE SUCCEEDS SOBGEQ R0,10$ ;LOOP AGAIN NOGO: CLRL R0 ;COMPARE FAILED RET DONE: MOVL #1,R0 RET ;SUCCESS .END