Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libc / machine / rx / strncmp.S
blob4be8076dbcdcb42fed600bb5a1631162d8a33caf
1         .file   "strncmp.S"
3         .section .text
4         .global  _strncmp
5         .type    _strncmp,@function
6 _strncmp:
7         ;; R1: string1
8         ;; R2: string2
9         ;; R3: max number of bytes to compare
10 #ifdef __RX_DISALLOW_STRING_INSNS__
11         cmp     #0, r3          ; For a length of zero, return zero
12         beq     4f
14 2:      mov.b   [r1+], r4
15         mov.b   [r2+], r5
16         cmp     #0, r4
17         beq     3f
18         cmp     #0, r5
19         beq     3f
20         sub     #1, r3
21         beq     3f
22         cmp     r4, r5
23         beq     2b
25 3:      and     #0xff, r4       ; We need to perform an unsigned comparison of the bytes.
26         and     #0xff, r5
27         sub     r5, r4, r1
28         rts
30 4:      mov     #0, r1
31         rts
32 #else
33         scmpu                   ; Perform the string comparison
34         bnc     1f              ; If Carry is not set skip over
35         scne.L  r1              ; Set result based on Z flag
36         rts                     ;
37 1:                              ;
38         mov     #-1,r1          ; Carry not set, result should be negative
39         rts                     ;
40 #endif
41         .size _strncmp, . - _strncmp