/*1* Copyright 2004-2009 Analog Devices Inc.2*3* Licensed under the ADI BSD license or the GPL-2 (or later)4*/56#include <linux/linkage.h>78/* int memcmp(const void *s1, const void *s2, size_t n);9* R0 = First Address (s1)10* R1 = Second Address (s2)11* R2 = count (n)12*13* Favours word aligned data.14*/1516.text1718.align 21920ENTRY(_memcmp)21I1 = P3;22P0 = R0; /* P0 = s1 address */23P3 = R1; /* P3 = s2 Address */24P2 = R2 ; /* P2 = count */25CC = R2 <= 7(IU);26IF CC JUMP .Ltoo_small;27I0 = R1; /* s2 */28R1 = R1 | R0; /* OR addresses together */29R1 <<= 30; /* check bottom two bits */30CC = AZ; /* AZ set if zero. */31IF !CC JUMP .Lbytes ; /* Jump if addrs not aligned. */3233P1 = P2 >> 2; /* count = n/4 */34R3 = 3;35R2 = R2 & R3; /* remainder */36P2 = R2; /* set remainder */3738LSETUP (.Lquad_loop_s, .Lquad_loop_e) LC0=P1;39.Lquad_loop_s:40#if ANOMALY_0500020241R0 = [P0++];42R1 = [I0++];43#else44MNOP || R0 = [P0++] || R1 = [I0++];45#endif46CC = R0 == R1;47IF !CC JUMP .Lquad_different;48.Lquad_loop_e:49NOP;5051P3 = I0; /* s2 */52.Ltoo_small:53CC = P2 == 0; /* Check zero count*/54IF CC JUMP .Lfinished; /* very unlikely*/5556.Lbytes:57LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2;58.Lbyte_loop_s:59R1 = B[P3++](Z); /* *s2 */60R0 = B[P0++](Z); /* *s1 */61CC = R0 == R1;62IF !CC JUMP .Ldifferent;63.Lbyte_loop_e:64NOP;6566.Ldifferent:67R0 = R0 - R1;68P3 = I1;69RTS;7071.Lquad_different:72/* We've read two quads which don't match.73* Can't just compare them, because we're74* a little-endian machine, so the MSBs of75* the regs occur at later addresses in the76* string.77* Arrange to re-read those two quads again,78* byte-by-byte.79*/80P0 += -4; /* back up to the start of the */81P3 = I0; /* quads, and increase the*/82P2 += 4; /* remainder count*/83P3 += -4;84JUMP .Lbytes;8586.Lfinished:87R0 = 0;88P3 = I1;89RTS;9091ENDPROC(_memcmp)929394