4 * Copyright 2004-2007 Analog Devices Inc.
5 * Enter bugs at http://blackfin.uclinux.org/
7 * SPDX-License-Identifier: GPL-2.0+
13 * C Library function MEMCMP
17 * Favours word aligned data.
21 .type _memcmp, STT_FUNC;
24 P0 = R0; /* P0 = s1 address */
25 P3 = R1; /* P3 = s2 Address */
26 P2 = R2 ; /* P2 = count */
28 IF CC JUMP .Ltoo_small;
30 R1 = R1 | R0; /* OR addresses together */
31 R1 <<= 30; /* check bottom two bits */
32 CC = AZ; /* AZ set if zero. */
33 IF !CC JUMP .Lbytes ; /* Jump if addrs not aligned. */
35 P1 = P2 >> 2; /* count = n/4 */
37 R2 = R2 & R3; /* remainder */
38 P2 = R2; /* set remainder */
40 LSETUP (.Lquad_loop_s , .Lquad_loop_e) LC0=P1;
46 IF !CC JUMP .Lquad_different;
52 CC = P2 == 0; /* Check zero count*/
53 IF CC JUMP .Lfinished; /* very unlikely*/
56 LSETUP (.Lbyte_loop_s , .Lbyte_loop_e) LC0=P2;
58 R1 = B[P3++](Z); /* *s2 */
59 R0 = B[P0++](Z); /* *s1 */
61 IF !CC JUMP .Ldifferent;
71 /* We've read two quads which don't match.
72 * Can't just compare them, because we're
73 * a little-endian machine, so the MSBs of
74 * the regs occur at later addresses in the
76 * Arrange to re-read those two quads again,
79 P0 += -4; /* back up to the start of the */
80 P3 = I0; /* quads, and increase the*/
81 P2 += 4; /* remainder count*/
90 .size _memcmp, .-_memcmp