Skip to content

Commit 2c0a358

Browse files
committed
machine/rx: Fix memchr to mask needle value to a single byte
memchr is supposed to interpret the parameter as an unsigned char, and that requires it to ignore the upper bits. Signed-off-by: Keith Packard <[email protected]>
1 parent 3c63abd commit 2c0a358

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

newlib/libc/machine/rx/memchr.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _memchr:
1212
;; R1: string pointer
1313
;; R2: byte sought
1414
;; R3: max number to scan
15+
and #255, r2
1516
cmp #0, r3 ; If r3 is 0 suntil.b will do nothing and not set any flags...
1617
stz #1, r1 ; ...so store 1 into r1. It will be decremented by the SUB later.
1718
suntil.b ; Search until *r1 == r2 or r3 bytes have been examined.

0 commit comments

Comments
 (0)