2 * File: arch/blackfin/lib/memcmp.S
9 * Rev: $Id: memcmp.S 2386 2006-11-01 04:57:26Z magicyang $
12 * Copyright 2004-2006 Analog Devices Inc.
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see the file COPYING, or write
28 * to the Free Software Foundation, Inc.,
29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 * C Library function MEMCMP
39 * Favours word aligned data.
45 P0 = R0; /* P0 = s1 address */
46 P3 = R1; /* P3 = s2 Address */
47 P2 = R2 ; /* P2 = count */
49 IF CC JUMP .Ltoo_small;
51 R1 = R1 | R0; /* OR addresses together */
52 R1 <<= 30; /* check bottom two bits */
53 CC = AZ; /* AZ set if zero. */
54 IF !CC JUMP .Lbytes ; /* Jump if addrs not aligned. */
56 P1 = P2 >> 2; /* count = n/4 */
58 R2 = R2 & R3; /* remainder */
59 P2 = R2; /* set remainder */
61 LSETUP (.Lquad_loop_s , .Lquad_loop_e) LC0=P1;
67 IF !CC JUMP .Lquad_different;
73 CC = P2 == 0; /* Check zero count*/
74 IF CC JUMP .Lfinished; /* very unlikely*/
77 LSETUP (.Lbyte_loop_s , .Lbyte_loop_e) LC0=P2;
79 R1 = B[P3++](Z); /* *s2 */
80 R0 = B[P0++](Z); /* *s1 */
82 IF !CC JUMP .Ldifferent;
92 /* We've read two quads which don't match.
93 * Can't just compare them, because we're
94 * a little-endian machine, so the MSBs of
95 * the regs occur at later addresses in the
97 * Arrange to re-read those two quads again,
100 P0 += -4; /* back up to the start of the */
101 P3 = I0; /* quads, and increase the*/
102 P2 += 4; /* remainder count*/