source: trunk/libs/newlib/src/newlib/libc/machine/rx/strncpy.S @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1004 bytes
Line 
1        .file   "strncpy.S"
2
3        .section .text
4        .global  _strncpy
5        .type    _strncpy,@function
6_strncpy:
7#ifdef __RX_DISALLOW_STRING_INSNS__
8        cmp     #0, r3
9        beq     3f
10       
11        mov     r1, r4          ; Preserve R1 for the return value.
12
132:      mov.b   [r2+], r5       ; Copy bytes until...
14        mov.b   r5, [r4+]
15        sub     #1, r3
16        beq     3f              ; ... our count reaches zero
17        cmp     #0, r5
18        bne     2b              ; ... or we have written a NUL byte
19
204:      mov.b   r5, [r4+]       ; Continue to write further NUL bytes
21        sub     #1, r3
22        bne     4b              ; until the count reaches zero.
23
243:      rts
25       
26#else
27        mov     r1, r4          ; Save a copy of the dest pointer.
28        mov     r3, r5          ; Save a copy of the byte count
29        smovu                   ; Copy the bytes
30        cmp     #0, r3          ; If we have copied the number of bytes requested
31        beq     1f              ;  then skip the next bit:
32        add     r4, r5, r1      ; Point to the last byte that we are supposed to write.
33        sub     r3, r1          ; Subtract the number of bytes left to be written.
34        mov     #0, r2          ; Fill the remaining bytes with NULs,
35        sstr.b
361:
37        mov     r4, r1          ; Return the destination pointer
38        rts
39#endif
40        .size _strncpy, . - _strncpy
41       
Note: See TracBrowser for help on using the repository browser.