- clrl r4 # r4 = pointer to last match
-6:
- locc $0,$65535,(r3) # look for '\0'
- bneq 8f
- decw r0 # r0 = 65535
-1:
- locc r2,r0,(r3) # look for c
- bneq 7f
- movl r1,r3 # reset pointer and ...
- jbr 6b # ... try again
-7:
- movl r1,r4 # stash pointer ...
- addl3 $1,r1,r3 # ... skip over match and ...
- decl r0 # ... decrement count
- jbr 6b # ... try again
-8:
- subl3 r3,r1,r0 # length of short block
- incl r0 # +1 for '\0'
-9:
- locc r2,r0,(r3) # look for c
- beql 0f
- movl r1,r4 # stash pointer ...
- addl3 $1,r1,r3 # ... skip over match ...
- decl r0 # ... adjust count and ...
- jbr 9b # ... try again
-0:
- movl r4,r0 # return stashed pointer
+ locc $0,r4,(r3) /* look for '\0' */
+ bneq 1f
+ locc r2,r4,(r3) /* continue phase 1 search for c */
+ beql 0b
+ movab (r1)+,r5 /* found c: save and increment pointer */
+ brb 0b /* and continue */
+
+1: /* second phase */
+ subl3 r3,r1,r0 /* length of short block */
+ movl r3,r1
+2:
+ locc r2,r0,(r1) /* look for c */
+ beql 3f /* skip if not found */
+ movab (r1)+,r5 /* save pointer as before */
+ sobgtr r0,2b /* adjust count and loop */
+3:
+ movl r5,r0 /* return stashed pointer */