comparison nss/lib/freebl/mpi/mpi_arm.c @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 /* This inlined version is for 32-bit ARM platform only */
6
7 #if !defined(__arm__)
8 #error "This is for ARM only"
9 #endif
10
11 /* 16-bit thumb doesn't work inlined assember version */
12 #if (!defined(__thumb__) || defined(__thumb2__)) && !defined(__ARM_ARCH_3__)
13
14 #include "mpi-priv.h"
15
16 #ifdef MP_ASSEMBLY_MULTIPLY
17 void s_mpv_mul_d(const mp_digit *a, mp_size a_len, mp_digit b, mp_digit *c)
18 {
19 __asm__ __volatile__(
20 "mov r5, #0\n"
21 #ifdef __thumb2__
22 "cbz %1, 2f\n"
23 #else
24 "cmp %1, r5\n" /* r5 is 0 now */
25 "beq 2f\n"
26 #endif
27
28 "1:\n"
29 "mov r4, #0\n"
30 "ldr r6, [%0], #4\n"
31 "umlal r5, r4, r6, %2\n"
32 "str r5, [%3], #4\n"
33 "mov r5, r4\n"
34
35 "subs %1, #1\n"
36 "bne 1b\n"
37
38 "2:\n"
39 "str r5, [%3]\n"
40 :
41 : "r"(a), "r"(a_len), "r"(b), "r"(c)
42 : "memory", "cc", "%r4", "%r5", "%r6");
43 }
44
45 void s_mpv_mul_d_add(const mp_digit *a, mp_size a_len, mp_digit b, mp_digit *c)
46 {
47 __asm__ __volatile__(
48 "mov r5, #0\n"
49 #ifdef __thumb2__
50 "cbz %1, 2f\n"
51 #else
52 "cmp %1, r5\n" /* r5 is 0 now */
53 "beq 2f\n"
54 #endif
55
56 "1:\n"
57 "mov r4, #0\n"
58 "ldr r6, [%3]\n"
59 "adds r5, r6\n"
60 "adc r4, r4, #0\n"
61
62 "ldr r6, [%0], #4\n"
63 "umlal r5, r4, r6, %2\n"
64 "str r5, [%3], #4\n"
65 "mov r5, r4\n"
66
67 "subs %1, #1\n"
68 "bne 1b\n"
69
70 "2:\n"
71 "str r5, [%3]\n"
72 :
73 : "r"(a), "r"(a_len), "r"(b), "r"(c)
74 : "memory", "cc", "%r4", "%r5", "%r6");
75 }
76
77 void s_mpv_mul_d_add_prop(const mp_digit *a, mp_size a_len, mp_digit b, mp_digit *c)
78 {
79 if (!a_len)
80 return;
81
82 __asm__ __volatile__(
83 "mov r5, #0\n"
84
85 "1:\n"
86 "mov r4, #0\n"
87 "ldr r6, [%3]\n"
88 "adds r5, r6\n"
89 "adc r4, r4, #0\n"
90 "ldr r6, [%0], #4\n"
91 "umlal r5, r4, r6, %2\n"
92 "str r5, [%3], #4\n"
93 "mov r5, r4\n"
94
95 "subs %1, #1\n"
96 "bne 1b\n"
97
98 #ifdef __thumb2__
99 "cbz r4, 3f\n"
100 #else
101 "cmp r4, #0\n"
102 "beq 3f\n"
103 #endif
104
105 "2:\n"
106 "mov r4, #0\n"
107 "ldr r6, [%3]\n"
108 "adds r5, r6\n"
109 "adc r4, r4, #0\n"
110 "str r5, [%3], #4\n"
111 "movs r5, r4\n"
112 "bne 2b\n"
113
114 "3:\n"
115 :
116 : "r"(a), "r"(a_len), "r"(b), "r"(c)
117 : "memory", "cc", "%r4", "%r5", "%r6");
118 }
119 #endif
120
121 #ifdef MP_ASSEMBLY_SQUARE
122 void s_mpv_sqr_add_prop(const mp_digit *pa, mp_size a_len, mp_digit *ps)
123 {
124 if (!a_len)
125 return;
126
127 __asm__ __volatile__(
128 "mov r3, #0\n"
129
130 "1:\n"
131 "mov r4, #0\n"
132 "ldr r6, [%0], #4\n"
133 "ldr r5, [%2]\n"
134 "adds r3, r5\n"
135 "adc r4, r4, #0\n"
136 "umlal r3, r4, r6, r6\n" /* w = r3:r4 */
137 "str r3, [%2], #4\n"
138
139 "ldr r5, [%2]\n"
140 "adds r3, r4, r5\n"
141 "mov r4, #0\n"
142 "adc r4, r4, #0\n"
143 "str r3, [%2], #4\n"
144 "mov r3, r4\n"
145
146 "subs %1, #1\n"
147 "bne 1b\n"
148
149 #ifdef __thumb2__
150 "cbz r3, 3f\n"
151 #else
152 "cmp r3, #0\n"
153 "beq 3f\n"
154 #endif
155
156 "2:\n"
157 "mov r4, #0\n"
158 "ldr r5, [%2]\n"
159 "adds r3, r5\n"
160 "adc r4, r4, #0\n"
161 "str r3, [%2], #4\n"
162 "movs r3, r4\n"
163 "bne 2b\n"
164
165 "3:"
166 :
167 : "r"(pa), "r"(a_len), "r"(ps)
168 : "memory", "cc", "%r3", "%r4", "%r5", "%r6");
169 }
170 #endif
171 #endif
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)