mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-24 07:57:22 +08:00
fd6942ab42
* configure.host: Add support for RX architecture. * libc/include/machine/ieeefp.h: Likewise. * libc/include/machine/setjmp.h: Likewise. * libc/include/machine/configure.in: Likewise. * libc/include/machine/configure: Regenerate. * libc/machine/rx: New directory. * libc/machine/rx/*: New files to support RX architecture. libgloss: * configure.in: Add support for RX sub-directory. * configure: Regenerate. * rx: New directory. * rx/*: New files to support RX architecture.
36 lines
1.3 KiB
ArmAsm
36 lines
1.3 KiB
ArmAsm
.file "strncat.S"
|
|
|
|
.section .text
|
|
.global _strncat
|
|
.type _strncat,@function
|
|
_strncat:
|
|
;; On entry: r1 => Destination
|
|
;; r2 => Source
|
|
;; r3 => Max number of bytes to copy
|
|
|
|
mov r1, r4 ; Save a copy of the dest pointer.
|
|
mov r2, r5 ; Save a copy of the source pointer.
|
|
mov r3, r6 ; Save a copy of the byte count.
|
|
|
|
mov #0, r2 ; Search for the NUL byte.
|
|
mov #-1, r3 ; Search until we run out of memory.
|
|
suntil.b ; Find the end of the destination string.
|
|
sub #1, r1 ; suntil.b leaves r1 pointing to the byte beyond the NUL.
|
|
|
|
mov r6, r3 ; Restore the limit on the number of bytes copied.
|
|
mov r5, r2 ; Restore the source pointer.
|
|
mov r1, r5 ; Save a copy of the dest pointer.
|
|
smovu ; Copy source to destination.
|
|
|
|
add #0, r6, r3 ; Restore the number of bytes to copy (again), but this time set the Z flag as well.
|
|
beq 1f ; If we copied 0 bytes then we already know that the dest string is NUL terminated, so we do not have to do anything.
|
|
mov #0, r2 ; Otherwise we must check to see if a NUL byte
|
|
mov r5, r1 ; was included in the bytes that were copied.
|
|
suntil.b
|
|
beq 1f ; Z flag is set if a match was found.
|
|
add r6, r5 ; Point at byte after end of copied bytes.
|
|
mov.b #0, [r5] ; Store a NUL there.
|
|
1:
|
|
mov r4, r1 ; Return the original dest pointer.
|
|
rts
|