Debian Codegraph @

mpi/arm/mpih-mul1.S

raw
1 /* ARM mul_1 -- Multiply a limb vector with a limb and store the result in
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_mul_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_mul_1
41 .type _gcry_mpih_mul_1,%function
42 _gcry_mpih_mul_1:
43 push {r4, r5, r6, r7, r8, r9, r10, r11, lr};
44 mov r4, #0;
45
46 tst r2, #3;
47 beq .Large_loop;
48
49 .Loop:
50 ldr r5, [r1], #4;
51 mov lr, #0;
52 umlal r4, lr, r5, r3;
53 sub r2, #1;
54 str r4, [r0], #4;
55 tst r2, #3;
56 mov r4, lr;
57 bne .Loop;
58
59 teq r2, #0;
60 beq .Lend;
61
62 .Large_loop:
63 ldm r1!, {r5, r6, r7, r8};
64 mov r9, #0;
65 mov r10, #0;
66 umlal r4, r9, r5, r3;
67 mov r11, #0;
68 umlal r9, r10, r6, r3;
69 str r4, [r0], #4;
70 mov r4, #0;
71 umlal r10, r11, r7, r3;
72 subs r2, #4;
73 umlal r11, r4, r8, r3;
74 stm r0!, {r9, r10, r11};
75 bne .Large_loop;
76
77 .Lend:
78 mov r0, r4;
79 pop {r4, r5, r6, r7, r8, r9, r10, r11, pc};
80 .size _gcry_mpih_mul_1,.-_gcry_mpih_mul_1;