1/* Copyright (c) 2006, Carlos Lamas
2
3   based on libc/pmstring/strcmp_P.S which is
4   Copyright (c) 2002, Marek Michalkiewicz
5
6   All rights reserved.
7
8   Redistribution and use in source and binary forms, with or without
9   modification, are permitted provided that the following conditions are met:
10
11   * Redistributions of source code must retain the above copyright
12     notice, this list of conditions and the following disclaimer.
13   * Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in
15     the documentation and/or other materials provided with the
16     distribution.
17   * Neither the name of the copyright holders nor the names of
18     contributors may be used to endorse or promote products derived
19     from this software without specific prior written permission.
20
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  POSSIBILITY OF SUCH DAMAGE. */
32
33/* $Id: strcmp_PF.S 2503 2016-02-07 22:59:47Z joerg_wunsch $ */
34
35#if !defined(__AVR_TINY__)
36
37#include "macros.inc"
38
39#define s1_b1 r25
40#define s1_b0 r24
41#define s2_b3 r23
42#define s2_b2 r22
43#define s2_b1 r21
44#define s2_b0 r20
45
46#define ret_b1 r25
47#define ret_b0 r24
48
49#if !defined(__DOXYGEN__)
50
51	.text
52	.global	_U(strcmp_PF)
53	.type	_U(strcmp_PF), @function
54
55_U(strcmp_PF):
56
57	X_movw	ZL, s2_b0
58	LPM_R0_ZPLUS_INIT s2_b2
59	X_movw	XL, s1_b0
60
61.L_strcmp_PF_loop:
62
63	ld	ret_b0, X+
64	LPM_R0_ZPLUS_NEXT s2_b2
65	sub	ret_b0, r0
66	brne	.L_strcmp_PF_done
67	tst	r0
68	brne	.L_strcmp_PF_loop
69
70.L_strcmp_PF_done:
71; ret_hi = SREG.C ? 0xFF : 0
72
73	sbc	ret_b1, ret_b1
74	ret
75
76.L_strcmp_PF_end:
77
78	.size	_U(strcmp_PF), .L_strcmp_PF_end - _U(strcmp_PF)
79
80#endif /* not __DOXYGEN__ */
81
82#endif /* !defined(__AVR_TINY__) */
83