4 Copyright (C) 2010, 2014, Niels Möller
6 This file is part of GNU Nettle.
8 GNU Nettle is free software: you can redistribute it and/or
9 modify it under the terms of either:
11 * the GNU Lesser General Public License as published by the Free
12 Software Foundation; either version 3 of the License, or (at your
13 option) any later version.
17 * the GNU General Public License as published by the Free
18 Software Foundation; either version 2 of the License, or (at your
19 option) any later version.
21 or both in parallel, as here.
23 GNU Nettle is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 General Public License for more details.
28 You should have received copies of the GNU General Public License and
29 the GNU Lesser General Public License along with this program. If
30 not, see http://www.gnu.org/licenses/.
34 define(<DST>, <%rax>) C Originally in %rdi
41 define(<S1>, <%rdi>) C Overlaps with CNT
43 define(<USE_SSE2>, <no>)
49 C memxor(void *dst, const void *src, size_t n)
53 PROLOGUE(nettle_memxor)
57 C Get number of unaligned bytes at the end
58 C %rdi is used as CNT, %rax as DST and as return value
69 C FIXME: Instead of this loop, could try cmov with memory
70 C destination, as a sequence of one 8-bit, one 16-bit and one
71 C 32-bit operations. (Except that cmov can't do 8-bit ops, so
72 C that step has to use a conditional).
76 movb (SRC, N), LREG(TMP)
77 xorb LREG(TMP), (DST, N)
87 C Next destination word is -8(DST, N)
110 ja .Lword_loop C Not zero and no carry
113 C Final operation is word aligned
128 movb (SRC, N), LREG(TMP)
129 xorb LREG(TMP), (DST, N)
151 movdqu (SRC, N), %xmm0
152 movdqa (DST, N), %xmm1
154 movdqa %xmm1, (DST, N)
159 C FIXME: See if we can do a full word first, before the
160 C byte-wise final loop.
163 C Final operation is aligned
173 EPILOGUE(nettle_memxor)