2 ; Ullrich von Bassewitz, 31.05.1998
3 ; Christian Krueger, 2013-Aug-04, minor optimization
5 ; const char* strchr (const char* s, int c);
15 tay ; low byte of pointer to y
17 .if (.cpu .bitand ::CPU_ISET_65SC02)
21 sta ptr1 ; access from page start, y contains low byte
24 Loop: lda (ptr1),y ; Get next char
25 beq EOS ; Jump on end of string
27 beq Found ; Jump if yes
31 bne Loop ; Branch always
33 ; End of string. Check if we're searching for the terminating zero
36 lda tmp1 ; Get the char we're searching for
37 bne NotFound ; Jump if not searching for terminator
39 ; Found. Set pointer to c.
42 ldx ptr1+1 ; Load high byte of pointer
43 tya ; low byte is in y
46 ; Not found, return NULL