.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. ; .ENTRY SRST,^M ;ENTRY POINT MOVL 4(AP),R5 ;GET ADDRESS OF STRING MOVL @8(AP),R6 ;GET START BOUND MOVL @12(AP),R7 ;GET END MOVL 16(AP),R8 ;TEST STRING CLRB 20(AP) ;SET LOGICAL TO FALSE DECL R6 ;BACKUP ONE ADDL2 R6,R5 ;START ADDRESS SUBL2 R6,R7 ;NUMBER OF BYTES 1$: MOVZBL (R8)+,R4 ;GET BYTE BEQL 5$ ;OUT OF STRING LOCC R4,R7,R5 ;SEE IF IT IS THERE BNEQ 1$ ;NO TRY ONE MORE TIME INCB @20(AP) ;SET FIND TO TRUE CMPL #6,(AP) ;DOES HE WANT THE CHARACTER TOO BNEQ 5$ ;NO MOVB R4,@24(AP) ;RETURN CHAR FOUNDED 5$: RET ;EXIT .END