2 ; Ullrich von Bassewitz, 31.05.1998
3 ; Christian Krueger: 2013-Aug-01, optimization
5 ; char* strrchr (const char* s, int c);
10 .importzp ptr1, tmp1, tmp2
17 ldx #0 ; default function result is NULL, X is high byte...
18 stx tmp2 ; tmp2 is low-byte
19 stx ptr1 ; low-byte of source string is in Y, so clear real one...
22 lda (ptr1),y ; get char
23 beq finished ; jump if end of string
25 bne nextChar ; jump if no
28 sty tmp2 ; y has low byte of location, save it
29 ldx ptr1+1 ; x holds high-byte of result
35 bne testChar ; here like bra...
37 ; return the pointer to the last occurrence
40 lda tmp2 ; high byte in X is already correct...