6 .type _memchr,@function
10 ;; R3: max number to scan
11 #ifdef __RX_DISALLOW_STRING_INSNS__
12 mov.b r2, r2 ; The mov.b below sign extends as it loads, so make sure that r2 is sign-extended as well.
20 sub #1, r1 ; We have found a match, bit now R1 points to the byte after the match.
23 cmp #0, r3 ; If r3 is 0 suntil.b will do nothing and not set any flags...
24 stz #1, r1 ; ...so store 1 into r1. It will be decremented by the SUB later.
25 suntil.b ; Search until *r1 == r2 or r3 bytes have been examined.
26 stnz #1, r1 ; If no match was found return NULL.
27 sub #1, r1 ; suntil.b leaves r1 pointing at the address *after* the match.
31 .size _memchr, . - _memchr