Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Memory Search for Telehack
5 REM MEMSRCH.BAS BY TECHMAGE@TELEHACK.COM
10 PRINT "START ADDRESS (DEC)";
15 INPUT AS: REM STARTING ADDRESS (DECIMAL)
20 PRINT "END ADDRESS (DEC)";
25 INPUT AE: REM ENDING ADDRESS (DECIMAL)
30 PRINT "SEARCH STRING";
35 INPUT S$: REM SEARCH STRING
40 L=LEN(S$): REM LENGTH OF SEARCH STRING
45 DIM AA(L): REM ADDRESS ARRAY
50 AC=AS: REM CURRENT ADDRESS (INCREMENTS)
100 D=PEEK(AC): REM DATA
110 IF CHR$(D) = MID$(S$,1,1) THEN GOTO 200
115 AC=AC+1
120 IF AC >= AE THEN GOTO 300
125 GOTO 100
200 REM LOOP TO MATCH ENTIRE STRING
205 FOR I = 1 TO L
210 IF CHR$(PEEK(AC+I-1)) <> MID$(S$,I,1) THEN GOTO 115
215 AA(I)=AC+I-1
220 NEXT
225 GOTO 400
300 PRINT "SEARCH STRING ";
305 PRINT CHR$(34);S$;CHR$(34);
310 PRINT " NOT FOUND IN ADDRESS RANGE."
315 GOTO 420
400 PRINT "SEARCH STRING ";
405 PRINT CHR$(34);S$;CHR$(34);
410 PRINT " FOUND BETWEEN ADDRESSES";
415 PRINT AA(1);" AND ";AA(L);"."
420 END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment