Last change
on this file was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
753 bytes
|
Rev | Line | |
---|
[444] | 1 | .file "strncmp.S" |
---|
| 2 | |
---|
| 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 |
---|
| 13 | |
---|
| 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 |
---|
| 24 | |
---|
| 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 |
---|
| 29 | |
---|
| 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 |
---|
Note: See
TracBrowser
for help on using the repository browser.