Debian Codegraph @

mpi/arm/mpih-mul3.S

raw
1 /* ARM mul_3 -- Multiply a limb vector with a limb and subtract the result
2 * from 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_submul_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_submul_1
41 .type _gcry_mpih_submul_1,%function
42 _gcry_mpih_submul_1:
43 push {r4, r5, r6, r8, r9, r10, lr};
44 mov lr, #0;
45 cmp r0, #0; /* prepare carry flag for sbc */
46
47 tst r2, #3;
48 beq .Large_loop;
49 .Loop:
50 ldr r5, [r1], #4;
51 mov r4, lr;
52 mov lr, #0;
53 ldr r6, [r0];
54 umlal r4, lr, r5, r3;
55 sub r2, #1;
56 sbcs r4, r6, r4;
57 tst r2, #3;
58 str r4, [r0], #4;
59 bne .Loop;
60
61 teq r2, #0;
62 beq .Lend;
63
64 .Large_loop:
65 ldr r5, [r1], #4;
66 mov r9, #0;
67 ldr r4, [r0, #0];
68
69 umlal lr, r9, r5, r3;
70 ldr r6, [r0, #4];
71 ldr r5, [r1], #4;
72 sbcs r4, r4, lr;
73
74 mov lr, #0;
75 umlal r9, lr, r5, r3;
76 ldr r8, [r0, #8];
77 ldr r5, [r1], #4;
78 sbcs r6, r6, r9;
79
80 mov r9, #0;
81 umlal lr, r9, r5, r3;
82 ldr r10, [r0, #12];
83 ldr r5, [r1], #4;
84 sbcs r8, r8, lr;
85
86 mov lr, #0;
87 umlal r9, lr, r5, r3;
88 sub r2, #4;
89 sbcs r10, r10, r9;
90
91 teq r2, #0;
92 stm r0!, {r4, r6, r8, r10};
93 bne .Large_loop;
94
95 .Lend:
96 it cc
97 movcc r2, #1;
98 add r0, lr, r2;
99 pop {r4, r5, r6, r8, r9, r10, pc};
100 .size _gcry_mpih_submul_1,.-_gcry_mpih_submul_1;