Debian Codegraph @

mpi/amd64/mpih-mul1.S

raw
1 /* AMD64 mul_1 -- Multiply a limb vector with a limb and store
2 * the result in a second limb vector.
3 * Copyright (C) 1992, 1994, 1998,
4 * 2001, 2002, 2006 Free Software Foundation, Inc.
5 *
6 * This file is part of Libgcrypt.
7 *
8 * Libgcrypt is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * Libgcrypt is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, see <https://www.gnu.org/licenses/>.
20 * SPDX-License-Identifier: LGPL-2.1-or-later
21 *
22 * Note: This code is heavily based on the GNU MP Library.
23 * Actually it's the same code with only minor changes in the
24 * way the data is stored; this is to support the abstraction
25 * of an optional secure memory allocation which may be used
26 * to avoid revealing of sensitive data due to paging etc.
27 */
28
29
30 #include "sysdep.h"
31 #include "asm-syntax.h"
32
33 /*******************
34 * mpi_limb_t
35 * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (rdi)
36 * mpi_ptr_t s1_ptr, (rsi)
37 * mpi_size_t s1_size, (rdx)
38 * mpi_limb_t s2_limb) (rcx)
39 */
40
41
42 TEXT
43 ALIGN(4)
44
45 GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
46 C_SYMBOL_NAME(_gcry_mpih_mul_1:)
47
48 FUNC_ENTRY()
49 movq %rdx, %r11
50 leaq (%rsi,%rdx,8), %rsi
51 leaq (%rdi,%rdx,8), %rdi
52 negq %r11
53 xorl %r8d, %r8d
54
55 ALIGN(4)
56 .Loop: movq (%rsi,%r11,8), %rax
57 mulq %rcx
58 addq %r8, %rax
59 movl $0, %r8d
60 adcq %rdx, %r8
61 movq %rax, (%rdi,%r11,8)
62 incq %r11
63 jne .Loop
64
65 movq %r8, %rax
66 FUNC_EXIT()