1/* Copyright (c) 2006, Carlos Lamas 2 3 based on libc/pmstring/strncmp_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: strncmp_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#define len_b1 r19 46#define len_b0 r18 47 48#define ret_b1 r25 49#define ret_b0 r24 50 51#if !defined(__DOXYGEN__) 52 53 .text 54 .global _U(strncmp_PF) 55 .type _U(strncmp_PF), @function 56 57_U(strncmp_PF): 58 59 X_movw ZL, s2_b0 60 LPM_R0_ZPLUS_INIT s2_b2 61 X_movw XL, s1_b0 62 63.L_strncmp_PF_loop: 64 65 subi len_b0, lo8(1) 66 sbci len_b1, hi8(1) 67 brcs .L_strncmp_PF_equal 68 ld ret_b0, X+ 69 LPM_R0_ZPLUS_NEXT s2_b2 70 sub ret_b0, r0 71 brne .L_strncmp_PF_done 72 tst r0 73 brne .L_strncmp_PF_loop 74 75.L_strncmp_PF_equal: 76 77 sub ret_b0, ret_b0 78 79.L_strncmp_PF_done: 80; ret_hi = SREG.C ? 0xFF : 0 81 82 sbc ret_b1, ret_b1 83 ret 84 85.L_strncmp_PF_end: 86 87 .size _U(strncmp_PF), .L_strncmp_PF_end - _U(strncmp_PF) 88 89#endif /* not __DOXYGEN__ */ 90 91#endif /* !defined(__AVR_TINY__) */ 92