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, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
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(5)
44	.byte	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
45
46	GLOBL	C_SYMBOL_NAME(_gcry_mpih_mul_1)
47C_SYMBOL_NAME(_gcry_mpih_mul_1:)
48
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.Loop:	movq	(%rsi,%r11,8), %rax
56	mulq	%rcx
57	addq	%r8, %rax
58	movl	$0, %r8d
59	adcq	%rdx, %r8
60	movq	%rax, (%rdi,%r11,8)
61	incq	%r11
62	jne	.Loop
63
64	movq	%r8, %rax
65	ret
66