Debian Codegraph @

mpi/arm/mpih-mul2.S

raw
1 /* ARM mul_2 -- Multiply a limb vector with a limb and add the result to
2 * a second limb vector.
3 *
4 * Copyright (C) 2013 Jussi Kivilinna <[email protected]>
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 <http://www.gnu.org/licenses/>.
20 *
21 * Note: This code is heavily based on the GNU MP Library (version 4.2.1).
22 */
23
24 #include "sysdep.h"
25 #include "asm-syntax.h"
26
27 .syntax unified
28 .arm
29
30 /*******************
31 * mpi_limb_t
32 * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, r0
33 * mpi_ptr_t s1_ptr, r1
34 * mpi_size_t s1_size, r2
35 * mpi_limb_t s2_limb) r3
36 */
37
38 .text
39
40 .globl _gcry_mpih_addmul_1
41 .type _gcry_mpih_addmul_1,%function
42 _gcry_mpih_addmul_1:
43 push {r4, r5, r6, r8, r10, lr};
44 mov lr, #0;
45 cmn r0, #0; /* clear carry flag */
46
47 tst r2, #3;
48 beq .Large_loop;
49 .Loop:
50 ldr r5, [r1], #4;
51 ldr r4, [r0];
52 sub r2, #1;
53 adcs r4, lr;
54 mov lr, #0;
55 umlal r4, lr, r5, r3;
56 tst r2, #3;
57 str r4, [r0], #4;
58 bne .Loop;
59
60 teq r2, #0;
61 beq .Lend;
62
63 .Large_loop:
64 ldr r5, [r1], #4;
65 ldm r0, {r4, r6, r8, r10};
66
67 sub r2, #4;
68 adcs r4, lr;
69 mov lr, #0;
70 umlal r4, lr, r5, r3;
71
72 ldr r5, [r1], #4;
73 adcs r6, lr;
74 mov lr, #0;
75 umlal r6, lr, r5, r3;
76
77 ldr r5, [r1], #4;
78 adcs r8, lr;
79 mov lr, #0;
80 umlal r8, lr, r5, r3;
81
82 ldr r5, [r1], #4;
83 adcs r10, lr;
84 mov lr, #0;
85 umlal r10, lr, r5, r3;
86
87 teq r2, #0;
88 stm r0!, {r4, r6, r8, r10};
89 bne .Large_loop;
90
91 .Lend:
92 adc r0, lr, #0;
93 pop {r4, r5, r6, r8, r10, pc};
94 .size _gcry_mpih_addmul_1,.-_gcry_mpih_addmul_1;