diff options
Diffstat (limited to 'newlib/libc/machine/rx/strncpy.S')
-rw-r--r-- | newlib/libc/machine/rx/strncpy.S | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/newlib/libc/machine/rx/strncpy.S b/newlib/libc/machine/rx/strncpy.S index e04922a59..e5b6a83ac 100644 --- a/newlib/libc/machine/rx/strncpy.S +++ b/newlib/libc/machine/rx/strncpy.S @@ -4,6 +4,26 @@ .global _strncpy .type _strncpy,@function _strncpy: +#ifdef __RX_DISALLOW_STRING_INSNS__ + cmp #0, r3 + beq 3f + + mov r1, r4 ; Preserve R1 for the return value. + +2: mov.b [r2+], r5 ; Copy bytes until... + mov.b r5, [r4+] + sub #1, r3 + beq 3f ; ... our count reaches zero + cmp #0, r5 + bne 2b ; ... or we have written a NUL byte + +4: mov.b r5, [r4+] ; Continue to write further NUL bytes + sub #1, r3 + bne 4b ; until the count reaches zero. + +3: rts + +#else mov r1, r4 ; Save a copy of the dest pointer. mov r3, r5 ; Save a copy of the byte count smovu ; Copy the bytes @@ -16,3 +36,6 @@ _strncpy: 1: mov r4, r1 ; Return the destination pointer rts +#endif + .size _strncpy, . - _strncpy + |