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