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:
1.0 KB
|
Line | |
---|
1 | .file "strcat.S" |
---|
2 | |
---|
3 | .section .text |
---|
4 | .global _strcat |
---|
5 | .type _strcat,@function |
---|
6 | _strcat: |
---|
7 | ;; On entry: r1 => Destination |
---|
8 | ;; r2 => Source |
---|
9 | #ifdef __RX_DISALLOW_STRING_INSNS__ |
---|
10 | mov r1, r4 ; Save a copy of the dest pointer. |
---|
11 | |
---|
12 | 1: mov.b [r4+], r5 ; Find the NUL byte at the end of R4. |
---|
13 | cmp #0, r5 |
---|
14 | bne 1b |
---|
15 | |
---|
16 | sub #1, r4 ; Move R4 back to point at the NUL byte. |
---|
17 | |
---|
18 | 2: mov.b [r2+], r5 ; Copy bytes from R2 to R4 until we reach a NUL byte. |
---|
19 | mov.b r5, [r4+] |
---|
20 | cmp #0, r5 |
---|
21 | bne 2b |
---|
22 | |
---|
23 | rts |
---|
24 | #else |
---|
25 | mov r1, r4 ; Save a copy of the dest pointer. |
---|
26 | mov r2, r5 ; Save a copy of the source pointer. |
---|
27 | |
---|
28 | mov #0, r2 ; Search for the NUL byte. |
---|
29 | mov #-1, r3 ; Limit on the number of bytes examined. |
---|
30 | suntil.b ; Find the end of the destination string. |
---|
31 | sub #1, r1 ; suntil.b leaves r1 pointing to the byte beyond the match. |
---|
32 | |
---|
33 | mov #-1, r3 ; Set a limit on the number of bytes copied. |
---|
34 | mov r5, r2 ; Restore the source pointer. |
---|
35 | smovu ; Copy source to destination |
---|
36 | |
---|
37 | mov r4, r1 ; Return the original dest pointer. |
---|
38 | rts |
---|
39 | #endif |
---|
40 | .size _strcat, . - _strcat |
---|
41 | |
---|
Note: See
TracBrowser
for help on using the repository browser.