Last change
on this file since 690 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.1 KB
|
Line | |
---|
1 | .file "memmove.S" |
---|
2 | |
---|
3 | .section .text |
---|
4 | .global _memmove |
---|
5 | .type _memmove,@function |
---|
6 | _memmove: |
---|
7 | ;; R1: DEST |
---|
8 | ;; R2: SRC |
---|
9 | ;; R3: COUNT |
---|
10 | #ifdef __RX_DISALLOW_STRING_INSNS__ |
---|
11 | /* Do not use the string instructions - they might prefetch |
---|
12 | bytes from outside of valid memory. This is particularly |
---|
13 | dangerous in I/O space. */ |
---|
14 | |
---|
15 | cmp #0, r3 ; If the count is zero, do nothing |
---|
16 | beq 4f |
---|
17 | |
---|
18 | cmp r1, r2 |
---|
19 | blt 3f ; If SRC < DEST copy backwards |
---|
20 | |
---|
21 | mov r1, r14 ; Save a copy of DEST |
---|
22 | |
---|
23 | 5: mov.b [r2+], r5 |
---|
24 | mov.b r5, [r14+] |
---|
25 | sub #1, r3 |
---|
26 | bne 5b |
---|
27 | |
---|
28 | 4: rts |
---|
29 | |
---|
30 | 3: add r3, r1 |
---|
31 | add r3, r2 |
---|
32 | |
---|
33 | 6: mov.b [-r2], r5 |
---|
34 | mov.b r5, [-r1] |
---|
35 | sub #1, r3 |
---|
36 | bne 6b |
---|
37 | |
---|
38 | rts |
---|
39 | #else |
---|
40 | mov r1, r4 ; Save a copy of DEST |
---|
41 | cmp r1, r2 |
---|
42 | blt 2f ; If SRC (r2) is less than DEST (r1) then copy backwards |
---|
43 | smovf |
---|
44 | 1: |
---|
45 | mov r4, r1 ; Return DEST |
---|
46 | rts |
---|
47 | 2: |
---|
48 | add r3, r1 ; The SMOVB instructions requires the DEST in r1 and the |
---|
49 | add r3, r2 ; SRC in r2 but it needs them to point the last bytes of |
---|
50 | sub #1, r2 ; the regions involved not the first bytes, hence these |
---|
51 | sub #1, r1 ; additions and subtractions. |
---|
52 | smovb |
---|
53 | bra 1b |
---|
54 | |
---|
55 | #endif /* SMOVF allowed. */ |
---|
56 | |
---|
57 | .size _memmove, . - _memmove |
---|
Note: See
TracBrowser
for help on using the repository browser.