File: strncmp_P.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 (40 lines) | stat: -rw-r--r-- 717 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

#include "macros.inc"

#define s1_hi r25
#define s1_lo r24
#define s2_hi r23
#define s2_lo r22
#define len_hi r21
#define len_lo r20

#define ret_hi r25
#define ret_lo r24

; int strncmp_P(const char *s1, const char flash *s2, size_t len)

	.text
	.global	_U(strncmp_P)
	.type	_U(strncmp_P), @function
_U(strncmp_P):
	LOAD_Z(s2_lo, s2_hi)
	LOAD_X(s1_lo, s1_hi)
.strncmp_P_loop:
	subi	len_lo, lo8(1)
	sbci	len_hi, hi8(1)
	brcs	.strncmp_P_equal
	ld	ret_lo, X+
	LPM_R0_ZP
	sub	ret_lo, r0
	brne	.strncmp_P_done
	tst	r0
	brne	.strncmp_P_loop
.strncmp_P_equal:
	sub	ret_lo, ret_lo
.strncmp_P_done:
; ret_hi = SREG.C ? 0xFF : 0
	sbc	ret_hi, ret_hi
	ret
.strncmp_P_end:
	.size	_U(strncmp_P), .strncmp_P_end - _U(strncmp_P)