.TITLE STRING SEARCH .PSECT SRST ; ; ; This subroutine is used to search for the first ; occurence of a character in a bounded string ; ; Call SRST(STRING,LOWER BOUND,UPPER BOUND ; ,CHARS TO LOOK FOR,LOGIBcal*1, ; [found character]) ; ; if a character is found lower bound ; value will be position of ; character in string, starting from 1 ; if found character is present,match character ; will be returned ; search is in order of ; search characters supplied, ie ; if characters are 'l:' will ; look for l first with in bounds ; if fails, then look for :. ; search characters must be ; a ASCIZ string. ; SRST:: MOV 2(R5),R0 ;GET START OF BUFFER MOV @4(R5),R1 ;GET LOWER SEARCH BOUND MOV @6(R5),R2 ;GET UPPER SEARCH BOUND MOV 10(R5),R3 ;GET ADDRESS OF STRING DEC R1 ;WANT TO DO THIS AT LEAST ONCE SUB R1,R2 ;NUMBER OF TIMES TO CHECK ADD R1,R0 ;START OF SEARCH AREA CLR R1 ;SET R1 TO F4P LOGICAL FALSE MOV R0,-(SP) MOV R2,-(SP) ; ; 1$: MOV (SP),R2 ;RESTORE POINTER AND COUNT MOV 2(SP),R0 MOVB (R3)+,R4 ;GET SEARCH CHARACTER BEQ 10$ ;NULL EXIT ; ; 2$: CMPB (R0)+,R4 ;THIS IT BEQ 5$ ;YES SOB R2,2$ ;NO KEEP TRYING BR 1$ ;DIDN'T FIND THIS ONE ;TRY ANOTHER 5$: MOV #-1,R1 ;FOUND IT SUB 2(R5),R0 ;GET ITS OFFSET MOV R0,@4(R5) ;GIVE IT BACK TO HIM 10$: MOVB R1,@12(R5) ;SET STATUS OF SEARCH CMP #6,(R5) ;DID HE WANT TO KNOW WHICH ONE BNE 20$ ;NO MOVB R4,@14(R5) ;YES 20$: CMP (SP)+,(SP)+ ;CLEAN UP RETURN .END