1/* 2Copyright (c) 2009 Nick Clifton <nickc@redhat.com> 3 */ 4 .file "strncmp.S" 5 6 .section .text 7 .global _strncmp 8 .type _strncmp,@function 9_strncmp: 10 ;; R1: string1 11 ;; R2: string2 12 ;; R3: max number of bytes to compare 13#ifdef __RX_DISALLOW_STRING_INSNS__ 14 cmp #0, r3 ; For a length of zero, return zero 15 beq 4f 16 172: mov.b [r1+], r4 18 mov.b [r2+], r5 19 cmp #0, r4 20 beq 3f 21 cmp #0, r5 22 beq 3f 23 sub #1, r3 24 beq 3f 25 cmp r4, r5 26 beq 2b 27 283: and #0xff, r4 ; We need to perform an unsigned comparison of the bytes. 29 and #0xff, r5 30 sub r5, r4, r1 31 rts 32 334: mov #0, r1 34 rts 35#else 36 scmpu ; Perform the string comparison 37 bnc 1f ; If Carry is not set skip over 38 scne.L r1 ; Set result based on Z flag 39 rts ; 401: ; 41 mov #-1,r1 ; Carry not set, result should be negative 42 rts ; 43#endif 44 .size _strncmp, . - _strncmp 45