4 * Copyright 2004-2007 Analog Devices Inc.
5 * Enter bugs at http://blackfin.uclinux.org/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see the file COPYING, or write
19 * to the Free Software Foundation, Inc.,
20 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 * C Library function MEMCMP
30 * Favours word aligned data.
34 .type _memcmp, STT_FUNC;
37 P0 = R0; /* P0 = s1 address */
38 P3 = R1; /* P3 = s2 Address */
39 P2 = R2 ; /* P2 = count */
41 IF CC JUMP .Ltoo_small;
43 R1 = R1 | R0; /* OR addresses together */
44 R1 <<= 30; /* check bottom two bits */
45 CC = AZ; /* AZ set if zero. */
46 IF !CC JUMP .Lbytes ; /* Jump if addrs not aligned. */
48 P1 = P2 >> 2; /* count = n/4 */
50 R2 = R2 & R3; /* remainder */
51 P2 = R2; /* set remainder */
53 LSETUP (.Lquad_loop_s , .Lquad_loop_e) LC0=P1;
59 IF !CC JUMP .Lquad_different;
65 CC = P2 == 0; /* Check zero count*/
66 IF CC JUMP .Lfinished; /* very unlikely*/
69 LSETUP (.Lbyte_loop_s , .Lbyte_loop_e) LC0=P2;
71 R1 = B[P3++](Z); /* *s2 */
72 R0 = B[P0++](Z); /* *s1 */
74 IF !CC JUMP .Ldifferent;
84 /* We've read two quads which don't match.
85 * Can't just compare them, because we're
86 * a little-endian machine, so the MSBs of
87 * the regs occur at later addresses in the
89 * Arrange to re-read those two quads again,
92 P0 += -4; /* back up to the start of the */
93 P3 = I0; /* quads, and increase the*/
94 P2 += 4; /* remainder count*/
103 .size _memcmp, .-_memcmp