File: memcpy.S

package info (click to toggle)
avr-libc 20020203-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,448 kB
  • ctags: 6,562
  • sloc: ansic: 7,631; asm: 4,424; sh: 2,703; makefile: 338; pascal: 289
file content (48 lines) | stat: -rw-r--r-- 885 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

#include "macros.inc"

#define dest_hi r25
#define dest_lo r24
#define src_hi r23
#define src_lo r22
#define len_hi r21
#define len_lo r20

; void *memcpy(void *dest, const void *src, size_t len)

	.text
	.global	_U(memcpy)
	.type	_U(memcpy), @function
_U(memcpy):
	LOAD_Z(src_lo, src_hi)
	LOAD_X(dest_lo, dest_hi)
#if OPTIMIZE_SPEED
; 15 words, (14 + len * 6 - (len & 1)) cycles
	sbrs	len_lo, 0
	rjmp	.memcpy_start
	rjmp	.memcpy_odd
.memcpy_loop:
	ld	__tmp_reg__, Z+
	st	X+, __tmp_reg__
.memcpy_odd:
	ld	__tmp_reg__, Z+
	st	X+, __tmp_reg__
.memcpy_start:
	subi	len_lo, lo8(2)
	sbci	len_hi, hi8(2)
#else
; 11 words, (13 + len * 8) cycles
	rjmp	.memcpy_start
.memcpy_loop:
	ld	__tmp_reg__, Z+
	st	X+, __tmp_reg__
.memcpy_start:
	subi	len_lo, lo8(1)
	sbci	len_hi, hi8(1)
#endif
	brcc	.memcpy_loop
; return dest (unchanged)
	ret
.memcpy_end:
	.size	_U(memcpy), .memcpy_end - _U(memcpy)