10 ;STRING SEARCH SUBROUTINE¢20 ;BY JERRY WHITE 7/2/82¢30 ;¢40 ;CALL FROM BASIC (SS$)¢50 ;FIND=USR(ADR(SS$),COUNT,ADR(DSTR$),ADR(SSTR$))¢60 ;¢70 ;FINDTHIS SETUP FOR¢80 ;8 CHARACTER RECORDS¢90 ;¢0100 *=$600. ;RELOCATABLE¢0110 SSLO=$CD ;SSTR$ LO BYTE¢0120 SSHI=$CE. ;SSTR$ HI BYTE¢0130 DSLO=$CB ;DSTR$ LO BYTE¢0140 DSHI=$CC. ;DSTR$ HI BYTE¢0150 COUNTL=$D4 ;COUNT LO BYTE¢0160 COUNTH=$D5 ;COUNT HI BYTE¢0170 ;¢0180 PLA¢0190 PLA¢0200 STA COUNTH ;STORE¢0210 PLA¢0220 STA COUNTL ;ARGUMENTS¢0230 PLA¢0240 STA SSHI ;ON¢0250 PLA¢0260 STA SSLO ;PAGE 0¢0270 PLA¢0280 STA DSHI¢0290 PLA¢0300 STA DSLO¢0310 BEGIN LDY #0 ;INDEX=Y¢0320 ;¢0330 ; COMPARE ONE BYTE¢0340 ; FROM DATA STRING¢0350 ; WITH ONE BYTE¢0360 ; FROM SEARCH STRING¢0370 ;¢0380 LOOP1 LDA (DSLO),Y¢0390 CMP (DSLO),Y¢0400 ;¢0410 ; IF NO MATCH THEN¢0420 ; DONT BOTHER WITH¢0430 ; REST OF RECORD¢0440 ;¢0450 BNE LOOP2¢0460 INY ;INCREMENT INDEX¢0470 ; RECORD LENGTH=8¢0480 CPY #8 ;END OF RECORD?¢0490 ; IF NOT THEN¢0500 ; COMPARE NEXT¢0510 BNE LOOP1¢0520 ;¢0530 ; WE FOUND A MATCH¢0540 ; SO RETURN TO BASIC¢0550 RTS¢0560 ;¢0570 ; RESET SEARCH ADDRESS¢0580 ; TO NEXT RECORD¢0590 ;¢0600 LOOP2 LDA SSLO¢0610 CLC¢0620 ADC #8 ;8 CHARACTER RECORD¢0630 STA SSLO¢0640 BCC LOOP3¢0650 ;¢0660 ; CARRY SET SO¢0670 ; INCREMENT HI BYTE¢0680 ;¢0690 INC SSHI¢0700 LOOP3 LDA COUNTL¢0710 ;¢0720 ; IF LO BYTE<>0¢0730 ; DONT CHECK HI BYTE¢0740 ;¢0750 BNE LOOP4¢0760 LDA COUNTH¢0770 ;¢0780 ; COUNTER=0 SO¢0790 ; RETURN TO BASIC¢0800 ;¢0810 BEQ EXIT¢0820 ;¢0830 ; DECREMENT COUNTERS¢0840 ;¢0850 DEC COUNTH¢0860 LOOP4 DEC COUNTL¢0870 CLC ;FORCE BRANCH¢0880 BCC BEGIN¢0890 ;¢0900 ; IF WE GOT HERE THEN¢0910 ; THE SEARCH WAS NEGATIVE¢0920 EXIT RTS¢¢