xref: /btstack/3rd-party/micro-ecc/asm_arm.inc (revision af03003c8ac55cf0eea9563b597879b24aee256f)
1*af03003cSMatthias Ringwald#define DEC_5 4
2*af03003cSMatthias Ringwald#define DEC_6 5
3*af03003cSMatthias Ringwald#define DEC_7 6
4*af03003cSMatthias Ringwald#define DEC_8 7
5*af03003cSMatthias Ringwald
6*af03003cSMatthias Ringwald#define DEC(N) uECC_CONCAT(DEC_, N)
7*af03003cSMatthias Ringwald
8*af03003cSMatthias Ringwald#define REPEAT_1(stuff) stuff
9*af03003cSMatthias Ringwald#define REPEAT_2(stuff) REPEAT_1(stuff) stuff
10*af03003cSMatthias Ringwald#define REPEAT_3(stuff) REPEAT_2(stuff) stuff
11*af03003cSMatthias Ringwald#define REPEAT_4(stuff) REPEAT_3(stuff) stuff
12*af03003cSMatthias Ringwald#define REPEAT_5(stuff) REPEAT_4(stuff) stuff
13*af03003cSMatthias Ringwald#define REPEAT_6(stuff) REPEAT_5(stuff) stuff
14*af03003cSMatthias Ringwald#define REPEAT_7(stuff) REPEAT_6(stuff) stuff
15*af03003cSMatthias Ringwald#define REPEAT_8(stuff) REPEAT_7(stuff) stuff
16*af03003cSMatthias Ringwald
17*af03003cSMatthias Ringwald#define REPEAT(N, stuff) uECC_CONCAT(REPEAT_, N)(stuff)
18*af03003cSMatthias Ringwald
19*af03003cSMatthias Ringwald#define STR2(thing) #thing
20*af03003cSMatthias Ringwald#define STR(thing) STR2(thing)
21*af03003cSMatthias Ringwald
22*af03003cSMatthias Ringwald#if (uECC_ASM == uECC_asm_fast)
23*af03003cSMatthias Ringwald
24*af03003cSMatthias Ringwaldstatic uint32_t vli_add(uint32_t *result, const uint32_t *left, const uint32_t *right) {
25*af03003cSMatthias Ringwald    uint32_t carry = 0;
26*af03003cSMatthias Ringwald    uint32_t left_word;
27*af03003cSMatthias Ringwald    uint32_t right_word;
28*af03003cSMatthias Ringwald
29*af03003cSMatthias Ringwald    __asm__ volatile (
30*af03003cSMatthias Ringwald        ".syntax unified \n\t"
31*af03003cSMatthias Ringwald        "ldmia %[lptr]!, {%[left]} \n\t"  /* Load left word. */
32*af03003cSMatthias Ringwald        "ldmia %[rptr]!, {%[right]} \n\t" /* Load right word. */
33*af03003cSMatthias Ringwald        "adds %[left], %[right] \n\t"     /* Add first word. */
34*af03003cSMatthias Ringwald        "stmia %[dptr]!, {%[left]} \n\t"  /* Store result word. */
35*af03003cSMatthias Ringwald
36*af03003cSMatthias Ringwald        /* Now we just do the remaining words with the carry bit (using ADC) */
37*af03003cSMatthias Ringwald        REPEAT(DEC(uECC_WORDS),
38*af03003cSMatthias Ringwald            "ldmia %[lptr]!, {%[left]} \n\t"
39*af03003cSMatthias Ringwald            "ldmia %[rptr]!, {%[right]} \n\t"
40*af03003cSMatthias Ringwald            "adcs %[left], %[right] \n\t"
41*af03003cSMatthias Ringwald            "stmia %[dptr]!, {%[left]} \n\t")
42*af03003cSMatthias Ringwald
43*af03003cSMatthias Ringwald        "adcs %[carry], %[carry] \n\t" /* Store carry bit. */
44*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
45*af03003cSMatthias Ringwald        ".syntax divided \n\t"
46*af03003cSMatthias Ringwald    #endif
47*af03003cSMatthias Ringwald    #if (uECC_PLATFORM == uECC_arm_thumb)
48*af03003cSMatthias Ringwald        : [dptr] "+l" (result), [lptr] "+l" (left), [rptr] "+l" (right),
49*af03003cSMatthias Ringwald          [carry] "+l" (carry), [left] "=l" (left_word), [right] "=l" (right_word)
50*af03003cSMatthias Ringwald    #else
51*af03003cSMatthias Ringwald        : [dptr] "+r" (result), [lptr] "+r" (left), [rptr] "+r" (right),
52*af03003cSMatthias Ringwald          [carry] "+r" (carry), [left] "=r" (left_word), [right] "=r" (right_word)
53*af03003cSMatthias Ringwald    #endif
54*af03003cSMatthias Ringwald        :
55*af03003cSMatthias Ringwald        : "cc", "memory"
56*af03003cSMatthias Ringwald    );
57*af03003cSMatthias Ringwald    return carry;
58*af03003cSMatthias Ringwald}
59*af03003cSMatthias Ringwald#define asm_add 1
60*af03003cSMatthias Ringwald
61*af03003cSMatthias Ringwaldstatic uint32_t vli_sub(uint32_t *result, const uint32_t *left, const uint32_t *right) {
62*af03003cSMatthias Ringwald    uint32_t carry = 0;
63*af03003cSMatthias Ringwald    uint32_t left_word;
64*af03003cSMatthias Ringwald    uint32_t right_word;
65*af03003cSMatthias Ringwald
66*af03003cSMatthias Ringwald    __asm__ volatile (
67*af03003cSMatthias Ringwald        ".syntax unified \n\t"
68*af03003cSMatthias Ringwald        "ldmia %[lptr]!, {%[left]} \n\t"  /* Load left word. */
69*af03003cSMatthias Ringwald        "ldmia %[rptr]!, {%[right]} \n\t" /* Load right word. */
70*af03003cSMatthias Ringwald        "subs %[left], %[right] \n\t"     /* Subtract. */
71*af03003cSMatthias Ringwald        "stmia %[dptr]!, {%[left]} \n\t"  /* Store result word. */
72*af03003cSMatthias Ringwald
73*af03003cSMatthias Ringwald        /* Now we just do the remaining words with the carry bit (using SBC) */
74*af03003cSMatthias Ringwald        REPEAT(DEC(uECC_WORDS),
75*af03003cSMatthias Ringwald            "ldmia %[lptr]!, {%[left]} \n\t"
76*af03003cSMatthias Ringwald            "ldmia %[rptr]!, {%[right]} \n\t"
77*af03003cSMatthias Ringwald            "sbcs %[left], %[right] \n\t"
78*af03003cSMatthias Ringwald            "stmia %[dptr]!, {%[left]} \n\t")
79*af03003cSMatthias Ringwald
80*af03003cSMatthias Ringwald        "adcs %[carry], %[carry] \n\t" /* Store carry bit. */
81*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
82*af03003cSMatthias Ringwald        ".syntax divided \n\t"
83*af03003cSMatthias Ringwald    #endif
84*af03003cSMatthias Ringwald    #if (uECC_PLATFORM == uECC_arm_thumb)
85*af03003cSMatthias Ringwald        : [dptr] "+l" (result), [lptr] "+l" (left), [rptr] "+l" (right),
86*af03003cSMatthias Ringwald          [carry] "+l" (carry), [left] "=l" (left_word), [right] "=l" (right_word)
87*af03003cSMatthias Ringwald    #else
88*af03003cSMatthias Ringwald        : [dptr] "+r" (result), [lptr] "+r" (left), [rptr] "+r" (right),
89*af03003cSMatthias Ringwald          [carry] "+r" (carry), [left] "=r" (left_word), [right] "=r" (right_word)
90*af03003cSMatthias Ringwald    #endif
91*af03003cSMatthias Ringwald        :
92*af03003cSMatthias Ringwald        : "cc", "memory"
93*af03003cSMatthias Ringwald    );
94*af03003cSMatthias Ringwald    return !carry; // note that on ARM, carry flag set means "no borrow" when subtracting
95*af03003cSMatthias Ringwald                   // (for some reason...)
96*af03003cSMatthias Ringwald}
97*af03003cSMatthias Ringwald#define asm_sub 1
98*af03003cSMatthias Ringwald
99*af03003cSMatthias Ringwald#if (uECC_PLATFORM != uECC_arm_thumb)
100*af03003cSMatthias Ringwald#if (uECC_WORDS == 5)
101*af03003cSMatthias Ringwaldstatic void vli_mult(uint32_t *result, const uint32_t *left, const uint32_t *right) {
102*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
103*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
104*af03003cSMatthias Ringwald    register const uint32_t *r2 __asm__("r2") = right;
105*af03003cSMatthias Ringwald
106*af03003cSMatthias Ringwald    __asm__ volatile (
107*af03003cSMatthias Ringwald        ".syntax unified \n\t"
108*af03003cSMatthias Ringwald        "add r0, 12 \n\t"
109*af03003cSMatthias Ringwald        "add r2, 12 \n\t"
110*af03003cSMatthias Ringwald        "ldmia r1!, {r3,r4} \n\t"
111*af03003cSMatthias Ringwald        "ldmia r2!, {r6,r7} \n\t"
112*af03003cSMatthias Ringwald
113*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
114*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
115*af03003cSMatthias Ringwald
116*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
117*af03003cSMatthias Ringwald        "umull r11, r9, r3, r7 \n\t"
118*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
119*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
120*af03003cSMatthias Ringwald        "umull r11, r14, r4, r6 \n\t"
121*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
122*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
123*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
124*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
125*af03003cSMatthias Ringwald
126*af03003cSMatthias Ringwald        "umull r12, r14, r4, r7 \n\t"
127*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
128*af03003cSMatthias Ringwald        "adc r10, r14 \n\t"
129*af03003cSMatthias Ringwald        "stmia r0!, {r9, r10} \n\t"
130*af03003cSMatthias Ringwald
131*af03003cSMatthias Ringwald        "sub r0, 28 \n\t"
132*af03003cSMatthias Ringwald        "sub r2, 20 \n\t"
133*af03003cSMatthias Ringwald        "ldmia r2!, {r6,r7,r8} \n\t"
134*af03003cSMatthias Ringwald        "ldmia r1!, {r5} \n\t"
135*af03003cSMatthias Ringwald
136*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
137*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
138*af03003cSMatthias Ringwald
139*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
140*af03003cSMatthias Ringwald        "umull r11, r9, r3, r7 \n\t"
141*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
142*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
143*af03003cSMatthias Ringwald        "umull r11, r14, r4, r6 \n\t"
144*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
145*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
146*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
147*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
148*af03003cSMatthias Ringwald
149*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
150*af03003cSMatthias Ringwald        "umull r12, r14, r3, r8 \n\t"
151*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
152*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
153*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
154*af03003cSMatthias Ringwald        "umull r12, r14, r4, r7 \n\t"
155*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
156*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
157*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
158*af03003cSMatthias Ringwald        "umull r12, r14, r5, r6 \n\t"
159*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
160*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
161*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
162*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
163*af03003cSMatthias Ringwald
164*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
165*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
166*af03003cSMatthias Ringwald        "umull r14, r9, r4, r8 \n\t"
167*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
168*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
169*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
170*af03003cSMatthias Ringwald        "umull r14, r9, r5, r7 \n\t"
171*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
172*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
173*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
174*af03003cSMatthias Ringwald        "umull r14, r9, r3, r6 \n\t"
175*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
176*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
177*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
178*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
179*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
180*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
181*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
182*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
183*af03003cSMatthias Ringwald
184*af03003cSMatthias Ringwald        "ldmia r1!, {r4} \n\t"
185*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
186*af03003cSMatthias Ringwald        "umull r9, r10, r5, r8 \n\t"
187*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
188*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
189*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
190*af03003cSMatthias Ringwald        "umull r9, r10, r3, r7 \n\t"
191*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
192*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
193*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
194*af03003cSMatthias Ringwald        "umull r9, r10, r4, r6 \n\t"
195*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
196*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
197*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
198*af03003cSMatthias Ringwald        "ldr r9, [r0] \n\t"
199*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
200*af03003cSMatthias Ringwald        "adcs r12, #0 \n\t"
201*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
202*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
203*af03003cSMatthias Ringwald
204*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
205*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
206*af03003cSMatthias Ringwald        "umull r10, r11, r5, r6 \n\t"
207*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
208*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
209*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
210*af03003cSMatthias Ringwald        "umull r10, r11, r3, r8 \n\t"
211*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
212*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
213*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
214*af03003cSMatthias Ringwald        "umull r10, r11, r4, r7 \n\t"
215*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
216*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
217*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
218*af03003cSMatthias Ringwald        "ldr r10, [r0] \n\t"
219*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
220*af03003cSMatthias Ringwald        "adcs r14, #0 \n\t"
221*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
222*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
223*af03003cSMatthias Ringwald
224*af03003cSMatthias Ringwald        "ldmia r2!, {r7} \n\t"
225*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
226*af03003cSMatthias Ringwald        "umull r11, r12, r5, r7 \n\t"
227*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
228*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
229*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
230*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
231*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
232*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
233*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
234*af03003cSMatthias Ringwald        "umull r11, r12, r4, r8 \n\t"
235*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
236*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
237*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
238*af03003cSMatthias Ringwald        "ldr r11, [r0] \n\t"
239*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
240*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
241*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
242*af03003cSMatthias Ringwald        "stmia r0!, {r14} \n\t"
243*af03003cSMatthias Ringwald
244*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
245*af03003cSMatthias Ringwald        "umull r12, r14, r3, r7 \n\t"
246*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
247*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
248*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
249*af03003cSMatthias Ringwald        "umull r12, r14, r4, r6 \n\t"
250*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
251*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
252*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
253*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
254*af03003cSMatthias Ringwald
255*af03003cSMatthias Ringwald        "umull r14, r9, r4, r7 \n\t"
256*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
257*af03003cSMatthias Ringwald        "adc r11, r9 \n\t"
258*af03003cSMatthias Ringwald        "stmia r0!, {r10, r11} \n\t"
259*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
260*af03003cSMatthias Ringwald        ".syntax divided \n\t"
261*af03003cSMatthias Ringwald    #endif
262*af03003cSMatthias Ringwald        : "+r" (r0), "+r" (r1), "+r" (r2)
263*af03003cSMatthias Ringwald        :
264*af03003cSMatthias Ringwald        : "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory"
265*af03003cSMatthias Ringwald    );
266*af03003cSMatthias Ringwald}
267*af03003cSMatthias Ringwald#define asm_mult 1
268*af03003cSMatthias Ringwald#endif /* (uECC_WORDS == 5) */
269*af03003cSMatthias Ringwald
270*af03003cSMatthias Ringwald#if (uECC_WORDS == 6)
271*af03003cSMatthias Ringwaldstatic void vli_mult(uint32_t *result, const uint32_t *left, const uint32_t *right) {
272*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
273*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
274*af03003cSMatthias Ringwald    register const uint32_t *r2 __asm__("r2") = right;
275*af03003cSMatthias Ringwald
276*af03003cSMatthias Ringwald    __asm__ volatile (
277*af03003cSMatthias Ringwald        ".syntax unified \n\t"
278*af03003cSMatthias Ringwald        "add r0, 12 \n\t"
279*af03003cSMatthias Ringwald        "add r2, 12 \n\t"
280*af03003cSMatthias Ringwald        "ldmia r1!, {r3,r4,r5} \n\t"
281*af03003cSMatthias Ringwald        "ldmia r2!, {r6,r7,r8} \n\t"
282*af03003cSMatthias Ringwald
283*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
284*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
285*af03003cSMatthias Ringwald
286*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
287*af03003cSMatthias Ringwald        "umull r11, r9, r3, r7 \n\t"
288*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
289*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
290*af03003cSMatthias Ringwald        "umull r11, r14, r4, r6 \n\t"
291*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
292*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
293*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
294*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
295*af03003cSMatthias Ringwald
296*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
297*af03003cSMatthias Ringwald        "umull r12, r14, r3, r8 \n\t"
298*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
299*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
300*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
301*af03003cSMatthias Ringwald        "umull r12, r14, r4, r7 \n\t"
302*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
303*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
304*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
305*af03003cSMatthias Ringwald        "umull r12, r14, r5, r6 \n\t"
306*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
307*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
308*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
309*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
310*af03003cSMatthias Ringwald
311*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
312*af03003cSMatthias Ringwald        "umull r14, r9, r4, r8 \n\t"
313*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
314*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
315*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
316*af03003cSMatthias Ringwald        "umull r14, r9, r5, r7 \n\t"
317*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
318*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
319*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
320*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
321*af03003cSMatthias Ringwald
322*af03003cSMatthias Ringwald        "umull r9, r10, r5, r8 \n\t"
323*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
324*af03003cSMatthias Ringwald        "adc r12, r10 \n\t"
325*af03003cSMatthias Ringwald        "stmia r0!, {r11, r12} \n\t"
326*af03003cSMatthias Ringwald
327*af03003cSMatthias Ringwald        "sub r0, 36 \n\t"
328*af03003cSMatthias Ringwald        "sub r2, 24 \n\t"
329*af03003cSMatthias Ringwald        "ldmia r2!, {r6,r7,r8} \n\t"
330*af03003cSMatthias Ringwald
331*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
332*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
333*af03003cSMatthias Ringwald
334*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
335*af03003cSMatthias Ringwald        "umull r11, r9, r3, r7 \n\t"
336*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
337*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
338*af03003cSMatthias Ringwald        "umull r11, r14, r4, r6 \n\t"
339*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
340*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
341*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
342*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
343*af03003cSMatthias Ringwald
344*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
345*af03003cSMatthias Ringwald        "umull r12, r14, r3, r8 \n\t"
346*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
347*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
348*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
349*af03003cSMatthias Ringwald        "umull r12, r14, r4, r7 \n\t"
350*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
351*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
352*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
353*af03003cSMatthias Ringwald        "umull r12, r14, r5, r6 \n\t"
354*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
355*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
356*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
357*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
358*af03003cSMatthias Ringwald
359*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
360*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
361*af03003cSMatthias Ringwald        "umull r14, r9, r4, r8 \n\t"
362*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
363*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
364*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
365*af03003cSMatthias Ringwald        "umull r14, r9, r5, r7 \n\t"
366*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
367*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
368*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
369*af03003cSMatthias Ringwald        "umull r14, r9, r3, r6 \n\t"
370*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
371*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
372*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
373*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
374*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
375*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
376*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
377*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
378*af03003cSMatthias Ringwald
379*af03003cSMatthias Ringwald        "ldmia r1!, {r4} \n\t"
380*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
381*af03003cSMatthias Ringwald        "umull r9, r10, r5, r8 \n\t"
382*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
383*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
384*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
385*af03003cSMatthias Ringwald        "umull r9, r10, r3, r7 \n\t"
386*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
387*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
388*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
389*af03003cSMatthias Ringwald        "umull r9, r10, r4, r6 \n\t"
390*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
391*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
392*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
393*af03003cSMatthias Ringwald        "ldr r9, [r0] \n\t"
394*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
395*af03003cSMatthias Ringwald        "adcs r12, #0 \n\t"
396*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
397*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
398*af03003cSMatthias Ringwald
399*af03003cSMatthias Ringwald        "ldmia r1!, {r5} \n\t"
400*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
401*af03003cSMatthias Ringwald        "umull r10, r11, r3, r8 \n\t"
402*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
403*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
404*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
405*af03003cSMatthias Ringwald        "umull r10, r11, r4, r7 \n\t"
406*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
407*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
408*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
409*af03003cSMatthias Ringwald        "umull r10, r11, r5, r6 \n\t"
410*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
411*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
412*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
413*af03003cSMatthias Ringwald        "ldr r10, [r0] \n\t"
414*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
415*af03003cSMatthias Ringwald        "adcs r14, #0 \n\t"
416*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
417*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
418*af03003cSMatthias Ringwald
419*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
420*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
421*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
422*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
423*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
424*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
425*af03003cSMatthias Ringwald        "umull r11, r12, r4, r8 \n\t"
426*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
427*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
428*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
429*af03003cSMatthias Ringwald        "umull r11, r12, r5, r7 \n\t"
430*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
431*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
432*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
433*af03003cSMatthias Ringwald        "ldr r11, [r0] \n\t"
434*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
435*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
436*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
437*af03003cSMatthias Ringwald        "stmia r0!, {r14} \n\t"
438*af03003cSMatthias Ringwald
439*af03003cSMatthias Ringwald        "ldmia r2!, {r7} \n\t"
440*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
441*af03003cSMatthias Ringwald        "umull r12, r14, r3, r7 \n\t"
442*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
443*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
444*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
445*af03003cSMatthias Ringwald        "umull r12, r14, r4, r6 \n\t"
446*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
447*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
448*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
449*af03003cSMatthias Ringwald        "umull r12, r14, r5, r8 \n\t"
450*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
451*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
452*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
453*af03003cSMatthias Ringwald        "ldr r12, [r0] \n\t"
454*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
455*af03003cSMatthias Ringwald        "adcs r10, #0 \n\t"
456*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
457*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
458*af03003cSMatthias Ringwald
459*af03003cSMatthias Ringwald        "ldmia r2!, {r8} \n\t"
460*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
461*af03003cSMatthias Ringwald        "umull r14, r9, r3, r8 \n\t"
462*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
463*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
464*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
465*af03003cSMatthias Ringwald        "umull r14, r9, r4, r7 \n\t"
466*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
467*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
468*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
469*af03003cSMatthias Ringwald        "umull r14, r9, r5, r6 \n\t"
470*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
471*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
472*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
473*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
474*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
475*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
476*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
477*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
478*af03003cSMatthias Ringwald
479*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
480*af03003cSMatthias Ringwald        "umull r9, r10, r4, r8 \n\t"
481*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
482*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
483*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
484*af03003cSMatthias Ringwald        "umull r9, r10, r5, r7 \n\t"
485*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
486*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
487*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
488*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
489*af03003cSMatthias Ringwald
490*af03003cSMatthias Ringwald        "umull r10, r11, r5, r8 \n\t"
491*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
492*af03003cSMatthias Ringwald        "adc r14, r11 \n\t"
493*af03003cSMatthias Ringwald        "stmia r0!, {r12, r14} \n\t"
494*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
495*af03003cSMatthias Ringwald        ".syntax divided \n\t"
496*af03003cSMatthias Ringwald    #endif
497*af03003cSMatthias Ringwald        : "+r" (r0), "+r" (r1), "+r" (r2)
498*af03003cSMatthias Ringwald        :
499*af03003cSMatthias Ringwald        : "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory"
500*af03003cSMatthias Ringwald    );
501*af03003cSMatthias Ringwald}
502*af03003cSMatthias Ringwald#define asm_mult 1
503*af03003cSMatthias Ringwald#endif /* (uECC_WORDS == 6) */
504*af03003cSMatthias Ringwald
505*af03003cSMatthias Ringwald#if (uECC_WORDS == 7)
506*af03003cSMatthias Ringwaldstatic void vli_mult(uint32_t *result, const uint32_t *left, const uint32_t *right) {
507*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
508*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
509*af03003cSMatthias Ringwald    register const uint32_t *r2 __asm__("r2") = right;
510*af03003cSMatthias Ringwald
511*af03003cSMatthias Ringwald    __asm__ volatile (
512*af03003cSMatthias Ringwald        ".syntax unified \n\t"
513*af03003cSMatthias Ringwald        "add r0, 24 \n\t"
514*af03003cSMatthias Ringwald        "add r2, 24 \n\t"
515*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
516*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
517*af03003cSMatthias Ringwald
518*af03003cSMatthias Ringwald        "umull r9, r10, r3, r6 \n\t"
519*af03003cSMatthias Ringwald        "stmia r0!, {r9, r10} \n\t"
520*af03003cSMatthias Ringwald
521*af03003cSMatthias Ringwald        "sub r0, 20 \n\t"
522*af03003cSMatthias Ringwald        "sub r2, 16 \n\t"
523*af03003cSMatthias Ringwald        "ldmia r2!, {r6, r7, r8} \n\t"
524*af03003cSMatthias Ringwald        "ldmia r1!, {r4, r5} \n\t"
525*af03003cSMatthias Ringwald
526*af03003cSMatthias Ringwald        "umull r9, r10, r3, r6 \n\t"
527*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
528*af03003cSMatthias Ringwald
529*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
530*af03003cSMatthias Ringwald        "umull r9, r12, r3, r7 \n\t"
531*af03003cSMatthias Ringwald        "adds r10, r9 \n\t"
532*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
533*af03003cSMatthias Ringwald        "umull r9, r11, r4, r6 \n\t"
534*af03003cSMatthias Ringwald        "adds r10, r9 \n\t"
535*af03003cSMatthias Ringwald        "adcs r12, r11 \n\t"
536*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
537*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
538*af03003cSMatthias Ringwald
539*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
540*af03003cSMatthias Ringwald        "umull r10, r11, r3, r8 \n\t"
541*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
542*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
543*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
544*af03003cSMatthias Ringwald        "umull r10, r11, r4, r7 \n\t"
545*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
546*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
547*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
548*af03003cSMatthias Ringwald        "umull r10, r11, r5, r6 \n\t"
549*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
550*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
551*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
552*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
553*af03003cSMatthias Ringwald
554*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
555*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
556*af03003cSMatthias Ringwald        "umull r11, r12, r4, r8 \n\t"
557*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
558*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
559*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
560*af03003cSMatthias Ringwald        "umull r11, r12, r5, r7 \n\t"
561*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
562*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
563*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
564*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
565*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
566*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
567*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
568*af03003cSMatthias Ringwald        "ldr r11, [r0] \n\t"
569*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
570*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
571*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
572*af03003cSMatthias Ringwald        "stmia r0!, {r14} \n\t"
573*af03003cSMatthias Ringwald
574*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
575*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
576*af03003cSMatthias Ringwald        "umull r12, r14, r4, r6 \n\t"
577*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
578*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
579*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
580*af03003cSMatthias Ringwald        "umull r12, r14, r5, r8 \n\t"
581*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
582*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
583*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
584*af03003cSMatthias Ringwald        "umull r12, r14, r3, r7 \n\t"
585*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
586*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
587*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
588*af03003cSMatthias Ringwald        "ldr r12, [r0] \n\t"
589*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
590*af03003cSMatthias Ringwald        "adcs r10, #0 \n\t"
591*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
592*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
593*af03003cSMatthias Ringwald
594*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
595*af03003cSMatthias Ringwald        "umull r14, r9, r5, r6 \n\t"
596*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
597*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
598*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
599*af03003cSMatthias Ringwald        "umull r14, r9, r3, r8 \n\t"
600*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
601*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
602*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
603*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
604*af03003cSMatthias Ringwald
605*af03003cSMatthias Ringwald        "umull r9, r10, r3, r6 \n\t"
606*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
607*af03003cSMatthias Ringwald        "adc r12, r10 \n\t"
608*af03003cSMatthias Ringwald        "stmia r0!, {r11, r12} \n\t"
609*af03003cSMatthias Ringwald
610*af03003cSMatthias Ringwald        "sub r0, 44 \n\t"
611*af03003cSMatthias Ringwald        "sub r1, 16 \n\t"
612*af03003cSMatthias Ringwald        "sub r2, 28 \n\t"
613*af03003cSMatthias Ringwald        "ldmia r1!, {r3,r4,r5} \n\t"
614*af03003cSMatthias Ringwald        "ldmia r2!, {r6,r7,r8} \n\t"
615*af03003cSMatthias Ringwald
616*af03003cSMatthias Ringwald        "umull r9, r10, r3, r6 \n\t"
617*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
618*af03003cSMatthias Ringwald
619*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
620*af03003cSMatthias Ringwald        "umull r9, r12, r3, r7 \n\t"
621*af03003cSMatthias Ringwald        "adds r10, r9 \n\t"
622*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
623*af03003cSMatthias Ringwald        "umull r9, r11, r4, r6 \n\t"
624*af03003cSMatthias Ringwald        "adds r10, r9 \n\t"
625*af03003cSMatthias Ringwald        "adcs r12, r11 \n\t"
626*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
627*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
628*af03003cSMatthias Ringwald
629*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
630*af03003cSMatthias Ringwald        "umull r10, r11, r3, r8 \n\t"
631*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
632*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
633*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
634*af03003cSMatthias Ringwald        "umull r10, r11, r4, r7 \n\t"
635*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
636*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
637*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
638*af03003cSMatthias Ringwald        "umull r10, r11, r5, r6 \n\t"
639*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
640*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
641*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
642*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
643*af03003cSMatthias Ringwald
644*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
645*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
646*af03003cSMatthias Ringwald        "umull r11, r12, r4, r8 \n\t"
647*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
648*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
649*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
650*af03003cSMatthias Ringwald        "umull r11, r12, r5, r7 \n\t"
651*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
652*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
653*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
654*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
655*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
656*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
657*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
658*af03003cSMatthias Ringwald        "ldr r11, [r0] \n\t"
659*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
660*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
661*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
662*af03003cSMatthias Ringwald        "stmia r0!, {r14} \n\t"
663*af03003cSMatthias Ringwald
664*af03003cSMatthias Ringwald        "ldmia r1!, {r4} \n\t"
665*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
666*af03003cSMatthias Ringwald        "umull r12, r14, r5, r8 \n\t"
667*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
668*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
669*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
670*af03003cSMatthias Ringwald        "umull r12, r14, r3, r7 \n\t"
671*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
672*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
673*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
674*af03003cSMatthias Ringwald        "umull r12, r14, r4, r6 \n\t"
675*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
676*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
677*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
678*af03003cSMatthias Ringwald        "ldr r12, [r0] \n\t"
679*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
680*af03003cSMatthias Ringwald        "adcs r10, #0 \n\t"
681*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
682*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
683*af03003cSMatthias Ringwald
684*af03003cSMatthias Ringwald        "ldmia r1!, {r5} \n\t"
685*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
686*af03003cSMatthias Ringwald        "umull r14, r9, r3, r8 \n\t"
687*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
688*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
689*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
690*af03003cSMatthias Ringwald        "umull r14, r9, r4, r7 \n\t"
691*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
692*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
693*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
694*af03003cSMatthias Ringwald        "umull r14, r9, r5, r6 \n\t"
695*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
696*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
697*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
698*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
699*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
700*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
701*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
702*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
703*af03003cSMatthias Ringwald
704*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
705*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
706*af03003cSMatthias Ringwald        "umull r9, r10, r4, r8 \n\t"
707*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
708*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
709*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
710*af03003cSMatthias Ringwald        "umull r9, r10, r5, r7 \n\t"
711*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
712*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
713*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
714*af03003cSMatthias Ringwald        "umull r9, r10, r3, r6 \n\t"
715*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
716*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
717*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
718*af03003cSMatthias Ringwald        "ldr r9, [r0] \n\t"
719*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
720*af03003cSMatthias Ringwald        "adcs r12, #0 \n\t"
721*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
722*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
723*af03003cSMatthias Ringwald
724*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
725*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
726*af03003cSMatthias Ringwald        "umull r10, r11, r4, r6 \n\t"
727*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
728*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
729*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
730*af03003cSMatthias Ringwald        "umull r10, r11, r5, r8 \n\t"
731*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
732*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
733*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
734*af03003cSMatthias Ringwald        "umull r10, r11, r3, r7 \n\t"
735*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
736*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
737*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
738*af03003cSMatthias Ringwald        "ldr r10, [r0] \n\t"
739*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
740*af03003cSMatthias Ringwald        "adcs r14, #0 \n\t"
741*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
742*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
743*af03003cSMatthias Ringwald
744*af03003cSMatthias Ringwald        "ldmia r2!, {r7} \n\t"
745*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
746*af03003cSMatthias Ringwald        "umull r11, r12, r4, r7 \n\t"
747*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
748*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
749*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
750*af03003cSMatthias Ringwald        "umull r11, r12, r5, r6 \n\t"
751*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
752*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
753*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
754*af03003cSMatthias Ringwald        "umull r11, r12, r3, r8 \n\t"
755*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
756*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
757*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
758*af03003cSMatthias Ringwald        "ldr r11, [r0] \n\t"
759*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
760*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
761*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
762*af03003cSMatthias Ringwald        "stmia r0!, {r14} \n\t"
763*af03003cSMatthias Ringwald
764*af03003cSMatthias Ringwald        "ldmia r2!, {r8} \n\t"
765*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
766*af03003cSMatthias Ringwald        "umull r12, r14, r4, r8 \n\t"
767*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
768*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
769*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
770*af03003cSMatthias Ringwald        "umull r12, r14, r5, r7 \n\t"
771*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
772*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
773*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
774*af03003cSMatthias Ringwald        "umull r12, r14, r3, r6 \n\t"
775*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
776*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
777*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
778*af03003cSMatthias Ringwald        "ldr r12, [r0] \n\t"
779*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
780*af03003cSMatthias Ringwald        "adcs r10, #0 \n\t"
781*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
782*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
783*af03003cSMatthias Ringwald
784*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
785*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
786*af03003cSMatthias Ringwald        "umull r14, r9, r4, r6 \n\t"
787*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
788*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
789*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
790*af03003cSMatthias Ringwald        "umull r14, r9, r5, r8 \n\t"
791*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
792*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
793*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
794*af03003cSMatthias Ringwald        "umull r14, r9, r3, r7 \n\t"
795*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
796*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
797*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
798*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
799*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
800*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
801*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
802*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
803*af03003cSMatthias Ringwald
804*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
805*af03003cSMatthias Ringwald        "umull r9, r10, r5, r6 \n\t"
806*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
807*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
808*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
809*af03003cSMatthias Ringwald        "umull r9, r10, r3, r8 \n\t"
810*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
811*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
812*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
813*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
814*af03003cSMatthias Ringwald
815*af03003cSMatthias Ringwald        "umull r10, r11, r3, r6 \n\t"
816*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
817*af03003cSMatthias Ringwald        "adc r14, r11 \n\t"
818*af03003cSMatthias Ringwald        "stmia r0!, {r12, r14} \n\t"
819*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
820*af03003cSMatthias Ringwald        ".syntax divided \n\t"
821*af03003cSMatthias Ringwald    #endif
822*af03003cSMatthias Ringwald        : "+r" (r0), "+r" (r1), "+r" (r2)
823*af03003cSMatthias Ringwald        :
824*af03003cSMatthias Ringwald        : "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory"
825*af03003cSMatthias Ringwald    );
826*af03003cSMatthias Ringwald}
827*af03003cSMatthias Ringwald#define asm_mult 1
828*af03003cSMatthias Ringwald#endif /* (uECC_WORDS == 7) */
829*af03003cSMatthias Ringwald
830*af03003cSMatthias Ringwald#if (uECC_WORDS == 8)
831*af03003cSMatthias Ringwaldstatic void vli_mult(uint32_t *result, const uint32_t *left, const uint32_t *right) {
832*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
833*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
834*af03003cSMatthias Ringwald    register const uint32_t *r2 __asm__("r2") = right;
835*af03003cSMatthias Ringwald
836*af03003cSMatthias Ringwald    __asm__ volatile (
837*af03003cSMatthias Ringwald        ".syntax unified \n\t"
838*af03003cSMatthias Ringwald        "add r0, 24 \n\t"
839*af03003cSMatthias Ringwald        "add r2, 24 \n\t"
840*af03003cSMatthias Ringwald        "ldmia r1!, {r3,r4} \n\t"
841*af03003cSMatthias Ringwald        "ldmia r2!, {r6,r7} \n\t"
842*af03003cSMatthias Ringwald
843*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
844*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
845*af03003cSMatthias Ringwald
846*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
847*af03003cSMatthias Ringwald        "umull r11, r9, r3, r7 \n\t"
848*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
849*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
850*af03003cSMatthias Ringwald        "umull r11, r14, r4, r6 \n\t"
851*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
852*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
853*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
854*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
855*af03003cSMatthias Ringwald
856*af03003cSMatthias Ringwald        "umull r12, r14, r4, r7 \n\t"
857*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
858*af03003cSMatthias Ringwald        "adc r10, r14 \n\t"
859*af03003cSMatthias Ringwald        "stmia r0!, {r9, r10} \n\t"
860*af03003cSMatthias Ringwald
861*af03003cSMatthias Ringwald        "sub r0, 28 \n\t"
862*af03003cSMatthias Ringwald        "sub r2, 20 \n\t"
863*af03003cSMatthias Ringwald        "ldmia r2!, {r6,r7,r8} \n\t"
864*af03003cSMatthias Ringwald        "ldmia r1!, {r5} \n\t"
865*af03003cSMatthias Ringwald
866*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
867*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
868*af03003cSMatthias Ringwald
869*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
870*af03003cSMatthias Ringwald        "umull r11, r9, r3, r7 \n\t"
871*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
872*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
873*af03003cSMatthias Ringwald        "umull r11, r14, r4, r6 \n\t"
874*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
875*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
876*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
877*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
878*af03003cSMatthias Ringwald
879*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
880*af03003cSMatthias Ringwald        "umull r12, r14, r3, r8 \n\t"
881*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
882*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
883*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
884*af03003cSMatthias Ringwald        "umull r12, r14, r4, r7 \n\t"
885*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
886*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
887*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
888*af03003cSMatthias Ringwald        "umull r12, r14, r5, r6 \n\t"
889*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
890*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
891*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
892*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
893*af03003cSMatthias Ringwald
894*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
895*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
896*af03003cSMatthias Ringwald        "umull r14, r9, r4, r8 \n\t"
897*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
898*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
899*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
900*af03003cSMatthias Ringwald        "umull r14, r9, r5, r7 \n\t"
901*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
902*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
903*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
904*af03003cSMatthias Ringwald        "umull r14, r9, r3, r6 \n\t"
905*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
906*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
907*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
908*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
909*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
910*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
911*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
912*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
913*af03003cSMatthias Ringwald
914*af03003cSMatthias Ringwald        "ldmia r1!, {r4} \n\t"
915*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
916*af03003cSMatthias Ringwald        "umull r9, r10, r5, r8 \n\t"
917*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
918*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
919*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
920*af03003cSMatthias Ringwald        "umull r9, r10, r3, r7 \n\t"
921*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
922*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
923*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
924*af03003cSMatthias Ringwald        "umull r9, r10, r4, r6 \n\t"
925*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
926*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
927*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
928*af03003cSMatthias Ringwald        "ldr r9, [r0] \n\t"
929*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
930*af03003cSMatthias Ringwald        "adcs r12, #0 \n\t"
931*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
932*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
933*af03003cSMatthias Ringwald
934*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
935*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
936*af03003cSMatthias Ringwald        "umull r10, r11, r5, r6 \n\t"
937*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
938*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
939*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
940*af03003cSMatthias Ringwald        "umull r10, r11, r3, r8 \n\t"
941*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
942*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
943*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
944*af03003cSMatthias Ringwald        "umull r10, r11, r4, r7 \n\t"
945*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
946*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
947*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
948*af03003cSMatthias Ringwald        "ldr r10, [r0] \n\t"
949*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
950*af03003cSMatthias Ringwald        "adcs r14, #0 \n\t"
951*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
952*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
953*af03003cSMatthias Ringwald
954*af03003cSMatthias Ringwald        "ldmia r2!, {r7} \n\t"
955*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
956*af03003cSMatthias Ringwald        "umull r11, r12, r5, r7 \n\t"
957*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
958*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
959*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
960*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
961*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
962*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
963*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
964*af03003cSMatthias Ringwald        "umull r11, r12, r4, r8 \n\t"
965*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
966*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
967*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
968*af03003cSMatthias Ringwald        "ldr r11, [r0] \n\t"
969*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
970*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
971*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
972*af03003cSMatthias Ringwald        "stmia r0!, {r14} \n\t"
973*af03003cSMatthias Ringwald
974*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
975*af03003cSMatthias Ringwald        "umull r12, r14, r3, r7 \n\t"
976*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
977*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
978*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
979*af03003cSMatthias Ringwald        "umull r12, r14, r4, r6 \n\t"
980*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
981*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
982*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
983*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
984*af03003cSMatthias Ringwald
985*af03003cSMatthias Ringwald        "umull r14, r9, r4, r7 \n\t"
986*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
987*af03003cSMatthias Ringwald        "adc r11, r9 \n\t"
988*af03003cSMatthias Ringwald        "stmia r0!, {r10, r11} \n\t"
989*af03003cSMatthias Ringwald
990*af03003cSMatthias Ringwald        "sub r0, 52 \n\t"
991*af03003cSMatthias Ringwald        "sub r1, 20 \n\t"
992*af03003cSMatthias Ringwald        "sub r2, 32 \n\t"
993*af03003cSMatthias Ringwald        "ldmia r1!, {r3,r4,r5} \n\t"
994*af03003cSMatthias Ringwald        "ldmia r2!, {r6,r7,r8} \n\t"
995*af03003cSMatthias Ringwald
996*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
997*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
998*af03003cSMatthias Ringwald
999*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1000*af03003cSMatthias Ringwald        "umull r11, r9, r3, r7 \n\t"
1001*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
1002*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1003*af03003cSMatthias Ringwald        "umull r11, r14, r4, r6 \n\t"
1004*af03003cSMatthias Ringwald        "adds r12, r11 \n\t"
1005*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
1006*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1007*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1008*af03003cSMatthias Ringwald
1009*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
1010*af03003cSMatthias Ringwald        "umull r12, r14, r3, r8 \n\t"
1011*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1012*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1013*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1014*af03003cSMatthias Ringwald        "umull r12, r14, r4, r7 \n\t"
1015*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1016*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1017*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1018*af03003cSMatthias Ringwald        "umull r12, r14, r5, r6 \n\t"
1019*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1020*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1021*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1022*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
1023*af03003cSMatthias Ringwald
1024*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
1025*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1026*af03003cSMatthias Ringwald        "umull r14, r9, r4, r8 \n\t"
1027*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1028*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
1029*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1030*af03003cSMatthias Ringwald        "umull r14, r9, r5, r7 \n\t"
1031*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1032*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
1033*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1034*af03003cSMatthias Ringwald        "umull r14, r9, r3, r6 \n\t"
1035*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1036*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
1037*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1038*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
1039*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1040*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
1041*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1042*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
1043*af03003cSMatthias Ringwald
1044*af03003cSMatthias Ringwald        "ldmia r1!, {r4} \n\t"
1045*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
1046*af03003cSMatthias Ringwald        "umull r9, r10, r5, r8 \n\t"
1047*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1048*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1049*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
1050*af03003cSMatthias Ringwald        "umull r9, r10, r3, r7 \n\t"
1051*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1052*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1053*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
1054*af03003cSMatthias Ringwald        "umull r9, r10, r4, r6 \n\t"
1055*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1056*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1057*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
1058*af03003cSMatthias Ringwald        "ldr r9, [r0] \n\t"
1059*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1060*af03003cSMatthias Ringwald        "adcs r12, #0 \n\t"
1061*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
1062*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1063*af03003cSMatthias Ringwald
1064*af03003cSMatthias Ringwald        "ldmia r1!, {r5} \n\t"
1065*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
1066*af03003cSMatthias Ringwald        "umull r10, r11, r3, r8 \n\t"
1067*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1068*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
1069*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1070*af03003cSMatthias Ringwald        "umull r10, r11, r4, r7 \n\t"
1071*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1072*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
1073*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1074*af03003cSMatthias Ringwald        "umull r10, r11, r5, r6 \n\t"
1075*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1076*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
1077*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1078*af03003cSMatthias Ringwald        "ldr r10, [r0] \n\t"
1079*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1080*af03003cSMatthias Ringwald        "adcs r14, #0 \n\t"
1081*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1082*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1083*af03003cSMatthias Ringwald
1084*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
1085*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1086*af03003cSMatthias Ringwald        "umull r11, r12, r4, r8 \n\t"
1087*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
1088*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1089*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1090*af03003cSMatthias Ringwald        "umull r11, r12, r5, r7 \n\t"
1091*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
1092*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1093*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1094*af03003cSMatthias Ringwald        "umull r11, r12, r3, r6 \n\t"
1095*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
1096*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1097*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1098*af03003cSMatthias Ringwald        "ldr r11, [r0] \n\t"
1099*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
1100*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
1101*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1102*af03003cSMatthias Ringwald        "stmia r0!, {r14} \n\t"
1103*af03003cSMatthias Ringwald
1104*af03003cSMatthias Ringwald        "ldmia r1!, {r4} \n\t"
1105*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
1106*af03003cSMatthias Ringwald        "umull r12, r14, r5, r8 \n\t"
1107*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1108*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1109*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1110*af03003cSMatthias Ringwald        "umull r12, r14, r3, r7 \n\t"
1111*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1112*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1113*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1114*af03003cSMatthias Ringwald        "umull r12, r14, r4, r6 \n\t"
1115*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1116*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1117*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1118*af03003cSMatthias Ringwald        "ldr r12, [r0] \n\t"
1119*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1120*af03003cSMatthias Ringwald        "adcs r10, #0 \n\t"
1121*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1122*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
1123*af03003cSMatthias Ringwald
1124*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
1125*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1126*af03003cSMatthias Ringwald        "umull r14, r9, r5, r6 \n\t"
1127*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1128*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
1129*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1130*af03003cSMatthias Ringwald        "umull r14, r9, r3, r8 \n\t"
1131*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1132*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
1133*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1134*af03003cSMatthias Ringwald        "umull r14, r9, r4, r7 \n\t"
1135*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1136*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
1137*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1138*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
1139*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1140*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
1141*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1142*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
1143*af03003cSMatthias Ringwald
1144*af03003cSMatthias Ringwald        "ldmia r2!, {r7} \n\t"
1145*af03003cSMatthias Ringwald        "mov r14, #0 \n\t"
1146*af03003cSMatthias Ringwald        "umull r9, r10, r5, r7 \n\t"
1147*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1148*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1149*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
1150*af03003cSMatthias Ringwald        "umull r9, r10, r3, r6 \n\t"
1151*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1152*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1153*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
1154*af03003cSMatthias Ringwald        "umull r9, r10, r4, r8 \n\t"
1155*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1156*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1157*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
1158*af03003cSMatthias Ringwald        "ldr r9, [r0] \n\t"
1159*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1160*af03003cSMatthias Ringwald        "adcs r12, #0 \n\t"
1161*af03003cSMatthias Ringwald        "adc r14, #0 \n\t"
1162*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1163*af03003cSMatthias Ringwald
1164*af03003cSMatthias Ringwald        "ldmia r2!, {r8} \n\t"
1165*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
1166*af03003cSMatthias Ringwald        "umull r10, r11, r5, r8 \n\t"
1167*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1168*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
1169*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1170*af03003cSMatthias Ringwald        "umull r10, r11, r3, r7 \n\t"
1171*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1172*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
1173*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1174*af03003cSMatthias Ringwald        "umull r10, r11, r4, r6 \n\t"
1175*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1176*af03003cSMatthias Ringwald        "adcs r14, r11 \n\t"
1177*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1178*af03003cSMatthias Ringwald        "ldr r10, [r0] \n\t"
1179*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1180*af03003cSMatthias Ringwald        "adcs r14, #0 \n\t"
1181*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1182*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1183*af03003cSMatthias Ringwald
1184*af03003cSMatthias Ringwald        "ldmia r2!, {r6} \n\t"
1185*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1186*af03003cSMatthias Ringwald        "umull r11, r12, r5, r6 \n\t"
1187*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
1188*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1189*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1190*af03003cSMatthias Ringwald        "umull r11, r12, r3, r8 \n\t"
1191*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
1192*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1193*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1194*af03003cSMatthias Ringwald        "umull r11, r12, r4, r7 \n\t"
1195*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
1196*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1197*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1198*af03003cSMatthias Ringwald        "ldr r11, [r0] \n\t"
1199*af03003cSMatthias Ringwald        "adds r14, r11 \n\t"
1200*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
1201*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1202*af03003cSMatthias Ringwald        "stmia r0!, {r14} \n\t"
1203*af03003cSMatthias Ringwald
1204*af03003cSMatthias Ringwald        "ldmia r2!, {r7} \n\t"
1205*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
1206*af03003cSMatthias Ringwald        "umull r12, r14, r5, r7 \n\t"
1207*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1208*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1209*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1210*af03003cSMatthias Ringwald        "umull r12, r14, r3, r6 \n\t"
1211*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1212*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1213*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1214*af03003cSMatthias Ringwald        "umull r12, r14, r4, r8 \n\t"
1215*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1216*af03003cSMatthias Ringwald        "adcs r10, r14 \n\t"
1217*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1218*af03003cSMatthias Ringwald        "ldr r12, [r0] \n\t"
1219*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1220*af03003cSMatthias Ringwald        "adcs r10, #0 \n\t"
1221*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1222*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
1223*af03003cSMatthias Ringwald
1224*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1225*af03003cSMatthias Ringwald        "umull r14, r9, r3, r7 \n\t"
1226*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1227*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
1228*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1229*af03003cSMatthias Ringwald        "umull r14, r9, r4, r6 \n\t"
1230*af03003cSMatthias Ringwald        "adds r10, r14 \n\t"
1231*af03003cSMatthias Ringwald        "adcs r11, r9 \n\t"
1232*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1233*af03003cSMatthias Ringwald        "stmia r0!, {r10} \n\t"
1234*af03003cSMatthias Ringwald
1235*af03003cSMatthias Ringwald        "umull r9, r10, r4, r7 \n\t"
1236*af03003cSMatthias Ringwald        "adds r11, r9 \n\t"
1237*af03003cSMatthias Ringwald        "adc r12, r10 \n\t"
1238*af03003cSMatthias Ringwald        "stmia r0!, {r11, r12} \n\t"
1239*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
1240*af03003cSMatthias Ringwald        ".syntax divided \n\t"
1241*af03003cSMatthias Ringwald    #endif
1242*af03003cSMatthias Ringwald        : "+r" (r0), "+r" (r1), "+r" (r2)
1243*af03003cSMatthias Ringwald        :
1244*af03003cSMatthias Ringwald        : "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory"
1245*af03003cSMatthias Ringwald    );
1246*af03003cSMatthias Ringwald}
1247*af03003cSMatthias Ringwald#define asm_mult 1
1248*af03003cSMatthias Ringwald#endif /* (uECC_WORDS == 8) */
1249*af03003cSMatthias Ringwald
1250*af03003cSMatthias Ringwald#if uECC_SQUARE_FUNC
1251*af03003cSMatthias Ringwald#if (uECC_WORDS == 5)
1252*af03003cSMatthias Ringwaldstatic void vli_square(uint32_t *result, const uint32_t *left) {
1253*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
1254*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
1255*af03003cSMatthias Ringwald
1256*af03003cSMatthias Ringwald    __asm__ volatile (
1257*af03003cSMatthias Ringwald        ".syntax unified \n\t"
1258*af03003cSMatthias Ringwald        "ldmia r1!, {r2,r3,r4,r5,r6} \n\t"
1259*af03003cSMatthias Ringwald
1260*af03003cSMatthias Ringwald        "umull r11, r12, r2, r2 \n\t"
1261*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1262*af03003cSMatthias Ringwald
1263*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
1264*af03003cSMatthias Ringwald        "umull r10, r11, r2, r3 \n\t"
1265*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1266*af03003cSMatthias Ringwald        "adcs r8, r11, #0 \n\t"
1267*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1268*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1269*af03003cSMatthias Ringwald        "adcs r8, r11 \n\t"
1270*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1271*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1272*af03003cSMatthias Ringwald
1273*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1274*af03003cSMatthias Ringwald        "umull r11, r12, r2, r4 \n\t"
1275*af03003cSMatthias Ringwald        "adds r11, r11 \n\t"
1276*af03003cSMatthias Ringwald        "adcs r12, r12 \n\t"
1277*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1278*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1279*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1280*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1281*af03003cSMatthias Ringwald        "umull r11, r12, r3, r3 \n\t"
1282*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1283*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1284*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1285*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1286*af03003cSMatthias Ringwald
1287*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1288*af03003cSMatthias Ringwald        "umull r8, r11, r2, r5 \n\t"
1289*af03003cSMatthias Ringwald        "umull r1, r14, r3, r4 \n\t"
1290*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1291*af03003cSMatthias Ringwald        "adcs r11, r14 \n\t"
1292*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1293*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1294*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1295*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1296*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1297*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1298*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1299*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1300*af03003cSMatthias Ringwald
1301*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1302*af03003cSMatthias Ringwald        "umull r8, r9, r2, r6 \n\t"
1303*af03003cSMatthias Ringwald        "umull r1, r14, r3, r5 \n\t"
1304*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1305*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
1306*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1307*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1308*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1309*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1310*af03003cSMatthias Ringwald        "umull r1, r14, r4, r4 \n\t"
1311*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1312*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
1313*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1314*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1315*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1316*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1317*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1318*af03003cSMatthias Ringwald
1319*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1320*af03003cSMatthias Ringwald        "umull r8, r11, r3, r6 \n\t"
1321*af03003cSMatthias Ringwald        "umull r1, r14, r4, r5 \n\t"
1322*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1323*af03003cSMatthias Ringwald        "adcs r11, r14 \n\t"
1324*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1325*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1326*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1327*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1328*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1329*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1330*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1331*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1332*af03003cSMatthias Ringwald
1333*af03003cSMatthias Ringwald        "mov r8, #0 \n\t"
1334*af03003cSMatthias Ringwald        "umull r1, r10, r4, r6 \n\t"
1335*af03003cSMatthias Ringwald        "adds r1, r1 \n\t"
1336*af03003cSMatthias Ringwald        "adcs r10, r10 \n\t"
1337*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1338*af03003cSMatthias Ringwald        "adds r11, r1 \n\t"
1339*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1340*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1341*af03003cSMatthias Ringwald        "umull r1, r10, r5, r5 \n\t"
1342*af03003cSMatthias Ringwald        "adds r11, r1 \n\t"
1343*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1344*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1345*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1346*af03003cSMatthias Ringwald
1347*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
1348*af03003cSMatthias Ringwald        "umull r1, r10, r5, r6 \n\t"
1349*af03003cSMatthias Ringwald        "adds r1, r1 \n\t"
1350*af03003cSMatthias Ringwald        "adcs r10, r10 \n\t"
1351*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1352*af03003cSMatthias Ringwald        "adds r12, r1 \n\t"
1353*af03003cSMatthias Ringwald        "adcs r8, r10 \n\t"
1354*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1355*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1356*af03003cSMatthias Ringwald
1357*af03003cSMatthias Ringwald        "umull r1, r10, r6, r6 \n\t"
1358*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1359*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1360*af03003cSMatthias Ringwald        "stmia r0!, {r8, r11} \n\t"
1361*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
1362*af03003cSMatthias Ringwald        ".syntax divided \n\t"
1363*af03003cSMatthias Ringwald    #endif
1364*af03003cSMatthias Ringwald        : "+r" (r0), "+r" (r1)
1365*af03003cSMatthias Ringwald        :
1366*af03003cSMatthias Ringwald        : "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory"
1367*af03003cSMatthias Ringwald    );
1368*af03003cSMatthias Ringwald}
1369*af03003cSMatthias Ringwald#define asm_square 1
1370*af03003cSMatthias Ringwald#endif /* (uECC_WORDS == 5) */
1371*af03003cSMatthias Ringwald
1372*af03003cSMatthias Ringwald#if (uECC_WORDS == 6)
1373*af03003cSMatthias Ringwaldstatic void vli_square(uint32_t *result, const uint32_t *left) {
1374*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
1375*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
1376*af03003cSMatthias Ringwald
1377*af03003cSMatthias Ringwald    __asm__ volatile (
1378*af03003cSMatthias Ringwald        ".syntax unified \n\t"
1379*af03003cSMatthias Ringwald        "ldmia r1!, {r2,r3,r4,r5,r6,r7} \n\t"
1380*af03003cSMatthias Ringwald
1381*af03003cSMatthias Ringwald        "umull r11, r12, r2, r2 \n\t"
1382*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1383*af03003cSMatthias Ringwald
1384*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
1385*af03003cSMatthias Ringwald        "umull r10, r11, r2, r3 \n\t"
1386*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1387*af03003cSMatthias Ringwald        "adcs r8, r11, #0 \n\t"
1388*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1389*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1390*af03003cSMatthias Ringwald        "adcs r8, r11 \n\t"
1391*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1392*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1393*af03003cSMatthias Ringwald
1394*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1395*af03003cSMatthias Ringwald        "umull r11, r12, r2, r4 \n\t"
1396*af03003cSMatthias Ringwald        "adds r11, r11 \n\t"
1397*af03003cSMatthias Ringwald        "adcs r12, r12 \n\t"
1398*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1399*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1400*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1401*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1402*af03003cSMatthias Ringwald        "umull r11, r12, r3, r3 \n\t"
1403*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1404*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1405*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1406*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1407*af03003cSMatthias Ringwald
1408*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1409*af03003cSMatthias Ringwald        "umull r8, r11, r2, r5 \n\t"
1410*af03003cSMatthias Ringwald        "umull r1, r14, r3, r4 \n\t"
1411*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1412*af03003cSMatthias Ringwald        "adcs r11, r14 \n\t"
1413*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1414*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1415*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1416*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1417*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1418*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1419*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1420*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1421*af03003cSMatthias Ringwald
1422*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1423*af03003cSMatthias Ringwald        "umull r8, r9, r2, r6 \n\t"
1424*af03003cSMatthias Ringwald        "umull r1, r14, r3, r5 \n\t"
1425*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1426*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
1427*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1428*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1429*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1430*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1431*af03003cSMatthias Ringwald        "umull r1, r14, r4, r4 \n\t"
1432*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1433*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
1434*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1435*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1436*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1437*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1438*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1439*af03003cSMatthias Ringwald
1440*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1441*af03003cSMatthias Ringwald        "umull r8, r11, r2, r7 \n\t"
1442*af03003cSMatthias Ringwald        "umull r1, r14, r3, r6 \n\t"
1443*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1444*af03003cSMatthias Ringwald        "adcs r11, r14 \n\t"
1445*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1446*af03003cSMatthias Ringwald        "umull r1, r14, r4, r5 \n\t"
1447*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1448*af03003cSMatthias Ringwald        "adcs r11, r14 \n\t"
1449*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1450*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1451*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1452*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1453*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1454*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1455*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1456*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1457*af03003cSMatthias Ringwald
1458*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1459*af03003cSMatthias Ringwald        "umull r8, r9, r3, r7 \n\t"
1460*af03003cSMatthias Ringwald        "umull r1, r14, r4, r6 \n\t"
1461*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1462*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
1463*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1464*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1465*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1466*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1467*af03003cSMatthias Ringwald        "umull r1, r14, r5, r5 \n\t"
1468*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1469*af03003cSMatthias Ringwald        "adcs r9, r14 \n\t"
1470*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1471*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1472*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1473*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1474*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1475*af03003cSMatthias Ringwald
1476*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1477*af03003cSMatthias Ringwald        "umull r8, r11, r4, r7 \n\t"
1478*af03003cSMatthias Ringwald        "umull r1, r14, r5, r6 \n\t"
1479*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1480*af03003cSMatthias Ringwald        "adcs r11, r14 \n\t"
1481*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1482*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1483*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1484*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1485*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1486*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1487*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1488*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1489*af03003cSMatthias Ringwald
1490*af03003cSMatthias Ringwald        "mov r8, #0 \n\t"
1491*af03003cSMatthias Ringwald        "umull r1, r10, r5, r7 \n\t"
1492*af03003cSMatthias Ringwald        "adds r1, r1 \n\t"
1493*af03003cSMatthias Ringwald        "adcs r10, r10 \n\t"
1494*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1495*af03003cSMatthias Ringwald        "adds r11, r1 \n\t"
1496*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1497*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1498*af03003cSMatthias Ringwald        "umull r1, r10, r6, r6 \n\t"
1499*af03003cSMatthias Ringwald        "adds r11, r1 \n\t"
1500*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1501*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1502*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1503*af03003cSMatthias Ringwald
1504*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
1505*af03003cSMatthias Ringwald        "umull r1, r10, r6, r7 \n\t"
1506*af03003cSMatthias Ringwald        "adds r1, r1 \n\t"
1507*af03003cSMatthias Ringwald        "adcs r10, r10 \n\t"
1508*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1509*af03003cSMatthias Ringwald        "adds r12, r1 \n\t"
1510*af03003cSMatthias Ringwald        "adcs r8, r10 \n\t"
1511*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1512*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1513*af03003cSMatthias Ringwald
1514*af03003cSMatthias Ringwald        "umull r1, r10, r7, r7 \n\t"
1515*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1516*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1517*af03003cSMatthias Ringwald        "stmia r0!, {r8, r11} \n\t"
1518*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
1519*af03003cSMatthias Ringwald        ".syntax divided \n\t"
1520*af03003cSMatthias Ringwald    #endif
1521*af03003cSMatthias Ringwald        : "+r" (r0), "+r" (r1)
1522*af03003cSMatthias Ringwald        :
1523*af03003cSMatthias Ringwald        : "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory"
1524*af03003cSMatthias Ringwald    );
1525*af03003cSMatthias Ringwald}
1526*af03003cSMatthias Ringwald#define asm_square 1
1527*af03003cSMatthias Ringwald#endif /* (uECC_WORDS == 6) */
1528*af03003cSMatthias Ringwald
1529*af03003cSMatthias Ringwald#if (uECC_WORDS == 7)
1530*af03003cSMatthias Ringwaldstatic void vli_square(uint32_t *result, const uint32_t *left) {
1531*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
1532*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
1533*af03003cSMatthias Ringwald
1534*af03003cSMatthias Ringwald    __asm__ volatile (
1535*af03003cSMatthias Ringwald        ".syntax unified \n\t"
1536*af03003cSMatthias Ringwald        "ldmia r1!, {r2} \n\t"
1537*af03003cSMatthias Ringwald        "add r1, 20 \n\t"
1538*af03003cSMatthias Ringwald        "ldmia r1!, {r5} \n\t"
1539*af03003cSMatthias Ringwald        "add r0, 24 \n\t"
1540*af03003cSMatthias Ringwald        "umull r8, r9, r2, r5 \n\t"
1541*af03003cSMatthias Ringwald        "stmia r0!, {r8, r9} \n\t"
1542*af03003cSMatthias Ringwald        "sub r0, 32 \n\t"
1543*af03003cSMatthias Ringwald        "sub r1, 28 \n\t"
1544*af03003cSMatthias Ringwald
1545*af03003cSMatthias Ringwald        "ldmia r1!, {r2, r3, r4, r5, r6, r7} \n\t"
1546*af03003cSMatthias Ringwald
1547*af03003cSMatthias Ringwald        "umull r11, r12, r2, r2 \n\t"
1548*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1549*af03003cSMatthias Ringwald
1550*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
1551*af03003cSMatthias Ringwald        "umull r10, r11, r2, r3 \n\t"
1552*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1553*af03003cSMatthias Ringwald        "adcs r8, r11, #0 \n\t"
1554*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1555*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1556*af03003cSMatthias Ringwald        "adcs r8, r11 \n\t"
1557*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1558*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1559*af03003cSMatthias Ringwald
1560*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1561*af03003cSMatthias Ringwald        "umull r11, r12, r2, r4 \n\t"
1562*af03003cSMatthias Ringwald        "adds r11, r11 \n\t"
1563*af03003cSMatthias Ringwald        "adcs r12, r12 \n\t"
1564*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1565*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1566*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1567*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1568*af03003cSMatthias Ringwald        "umull r11, r12, r3, r3 \n\t"
1569*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1570*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1571*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1572*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1573*af03003cSMatthias Ringwald
1574*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1575*af03003cSMatthias Ringwald        "umull r8, r11, r2, r5 \n\t"
1576*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1577*af03003cSMatthias Ringwald        "umlal r8, r11, r3, r4 \n\t"
1578*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1579*af03003cSMatthias Ringwald        "it hi \n\t"
1580*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1581*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1582*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1583*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1584*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1585*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1586*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1587*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1588*af03003cSMatthias Ringwald
1589*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1590*af03003cSMatthias Ringwald        "umull r8, r9, r2, r6 \n\t"
1591*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1592*af03003cSMatthias Ringwald        "umlal r8, r9, r3, r5 \n\t"
1593*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1594*af03003cSMatthias Ringwald        "it hi \n\t"
1595*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1596*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1597*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1598*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1599*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1600*af03003cSMatthias Ringwald        "umlal r8, r9, r4, r4 \n\t"
1601*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1602*af03003cSMatthias Ringwald        "it hi \n\t"
1603*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1604*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1605*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1606*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1607*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1608*af03003cSMatthias Ringwald
1609*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1610*af03003cSMatthias Ringwald        "umull r8, r11, r2, r7 \n\t"
1611*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1612*af03003cSMatthias Ringwald        "umlal r8, r11, r3, r6 \n\t"
1613*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1614*af03003cSMatthias Ringwald        "it hi \n\t"
1615*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1616*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1617*af03003cSMatthias Ringwald        "umlal r8, r11, r4, r5 \n\t"
1618*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1619*af03003cSMatthias Ringwald        "it hi \n\t"
1620*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1621*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1622*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1623*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1624*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1625*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1626*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1627*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1628*af03003cSMatthias Ringwald
1629*af03003cSMatthias Ringwald        "ldmia r1!, {r2} \n\t"
1630*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1631*af03003cSMatthias Ringwald        "umull r8, r9, r3, r7 \n\t"
1632*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1633*af03003cSMatthias Ringwald        "umlal r8, r9, r4, r6 \n\t"
1634*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1635*af03003cSMatthias Ringwald        "it hi \n\t"
1636*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1637*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
1638*af03003cSMatthias Ringwald        "adds r8, r14 \n\t"
1639*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
1640*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1641*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1642*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1643*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1644*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1645*af03003cSMatthias Ringwald        "umlal r8, r9, r5, r5 \n\t"
1646*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1647*af03003cSMatthias Ringwald        "it hi \n\t"
1648*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1649*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1650*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1651*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1652*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1653*af03003cSMatthias Ringwald
1654*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1655*af03003cSMatthias Ringwald        "umull r8, r11, r3, r2 \n\t"
1656*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1657*af03003cSMatthias Ringwald        "umlal r8, r11, r4, r7 \n\t"
1658*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1659*af03003cSMatthias Ringwald        "it hi \n\t"
1660*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1661*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1662*af03003cSMatthias Ringwald        "umlal r8, r11, r5, r6 \n\t"
1663*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1664*af03003cSMatthias Ringwald        "it hi \n\t"
1665*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1666*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
1667*af03003cSMatthias Ringwald        "adds r8, r14 \n\t"
1668*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
1669*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1670*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1671*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1672*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1673*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1674*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1675*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1676*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1677*af03003cSMatthias Ringwald
1678*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1679*af03003cSMatthias Ringwald        "umull r8, r9, r4, r2 \n\t"
1680*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1681*af03003cSMatthias Ringwald        "umlal r8, r9, r5, r7 \n\t"
1682*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1683*af03003cSMatthias Ringwald        "it hi \n\t"
1684*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1685*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1686*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1687*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1688*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1689*af03003cSMatthias Ringwald        "umlal r8, r9, r6, r6 \n\t"
1690*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1691*af03003cSMatthias Ringwald        "it hi \n\t"
1692*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1693*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1694*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1695*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1696*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1697*af03003cSMatthias Ringwald
1698*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1699*af03003cSMatthias Ringwald        "umull r8, r11, r5, r2 \n\t"
1700*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1701*af03003cSMatthias Ringwald        "umlal r8, r11, r6, r7 \n\t"
1702*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1703*af03003cSMatthias Ringwald        "it hi \n\t"
1704*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1705*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1706*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1707*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1708*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1709*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1710*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1711*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1712*af03003cSMatthias Ringwald
1713*af03003cSMatthias Ringwald        "mov r8, #0 \n\t"
1714*af03003cSMatthias Ringwald        "umull r1, r10, r6, r2 \n\t"
1715*af03003cSMatthias Ringwald        "adds r1, r1 \n\t"
1716*af03003cSMatthias Ringwald        "adcs r10, r10 \n\t"
1717*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1718*af03003cSMatthias Ringwald        "adds r11, r1 \n\t"
1719*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1720*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1721*af03003cSMatthias Ringwald        "umull r1, r10, r7, r7 \n\t"
1722*af03003cSMatthias Ringwald        "adds r11, r1 \n\t"
1723*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
1724*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
1725*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1726*af03003cSMatthias Ringwald
1727*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
1728*af03003cSMatthias Ringwald        "umull r1, r10, r7, r2 \n\t"
1729*af03003cSMatthias Ringwald        "adds r1, r1 \n\t"
1730*af03003cSMatthias Ringwald        "adcs r10, r10 \n\t"
1731*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1732*af03003cSMatthias Ringwald        "adds r12, r1 \n\t"
1733*af03003cSMatthias Ringwald        "adcs r8, r10 \n\t"
1734*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
1735*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1736*af03003cSMatthias Ringwald
1737*af03003cSMatthias Ringwald        "umull r1, r10, r2, r2 \n\t"
1738*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
1739*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1740*af03003cSMatthias Ringwald        "stmia r0!, {r8, r11} \n\t"
1741*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
1742*af03003cSMatthias Ringwald        ".syntax divided \n\t"
1743*af03003cSMatthias Ringwald    #endif
1744*af03003cSMatthias Ringwald        : "+r" (r0), "+r" (r1)
1745*af03003cSMatthias Ringwald        :
1746*af03003cSMatthias Ringwald        : "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory"
1747*af03003cSMatthias Ringwald    );
1748*af03003cSMatthias Ringwald}
1749*af03003cSMatthias Ringwald#define asm_square 1
1750*af03003cSMatthias Ringwald#endif /* (uECC_WORDS == 7) */
1751*af03003cSMatthias Ringwald
1752*af03003cSMatthias Ringwald#if (uECC_WORDS == 8)
1753*af03003cSMatthias Ringwaldstatic void vli_square(uint32_t *result, const uint32_t *left) {
1754*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
1755*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
1756*af03003cSMatthias Ringwald
1757*af03003cSMatthias Ringwald    __asm__ volatile (
1758*af03003cSMatthias Ringwald        ".syntax unified \n\t"
1759*af03003cSMatthias Ringwald        "ldmia r1!, {r2, r3} \n\t"
1760*af03003cSMatthias Ringwald        "add r1, 16 \n\t"
1761*af03003cSMatthias Ringwald        "ldmia r1!, {r5, r6} \n\t"
1762*af03003cSMatthias Ringwald        "add r0, 24 \n\t"
1763*af03003cSMatthias Ringwald
1764*af03003cSMatthias Ringwald        "umull r8, r9, r2, r5 \n\t"
1765*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1766*af03003cSMatthias Ringwald
1767*af03003cSMatthias Ringwald        "umull r12, r10, r2, r6 \n\t"
1768*af03003cSMatthias Ringwald        "adds r9, r12 \n\t"
1769*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1770*af03003cSMatthias Ringwald        "stmia r0!, {r9} \n\t"
1771*af03003cSMatthias Ringwald
1772*af03003cSMatthias Ringwald        "umull r8, r9, r3, r6 \n\t"
1773*af03003cSMatthias Ringwald        "adds r10, r8 \n\t"
1774*af03003cSMatthias Ringwald        "adc r11, r9, #0 \n\t"
1775*af03003cSMatthias Ringwald        "stmia r0!, {r10, r11} \n\t"
1776*af03003cSMatthias Ringwald
1777*af03003cSMatthias Ringwald        "sub r0, 40 \n\t"
1778*af03003cSMatthias Ringwald        "sub r1, 32 \n\t"
1779*af03003cSMatthias Ringwald        "ldmia r1!, {r2,r3,r4,r5,r6,r7} \n\t"
1780*af03003cSMatthias Ringwald
1781*af03003cSMatthias Ringwald        "umull r11, r12, r2, r2 \n\t"
1782*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
1783*af03003cSMatthias Ringwald
1784*af03003cSMatthias Ringwald        "mov r9, #0 \n\t"
1785*af03003cSMatthias Ringwald        "umull r10, r11, r2, r3 \n\t"
1786*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1787*af03003cSMatthias Ringwald        "adcs r8, r11, #0 \n\t"
1788*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1789*af03003cSMatthias Ringwald        "adds r12, r10 \n\t"
1790*af03003cSMatthias Ringwald        "adcs r8, r11 \n\t"
1791*af03003cSMatthias Ringwald        "adc r9, #0 \n\t"
1792*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
1793*af03003cSMatthias Ringwald
1794*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1795*af03003cSMatthias Ringwald        "umull r11, r12, r2, r4 \n\t"
1796*af03003cSMatthias Ringwald        "adds r11, r11 \n\t"
1797*af03003cSMatthias Ringwald        "adcs r12, r12 \n\t"
1798*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1799*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1800*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1801*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1802*af03003cSMatthias Ringwald        "umull r11, r12, r3, r3 \n\t"
1803*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1804*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1805*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1806*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1807*af03003cSMatthias Ringwald
1808*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1809*af03003cSMatthias Ringwald        "umull r8, r11, r2, r5 \n\t"
1810*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1811*af03003cSMatthias Ringwald        "umlal r8, r11, r3, r4 \n\t"
1812*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1813*af03003cSMatthias Ringwald        "it hi \n\t"
1814*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1815*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1816*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1817*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1818*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1819*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1820*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1821*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1822*af03003cSMatthias Ringwald
1823*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1824*af03003cSMatthias Ringwald        "umull r8, r9, r2, r6 \n\t"
1825*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1826*af03003cSMatthias Ringwald        "umlal r8, r9, r3, r5 \n\t"
1827*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1828*af03003cSMatthias Ringwald        "it hi \n\t"
1829*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1830*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1831*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1832*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1833*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1834*af03003cSMatthias Ringwald        "umlal r8, r9, r4, r4 \n\t"
1835*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1836*af03003cSMatthias Ringwald        "it hi \n\t"
1837*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1838*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1839*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1840*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1841*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1842*af03003cSMatthias Ringwald
1843*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1844*af03003cSMatthias Ringwald        "umull r8, r11, r2, r7 \n\t"
1845*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1846*af03003cSMatthias Ringwald        "umlal r8, r11, r3, r6 \n\t"
1847*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1848*af03003cSMatthias Ringwald        "it hi \n\t"
1849*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1850*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1851*af03003cSMatthias Ringwald        "umlal r8, r11, r4, r5 \n\t"
1852*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1853*af03003cSMatthias Ringwald        "it hi \n\t"
1854*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1855*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1856*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1857*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1858*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1859*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1860*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1861*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1862*af03003cSMatthias Ringwald
1863*af03003cSMatthias Ringwald        "ldmia r1!, {r2} \n\t"
1864*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1865*af03003cSMatthias Ringwald        "umull r8, r9, r3, r7 \n\t"
1866*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1867*af03003cSMatthias Ringwald        "umlal r8, r9, r4, r6 \n\t"
1868*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1869*af03003cSMatthias Ringwald        "it hi \n\t"
1870*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1871*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
1872*af03003cSMatthias Ringwald        "adds r8, r14 \n\t"
1873*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
1874*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1875*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1876*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1877*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1878*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1879*af03003cSMatthias Ringwald        "umlal r8, r9, r5, r5 \n\t"
1880*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1881*af03003cSMatthias Ringwald        "it hi \n\t"
1882*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1883*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1884*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1885*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1886*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1887*af03003cSMatthias Ringwald
1888*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1889*af03003cSMatthias Ringwald        "umull r8, r11, r3, r2 \n\t"
1890*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1891*af03003cSMatthias Ringwald        "umlal r8, r11, r4, r7 \n\t"
1892*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1893*af03003cSMatthias Ringwald        "it hi \n\t"
1894*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1895*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1896*af03003cSMatthias Ringwald        "umlal r8, r11, r5, r6 \n\t"
1897*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1898*af03003cSMatthias Ringwald        "it hi \n\t"
1899*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1900*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
1901*af03003cSMatthias Ringwald        "adds r8, r14 \n\t"
1902*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
1903*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1904*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1905*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1906*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1907*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1908*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1909*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1910*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1911*af03003cSMatthias Ringwald
1912*af03003cSMatthias Ringwald        "ldmia r1!, {r3} \n\t"
1913*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1914*af03003cSMatthias Ringwald        "umull r8, r9, r4, r2 \n\t"
1915*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1916*af03003cSMatthias Ringwald        "umlal r8, r9, r5, r7 \n\t"
1917*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1918*af03003cSMatthias Ringwald        "it hi \n\t"
1919*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1920*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
1921*af03003cSMatthias Ringwald        "adds r8, r14 \n\t"
1922*af03003cSMatthias Ringwald        "adcs r9, #0 \n\t"
1923*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1924*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1925*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1926*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1927*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1928*af03003cSMatthias Ringwald        "umlal r8, r9, r6, r6 \n\t"
1929*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1930*af03003cSMatthias Ringwald        "it hi \n\t"
1931*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1932*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1933*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1934*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1935*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1936*af03003cSMatthias Ringwald
1937*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1938*af03003cSMatthias Ringwald        "umull r8, r11, r4, r3 \n\t"
1939*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1940*af03003cSMatthias Ringwald        "umlal r8, r11, r5, r2 \n\t"
1941*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1942*af03003cSMatthias Ringwald        "it hi \n\t"
1943*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1944*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1945*af03003cSMatthias Ringwald        "umlal r8, r11, r6, r7 \n\t"
1946*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1947*af03003cSMatthias Ringwald        "it hi \n\t"
1948*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1949*af03003cSMatthias Ringwald        "ldr r14, [r0] \n\t"
1950*af03003cSMatthias Ringwald        "adds r8, r14 \n\t"
1951*af03003cSMatthias Ringwald        "adcs r11, #0 \n\t"
1952*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1953*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1954*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1955*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1956*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1957*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1958*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1959*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1960*af03003cSMatthias Ringwald
1961*af03003cSMatthias Ringwald        "mov r10, #0 \n\t"
1962*af03003cSMatthias Ringwald        "umull r8, r9, r5, r3 \n\t"
1963*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1964*af03003cSMatthias Ringwald        "umlal r8, r9, r6, r2 \n\t"
1965*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1966*af03003cSMatthias Ringwald        "it hi \n\t"
1967*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1968*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1969*af03003cSMatthias Ringwald        "adcs r9, r9 \n\t"
1970*af03003cSMatthias Ringwald        "adc r10, r10 \n\t"
1971*af03003cSMatthias Ringwald        "mov r14, r9 \n\t"
1972*af03003cSMatthias Ringwald        "umlal r8, r9, r7, r7 \n\t"
1973*af03003cSMatthias Ringwald        "cmp r14, r9 \n\t"
1974*af03003cSMatthias Ringwald        "it hi \n\t"
1975*af03003cSMatthias Ringwald        "adchi r10, #0 \n\t"
1976*af03003cSMatthias Ringwald        "adds r8, r11 \n\t"
1977*af03003cSMatthias Ringwald        "adcs r9, r12 \n\t"
1978*af03003cSMatthias Ringwald        "adc r10, #0 \n\t"
1979*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1980*af03003cSMatthias Ringwald
1981*af03003cSMatthias Ringwald        "mov r12, #0 \n\t"
1982*af03003cSMatthias Ringwald        "umull r8, r11, r6, r3 \n\t"
1983*af03003cSMatthias Ringwald        "mov r14, r11 \n\t"
1984*af03003cSMatthias Ringwald        "umlal r8, r11, r7, r2 \n\t"
1985*af03003cSMatthias Ringwald        "cmp r14, r11 \n\t"
1986*af03003cSMatthias Ringwald        "it hi \n\t"
1987*af03003cSMatthias Ringwald        "adchi r12, #0 \n\t"
1988*af03003cSMatthias Ringwald        "adds r8, r8 \n\t"
1989*af03003cSMatthias Ringwald        "adcs r11, r11 \n\t"
1990*af03003cSMatthias Ringwald        "adc r12, r12 \n\t"
1991*af03003cSMatthias Ringwald        "adds r8, r9 \n\t"
1992*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
1993*af03003cSMatthias Ringwald        "adc r12, #0 \n\t"
1994*af03003cSMatthias Ringwald        "stmia r0!, {r8} \n\t"
1995*af03003cSMatthias Ringwald
1996*af03003cSMatthias Ringwald        "mov r8, #0 \n\t"
1997*af03003cSMatthias Ringwald        "umull r1, r10, r7, r3 \n\t"
1998*af03003cSMatthias Ringwald        "adds r1, r1 \n\t"
1999*af03003cSMatthias Ringwald        "adcs r10, r10 \n\t"
2000*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
2001*af03003cSMatthias Ringwald        "adds r11, r1 \n\t"
2002*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
2003*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
2004*af03003cSMatthias Ringwald        "umull r1, r10, r2, r2 \n\t"
2005*af03003cSMatthias Ringwald        "adds r11, r1 \n\t"
2006*af03003cSMatthias Ringwald        "adcs r12, r10 \n\t"
2007*af03003cSMatthias Ringwald        "adc r8, #0 \n\t"
2008*af03003cSMatthias Ringwald        "stmia r0!, {r11} \n\t"
2009*af03003cSMatthias Ringwald
2010*af03003cSMatthias Ringwald        "mov r11, #0 \n\t"
2011*af03003cSMatthias Ringwald        "umull r1, r10, r2, r3 \n\t"
2012*af03003cSMatthias Ringwald        "adds r1, r1 \n\t"
2013*af03003cSMatthias Ringwald        "adcs r10, r10 \n\t"
2014*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
2015*af03003cSMatthias Ringwald        "adds r12, r1 \n\t"
2016*af03003cSMatthias Ringwald        "adcs r8, r10 \n\t"
2017*af03003cSMatthias Ringwald        "adc r11, #0 \n\t"
2018*af03003cSMatthias Ringwald        "stmia r0!, {r12} \n\t"
2019*af03003cSMatthias Ringwald
2020*af03003cSMatthias Ringwald        "umull r1, r10, r3, r3 \n\t"
2021*af03003cSMatthias Ringwald        "adds r8, r1 \n\t"
2022*af03003cSMatthias Ringwald        "adcs r11, r10 \n\t"
2023*af03003cSMatthias Ringwald        "stmia r0!, {r8, r11} \n\t"
2024*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
2025*af03003cSMatthias Ringwald        ".syntax divided \n\t"
2026*af03003cSMatthias Ringwald    #endif
2027*af03003cSMatthias Ringwald        : "+r" (r0), "+r" (r1)
2028*af03003cSMatthias Ringwald        :
2029*af03003cSMatthias Ringwald        : "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory"
2030*af03003cSMatthias Ringwald    );
2031*af03003cSMatthias Ringwald}
2032*af03003cSMatthias Ringwald#define asm_square 1
2033*af03003cSMatthias Ringwald#endif /* (uECC_WORDS == 8) */
2034*af03003cSMatthias Ringwald#endif /* uECC_SQUARE_FUNC */
2035*af03003cSMatthias Ringwald
2036*af03003cSMatthias Ringwald#endif /* (uECC_PLATFORM != uECC_arm_thumb) */
2037*af03003cSMatthias Ringwald#endif /* (uECC_ASM == uECC_asm_fast) */
2038*af03003cSMatthias Ringwald
2039*af03003cSMatthias Ringwald#if !asm_add
2040*af03003cSMatthias Ringwaldstatic uint32_t vli_add(uint32_t *result, const uint32_t *left, const uint32_t *right) {
2041*af03003cSMatthias Ringwald    uint32_t counter = uECC_WORDS;
2042*af03003cSMatthias Ringwald    uint32_t carry = 0;
2043*af03003cSMatthias Ringwald    uint32_t left_word;
2044*af03003cSMatthias Ringwald    uint32_t right_word;
2045*af03003cSMatthias Ringwald
2046*af03003cSMatthias Ringwald    __asm__ volatile (
2047*af03003cSMatthias Ringwald        ".syntax unified \n\t"
2048*af03003cSMatthias Ringwald        "1: \n\t"
2049*af03003cSMatthias Ringwald        "ldmia %[lptr]!, {%[left]} \n\t"  /* Load left word. */
2050*af03003cSMatthias Ringwald        "ldmia %[rptr]!, {%[right]} \n\t" /* Load right word. */
2051*af03003cSMatthias Ringwald        "lsrs %[carry], #1 \n\t"          /* Set up carry flag (carry = 0 after this). */
2052*af03003cSMatthias Ringwald        "adcs %[left], %[right] \n\t"     /* Add with carry. */
2053*af03003cSMatthias Ringwald        "adcs %[carry], %[carry] \n\t"    /* Store carry bit. */
2054*af03003cSMatthias Ringwald        "stmia %[dptr]!, {%[left]} \n\t"  /* Store result word. */
2055*af03003cSMatthias Ringwald        "subs %[ctr], #1 \n\t"            /* Decrement counter. */
2056*af03003cSMatthias Ringwald        "bne 1b \n\t"                     /* Loop until counter == 0. */
2057*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
2058*af03003cSMatthias Ringwald        ".syntax divided \n\t"
2059*af03003cSMatthias Ringwald    #endif
2060*af03003cSMatthias Ringwald    #if (uECC_PLATFORM == uECC_arm_thumb)
2061*af03003cSMatthias Ringwald        : [dptr] "+l" (result), [lptr] "+l" (left), [rptr] "+l" (right),
2062*af03003cSMatthias Ringwald          [ctr] "+l" (counter), [carry] "+l" (carry),
2063*af03003cSMatthias Ringwald          [left] "=l" (left_word), [right] "=l" (right_word)
2064*af03003cSMatthias Ringwald    #else
2065*af03003cSMatthias Ringwald        : [dptr] "+r" (result), [lptr] "+r" (left), [rptr] "+r" (right),
2066*af03003cSMatthias Ringwald          [ctr] "+r" (counter), [carry] "+r" (carry),
2067*af03003cSMatthias Ringwald          [left] "=r" (left_word), [right] "=r" (right_word)
2068*af03003cSMatthias Ringwald    #endif
2069*af03003cSMatthias Ringwald        :
2070*af03003cSMatthias Ringwald        : "cc", "memory"
2071*af03003cSMatthias Ringwald    );
2072*af03003cSMatthias Ringwald    return carry;
2073*af03003cSMatthias Ringwald}
2074*af03003cSMatthias Ringwald#define asm_add 1
2075*af03003cSMatthias Ringwald#endif
2076*af03003cSMatthias Ringwald
2077*af03003cSMatthias Ringwald#if !asm_sub
2078*af03003cSMatthias Ringwaldstatic uint32_t vli_sub(uint32_t *result, const uint32_t *left, const uint32_t *right) {
2079*af03003cSMatthias Ringwald    uint32_t counter = uECC_WORDS;
2080*af03003cSMatthias Ringwald    uint32_t carry = 1; /* carry = 1 initially (means don't borrow) */
2081*af03003cSMatthias Ringwald    uint32_t left_word;
2082*af03003cSMatthias Ringwald    uint32_t right_word;
2083*af03003cSMatthias Ringwald
2084*af03003cSMatthias Ringwald    __asm__ volatile (
2085*af03003cSMatthias Ringwald        ".syntax unified \n\t"
2086*af03003cSMatthias Ringwald        "1: \n\t"
2087*af03003cSMatthias Ringwald        "ldmia %[lptr]!, {%[left]} \n\t"  /* Load left word. */
2088*af03003cSMatthias Ringwald        "ldmia %[rptr]!, {%[right]} \n\t" /* Load right word. */
2089*af03003cSMatthias Ringwald        "lsrs %[carry], #1 \n\t"          /* Set up carry flag (carry = 0 after this). */
2090*af03003cSMatthias Ringwald        "sbcs %[left], %[right] \n\t"     /* Subtract with borrow. */
2091*af03003cSMatthias Ringwald        "adcs %[carry], %[carry] \n\t"    /* Store carry bit. */
2092*af03003cSMatthias Ringwald        "stmia %[dptr]!, {%[left]} \n\t"  /* Store result word. */
2093*af03003cSMatthias Ringwald        "subs %[ctr], #1 \n\t"            /* Decrement counter. */
2094*af03003cSMatthias Ringwald        "bne 1b \n\t"                     /* Loop until counter == 0. */
2095*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
2096*af03003cSMatthias Ringwald        ".syntax divided \n\t"
2097*af03003cSMatthias Ringwald    #endif
2098*af03003cSMatthias Ringwald    #if (uECC_PLATFORM == uECC_arm_thumb)
2099*af03003cSMatthias Ringwald        : [dptr] "+l" (result), [lptr] "+l" (left), [rptr] "+l" (right),
2100*af03003cSMatthias Ringwald          [ctr] "+l" (counter), [carry] "+l" (carry),
2101*af03003cSMatthias Ringwald          [left] "=l" (left_word), [right] "=l" (right_word)
2102*af03003cSMatthias Ringwald    #else
2103*af03003cSMatthias Ringwald        : [dptr] "+r" (result), [lptr] "+r" (left), [rptr] "+r" (right),
2104*af03003cSMatthias Ringwald          [ctr] "+r" (counter), [carry] "+r" (carry),
2105*af03003cSMatthias Ringwald          [left] "=r" (left_word), [right] "=r" (right_word)
2106*af03003cSMatthias Ringwald    #endif
2107*af03003cSMatthias Ringwald        :
2108*af03003cSMatthias Ringwald        : "cc", "memory"
2109*af03003cSMatthias Ringwald    );
2110*af03003cSMatthias Ringwald    return !carry;
2111*af03003cSMatthias Ringwald}
2112*af03003cSMatthias Ringwald#define asm_sub 1
2113*af03003cSMatthias Ringwald#endif
2114*af03003cSMatthias Ringwald
2115*af03003cSMatthias Ringwald#if !asm_mult
2116*af03003cSMatthias Ringwaldstatic void vli_mult(uint32_t *result, const uint32_t *left, const uint32_t *right) {
2117*af03003cSMatthias Ringwald#if (uECC_PLATFORM != uECC_arm_thumb)
2118*af03003cSMatthias Ringwald    uint32_t c0 = 0;
2119*af03003cSMatthias Ringwald    uint32_t c1 = 0;
2120*af03003cSMatthias Ringwald    uint32_t c2 = 0;
2121*af03003cSMatthias Ringwald    uint32_t k = 0;
2122*af03003cSMatthias Ringwald    uint32_t i;
2123*af03003cSMatthias Ringwald    uint32_t t0, t1;
2124*af03003cSMatthias Ringwald
2125*af03003cSMatthias Ringwald    __asm__ volatile (
2126*af03003cSMatthias Ringwald        ".syntax unified \n\t"
2127*af03003cSMatthias Ringwald
2128*af03003cSMatthias Ringwald        "1: \n\t" /* outer loop (k < uECC_WORDS) */
2129*af03003cSMatthias Ringwald        "movs %[i], #0 \n\t" /* i = 0 */
2130*af03003cSMatthias Ringwald        "b 3f \n\t"
2131*af03003cSMatthias Ringwald
2132*af03003cSMatthias Ringwald        "2: \n\t" /* outer loop (k >= uECC_WORDS) */
2133*af03003cSMatthias Ringwald        "movs %[i], %[k] \n\t"      /* i = k */
2134*af03003cSMatthias Ringwald        "subs %[i], %[eccdm1] \n\t" /* i = k - (uECC_WORDS - 1) (times 4) */
2135*af03003cSMatthias Ringwald
2136*af03003cSMatthias Ringwald        "3: \n\t" /* inner loop */
2137*af03003cSMatthias Ringwald        "subs %[t0], %[k], %[i] \n\t" /* t0 = k-i */
2138*af03003cSMatthias Ringwald
2139*af03003cSMatthias Ringwald        "ldr %[t1], [%[right], %[t0]] \n\t" /* t1 = right[k - i] */
2140*af03003cSMatthias Ringwald        "ldr %[t0], [%[left], %[i]] \n\t"   /* t0 = left[i] */
2141*af03003cSMatthias Ringwald
2142*af03003cSMatthias Ringwald        "umull %[t0], %[t1], %[t0], %[t1] \n\t" /* (t0, t1) = left[i] * right[k - i] */
2143*af03003cSMatthias Ringwald
2144*af03003cSMatthias Ringwald        "adds %[c0], %[t0] \n\t" /* add low word to c0 */
2145*af03003cSMatthias Ringwald        "adcs %[c1], %[t1] \n\t" /* add high word to c1, including carry */
2146*af03003cSMatthias Ringwald        "adcs %[c2], #0 \n\t"    /* add carry to c2 */
2147*af03003cSMatthias Ringwald
2148*af03003cSMatthias Ringwald        "adds %[i], #4 \n\t"     /* i += 4 */
2149*af03003cSMatthias Ringwald        "cmp %[i], %[eccd] \n\t" /* i < uECC_WORDS (times 4)? */
2150*af03003cSMatthias Ringwald        "bge 4f \n\t"            /*   if not, exit the loop */
2151*af03003cSMatthias Ringwald        "cmp %[i], %[k] \n\t"    /* i <= k? */
2152*af03003cSMatthias Ringwald        "ble 3b \n\t"            /*   if so, continue looping */
2153*af03003cSMatthias Ringwald
2154*af03003cSMatthias Ringwald        "4: \n\t" /* end inner loop */
2155*af03003cSMatthias Ringwald
2156*af03003cSMatthias Ringwald        "str %[c0], [%[result], %[k]] \n\t" /* result[k] = c0 */
2157*af03003cSMatthias Ringwald        "mov %[c0], %[c1] \n\t"     /* c0 = c1 */
2158*af03003cSMatthias Ringwald        "mov %[c1], %[c2] \n\t"     /* c1 = c2 */
2159*af03003cSMatthias Ringwald        "movs %[c2], #0 \n\t"       /* c2 = 0 */
2160*af03003cSMatthias Ringwald        "adds %[k], #4 \n\t"        /* k += 4 */
2161*af03003cSMatthias Ringwald        "cmp %[k], %[eccd] \n\t"    /* k < uECC_WORDS (times 4) ? */
2162*af03003cSMatthias Ringwald        "blt 1b \n\t"               /*   if not, loop back, start with i = 0 */
2163*af03003cSMatthias Ringwald        "cmp %[k], %[eccd2m1] \n\t" /* k < uECC_WORDS * 2 - 1 (times 4) ? */
2164*af03003cSMatthias Ringwald        "blt 2b \n\t"               /*   if not, loop back, start with i = (k + 1) - uECC_WORDS */
2165*af03003cSMatthias Ringwald        /* end outer loop */
2166*af03003cSMatthias Ringwald
2167*af03003cSMatthias Ringwald        "str %[c0], [%[result], %[k]] \n\t" /* result[uECC_WORDS * 2 - 1] = c0 */
2168*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
2169*af03003cSMatthias Ringwald        ".syntax divided \n\t"
2170*af03003cSMatthias Ringwald    #endif
2171*af03003cSMatthias Ringwald        : [c0] "+r" (c0), [c1] "+r" (c1), [c2] "+r" (c2),
2172*af03003cSMatthias Ringwald          [k] "+r" (k), [i] "=&r" (i), [t0] "=&r" (t0), [t1] "=&r" (t1)
2173*af03003cSMatthias Ringwald        : [result] "r" (result), [left] "r" (left), [right] "r" (right),
2174*af03003cSMatthias Ringwald          [eccd] "I" (uECC_WORDS * 4), [eccdm1] "I" ((uECC_WORDS-1) * 4),
2175*af03003cSMatthias Ringwald          [eccd2m1] "I" ((uECC_WORDS * 2 - 1) * 4)
2176*af03003cSMatthias Ringwald        : "cc", "memory"
2177*af03003cSMatthias Ringwald    );
2178*af03003cSMatthias Ringwald
2179*af03003cSMatthias Ringwald#else /* Thumb-1 */
2180*af03003cSMatthias Ringwald
2181*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
2182*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
2183*af03003cSMatthias Ringwald    register const uint32_t *r2 __asm__("r2") = right;
2184*af03003cSMatthias Ringwald
2185*af03003cSMatthias Ringwald    __asm__ volatile (
2186*af03003cSMatthias Ringwald        ".syntax unified \n\t"
2187*af03003cSMatthias Ringwald        "movs r3, #0 \n\t" /* c0 = 0 */
2188*af03003cSMatthias Ringwald        "movs r4, #0 \n\t" /* c1 = 0 */
2189*af03003cSMatthias Ringwald        "movs r5, #0 \n\t" /* c2 = 0 */
2190*af03003cSMatthias Ringwald        "movs r6, #0 \n\t" /* k = 0 */
2191*af03003cSMatthias Ringwald
2192*af03003cSMatthias Ringwald        "push {r0} \n\t" /* keep result on the stack */
2193*af03003cSMatthias Ringwald
2194*af03003cSMatthias Ringwald        "1: \n\t" /* outer loop (k < uECC_WORDS) */
2195*af03003cSMatthias Ringwald        "movs r7, #0 \n\t" /* r7 = i = 0 */
2196*af03003cSMatthias Ringwald        "b 3f \n\t"
2197*af03003cSMatthias Ringwald
2198*af03003cSMatthias Ringwald        "2: \n\t" /* outer loop (k >= uECC_WORDS) */
2199*af03003cSMatthias Ringwald        "movs r7, r6 \n\t"        /* r7 = k */
2200*af03003cSMatthias Ringwald        "subs r7, %[eccdm1] \n\t" /* r7 = i = k - (uECC_WORDS - 1) (times 4) */
2201*af03003cSMatthias Ringwald
2202*af03003cSMatthias Ringwald        "3: \n\t" /* inner loop */
2203*af03003cSMatthias Ringwald        "push {r3, r4, r5, r6} \n\t" /* push things, r3 (c0) is at the top of stack. */
2204*af03003cSMatthias Ringwald        "subs r0, r6, r7 \n\t"       /* r0 = k - i */
2205*af03003cSMatthias Ringwald
2206*af03003cSMatthias Ringwald        "ldr r4, [r2, r0] \n\t" /* r4 = right[k - i] */
2207*af03003cSMatthias Ringwald        "ldr r0, [r1, r7] \n\t" /* r0 = left[i] */
2208*af03003cSMatthias Ringwald
2209*af03003cSMatthias Ringwald        "lsrs r3, r0, #16 \n\t" /* r3 = a1 */
2210*af03003cSMatthias Ringwald        "uxth r0, r0 \n\t"      /* r0 = a0 */
2211*af03003cSMatthias Ringwald
2212*af03003cSMatthias Ringwald        "lsrs r5, r4, #16 \n\t" /* r5 = b1 */
2213*af03003cSMatthias Ringwald        "uxth r4, r4 \n\t"      /* r4 = b0 */
2214*af03003cSMatthias Ringwald
2215*af03003cSMatthias Ringwald        "movs r6, r3 \n\t"     /* r6 = a1 */
2216*af03003cSMatthias Ringwald        "muls r6, r5, r6 \n\t" /* r6 = a1 * b1 */
2217*af03003cSMatthias Ringwald        "muls r3, r4, r3 \n\t" /* r3 = b0 * a1 */
2218*af03003cSMatthias Ringwald        "muls r5, r0, r5 \n\t" /* r5 = a0 * b1 */
2219*af03003cSMatthias Ringwald        "muls r0, r4, r0 \n\t" /* r0 = a0 * b0 */
2220*af03003cSMatthias Ringwald
2221*af03003cSMatthias Ringwald        "movs r4, #0 \n\t"  /* r4 = 0 */
2222*af03003cSMatthias Ringwald        "adds r3, r5 \n\t"  /* r3 = b0 * a1 + a0 * b1 */
2223*af03003cSMatthias Ringwald        "adcs r4, r4 \n\t"  /* r4 = carry */
2224*af03003cSMatthias Ringwald        "lsls r4, #16 \n\t" /* r4 = carry << 16 */
2225*af03003cSMatthias Ringwald        "adds r6, r4 \n\t"  /* r6 = a1 * b1 + carry */
2226*af03003cSMatthias Ringwald
2227*af03003cSMatthias Ringwald        "lsls r4, r3, #16 \n\t" /* r4 = (b0 * a1 + a0 * b1) << 16 */
2228*af03003cSMatthias Ringwald        "lsrs r3, #16 \n\t"     /* r3 = (b0 * a1 + a0 * b1) >> 16 */
2229*af03003cSMatthias Ringwald        "adds r0, r4 \n\t"      /* r0 = low word = a0 * b0 + ((b0 * a1 + a0 * b1) << 16) */
2230*af03003cSMatthias Ringwald        "adcs r6, r3 \n\t"      /* r6 = high word = a1 * b1 + carry + ((b0 * a1 + a0 * b1) >> 16) */
2231*af03003cSMatthias Ringwald
2232*af03003cSMatthias Ringwald        "pop {r3, r4, r5} \n\t" /* r3 = c0, r4 = c1, r5 = c2 */
2233*af03003cSMatthias Ringwald        "adds r3, r0 \n\t"      /* add low word to c0 */
2234*af03003cSMatthias Ringwald        "adcs r4, r6 \n\t"      /* add high word to c1, including carry */
2235*af03003cSMatthias Ringwald        "movs r0, #0 \n\t"      /* r0 = 0 (does not affect carry bit) */
2236*af03003cSMatthias Ringwald        "adcs r5, r0 \n\t"      /* add carry to c2 */
2237*af03003cSMatthias Ringwald
2238*af03003cSMatthias Ringwald        "pop {r6} \n\t" /* r6 = k */
2239*af03003cSMatthias Ringwald
2240*af03003cSMatthias Ringwald        "adds r7, #4 \n\t"     /* i += 4 */
2241*af03003cSMatthias Ringwald        "cmp r7, %[eccd] \n\t" /* i < uECC_WORDS (times 4)? */
2242*af03003cSMatthias Ringwald        "bge 4f \n\t"          /*   if not, exit the loop */
2243*af03003cSMatthias Ringwald        "cmp r7, r6 \n\t"      /* i <= k? */
2244*af03003cSMatthias Ringwald        "ble 3b \n\t"          /*   if so, continue looping */
2245*af03003cSMatthias Ringwald
2246*af03003cSMatthias Ringwald        "4: \n\t" /* end inner loop */
2247*af03003cSMatthias Ringwald
2248*af03003cSMatthias Ringwald        "ldr r0, [sp, #0] \n\t" /* r0 = result */
2249*af03003cSMatthias Ringwald
2250*af03003cSMatthias Ringwald        "str r3, [r0, r6] \n\t"   /* result[k] = c0 */
2251*af03003cSMatthias Ringwald        "mov r3, r4 \n\t"         /* c0 = c1 */
2252*af03003cSMatthias Ringwald        "mov r4, r5 \n\t"         /* c1 = c2 */
2253*af03003cSMatthias Ringwald        "movs r5, #0 \n\t"        /* c2 = 0 */
2254*af03003cSMatthias Ringwald        "adds r6, #4 \n\t"        /* k += 4 */
2255*af03003cSMatthias Ringwald        "cmp r6, %[eccd] \n\t"    /* k < uECC_WORDS (times 4) ? */
2256*af03003cSMatthias Ringwald        "blt 1b \n\t"             /*   if not, loop back, start with i = 0 */
2257*af03003cSMatthias Ringwald        "cmp r6, %[eccd2m1] \n\t" /* k < uECC_WORDS * 2 - 1 (times 4) ? */
2258*af03003cSMatthias Ringwald        "blt 2b \n\t"             /*   if not, loop back, start with i = (k + 1) - uECC_WORDS */
2259*af03003cSMatthias Ringwald        /* end outer loop */
2260*af03003cSMatthias Ringwald
2261*af03003cSMatthias Ringwald        "str r3, [r0, r6] \n\t" /* result[uECC_WORDS * 2 - 1] = c0 */
2262*af03003cSMatthias Ringwald        "pop {r0} \n\t"         /* pop result off the stack */
2263*af03003cSMatthias Ringwald
2264*af03003cSMatthias Ringwald        ".syntax divided \n\t"
2265*af03003cSMatthias Ringwald        :
2266*af03003cSMatthias Ringwald        : [r0] "l" (r0), [r1] "l" (r1), [r2] "l" (r2), [eccd] "I" (uECC_WORDS * 4), [eccdm1] "I" ((uECC_WORDS-1) * 4), [eccd2m1] "I" ((uECC_WORDS * 2 - 1) * 4)
2267*af03003cSMatthias Ringwald        : "r3", "r4", "r5", "r6", "r7", "cc", "memory"
2268*af03003cSMatthias Ringwald    );
2269*af03003cSMatthias Ringwald#endif
2270*af03003cSMatthias Ringwald}
2271*af03003cSMatthias Ringwald#define asm_mult 1
2272*af03003cSMatthias Ringwald#endif /* !asm_mult */
2273*af03003cSMatthias Ringwald
2274*af03003cSMatthias Ringwald#if uECC_SQUARE_FUNC
2275*af03003cSMatthias Ringwald#if !asm_square
2276*af03003cSMatthias Ringwaldstatic void vli_square(uint32_t *result, const uint32_t *left) {
2277*af03003cSMatthias Ringwald#if (uECC_PLATFORM != uECC_arm_thumb)
2278*af03003cSMatthias Ringwald    uint32_t c0 = 0;
2279*af03003cSMatthias Ringwald    uint32_t c1 = 0;
2280*af03003cSMatthias Ringwald    uint32_t c2 = 0;
2281*af03003cSMatthias Ringwald    uint32_t k = 0;
2282*af03003cSMatthias Ringwald    uint32_t i, tt;
2283*af03003cSMatthias Ringwald    uint32_t t0, t1;
2284*af03003cSMatthias Ringwald
2285*af03003cSMatthias Ringwald    __asm__ volatile (
2286*af03003cSMatthias Ringwald        ".syntax unified \n\t"
2287*af03003cSMatthias Ringwald
2288*af03003cSMatthias Ringwald        "1: \n\t" /* outer loop (k < uECC_WORDS) */
2289*af03003cSMatthias Ringwald        "movs %[i], #0 \n\t" /* i = 0 */
2290*af03003cSMatthias Ringwald        "b 3f \n\t"
2291*af03003cSMatthias Ringwald
2292*af03003cSMatthias Ringwald        "2: \n\t" /* outer loop (k >= uECC_WORDS) */
2293*af03003cSMatthias Ringwald        "movs %[i], %[k] \n\t"      /* i = k */
2294*af03003cSMatthias Ringwald        "subs %[i], %[eccdm1] \n\t" /* i = k - (uECC_WORDS - 1) (times 4) */
2295*af03003cSMatthias Ringwald
2296*af03003cSMatthias Ringwald        "3: \n\t" /* inner loop */
2297*af03003cSMatthias Ringwald        "subs %[tt], %[k], %[i] \n\t" /* tt = k-i */
2298*af03003cSMatthias Ringwald
2299*af03003cSMatthias Ringwald        "ldr %[t1], [%[left], %[tt]] \n\t" /* t1 = left[k - i] */
2300*af03003cSMatthias Ringwald        "ldr %[t0], [%[left], %[i]] \n\t"  /* t0 = left[i] */
2301*af03003cSMatthias Ringwald
2302*af03003cSMatthias Ringwald        "umull %[t0], %[t1], %[t0], %[t1] \n\t" /* (t0, t1) = left[i] * right[k - i] */
2303*af03003cSMatthias Ringwald
2304*af03003cSMatthias Ringwald        "cmp %[i], %[tt] \n\t" /* (i < k - i) ? */
2305*af03003cSMatthias Ringwald        "bge 4f \n\t"          /*   if i >= k - i, skip */
2306*af03003cSMatthias Ringwald        "lsls %[t1], #1 \n\t"  /* high word << 1 */
2307*af03003cSMatthias Ringwald        "adc %[c2], #0 \n\t"   /* add carry bit to c2 */
2308*af03003cSMatthias Ringwald        "lsls %[t0], #1 \n\t"  /* low word << 1 */
2309*af03003cSMatthias Ringwald        "adc %[t1], #0 \n\t"   /* add carry bit to high word */
2310*af03003cSMatthias Ringwald
2311*af03003cSMatthias Ringwald        "4: \n\t"
2312*af03003cSMatthias Ringwald
2313*af03003cSMatthias Ringwald        "adds %[c0], %[t0] \n\t" /* add low word to c0 */
2314*af03003cSMatthias Ringwald        "adcs %[c1], %[t1] \n\t" /* add high word to c1, including carry */
2315*af03003cSMatthias Ringwald        "adc %[c2], #0 \n\t"     /* add carry to c2 */
2316*af03003cSMatthias Ringwald
2317*af03003cSMatthias Ringwald        "adds %[i], #4 \n\t"          /* i += 4 */
2318*af03003cSMatthias Ringwald        "cmp %[i], %[k] \n\t"         /* i <= k? */
2319*af03003cSMatthias Ringwald        "bge 5f \n\t"                 /*   if not, exit the loop */
2320*af03003cSMatthias Ringwald        "subs %[tt], %[k], %[i] \n\t" /* tt = k - i */
2321*af03003cSMatthias Ringwald        "cmp %[i], %[tt] \n\t"        /* i <= k - i? */
2322*af03003cSMatthias Ringwald        "ble 3b \n\t"                 /*   if so, continue looping */
2323*af03003cSMatthias Ringwald
2324*af03003cSMatthias Ringwald        "5: \n\t" /* end inner loop */
2325*af03003cSMatthias Ringwald
2326*af03003cSMatthias Ringwald        "str %[c0], [%[result], %[k]] \n\t" /* result[k] = c0 */
2327*af03003cSMatthias Ringwald        "mov %[c0], %[c1] \n\t"     /* c0 = c1 */
2328*af03003cSMatthias Ringwald        "mov %[c1], %[c2] \n\t"     /* c1 = c2 */
2329*af03003cSMatthias Ringwald        "movs %[c2], #0 \n\t"       /* c2 = 0 */
2330*af03003cSMatthias Ringwald        "adds %[k], #4 \n\t"        /* k += 4 */
2331*af03003cSMatthias Ringwald        "cmp %[k], %[eccd] \n\t"    /* k < uECC_WORDS (times 4) ? */
2332*af03003cSMatthias Ringwald        "blt 1b \n\t"               /*   if not, loop back, start with i = 0 */
2333*af03003cSMatthias Ringwald        "cmp %[k], %[eccd2m1] \n\t" /* k < uECC_WORDS * 2 - 1 (times 4) ? */
2334*af03003cSMatthias Ringwald        "blt 2b \n\t"               /*   if not, loop back, start with i = (k + 1) - uECC_WORDS */
2335*af03003cSMatthias Ringwald        /* end outer loop */
2336*af03003cSMatthias Ringwald
2337*af03003cSMatthias Ringwald        "str %[c0], [%[result], %[k]] \n\t" /* result[uECC_WORDS * 2 - 1] = c0 */
2338*af03003cSMatthias Ringwald    #if (uECC_PLATFORM != uECC_arm_thumb2)
2339*af03003cSMatthias Ringwald        ".syntax divided \n\t"
2340*af03003cSMatthias Ringwald    #endif
2341*af03003cSMatthias Ringwald        : [c0] "+r" (c0), [c1] "+r" (c1), [c2] "+r" (c2),
2342*af03003cSMatthias Ringwald          [k] "+r" (k), [i] "=&r" (i), [tt] "=&r" (tt), [t0] "=&r" (t0), [t1] "=&r" (t1)
2343*af03003cSMatthias Ringwald        : [result] "r" (result), [left] "r" (left),
2344*af03003cSMatthias Ringwald          [eccd] "I" (uECC_WORDS * 4), [eccdm1] "I" ((uECC_WORDS-1) * 4),
2345*af03003cSMatthias Ringwald          [eccd2m1] "I" ((uECC_WORDS * 2 - 1) * 4)
2346*af03003cSMatthias Ringwald        : "cc", "memory"
2347*af03003cSMatthias Ringwald    );
2348*af03003cSMatthias Ringwald
2349*af03003cSMatthias Ringwald#else
2350*af03003cSMatthias Ringwald
2351*af03003cSMatthias Ringwald    register uint32_t *r0 __asm__("r0") = result;
2352*af03003cSMatthias Ringwald    register const uint32_t *r1 __asm__("r1") = left;
2353*af03003cSMatthias Ringwald
2354*af03003cSMatthias Ringwald    __asm__ volatile (
2355*af03003cSMatthias Ringwald        ".syntax unified \n\t"
2356*af03003cSMatthias Ringwald        "movs r2, #0 \n\t" /* c0 = 0 */
2357*af03003cSMatthias Ringwald        "movs r3, #0 \n\t" /* c1 = 0 */
2358*af03003cSMatthias Ringwald        "movs r4, #0 \n\t" /* c2 = 0 */
2359*af03003cSMatthias Ringwald        "movs r5, #0 \n\t" /* k = 0 */
2360*af03003cSMatthias Ringwald
2361*af03003cSMatthias Ringwald        "push {r0} \n\t" /* keep result on the stack */
2362*af03003cSMatthias Ringwald
2363*af03003cSMatthias Ringwald        "1: \n\t" /* outer loop (k < uECC_WORDS) */
2364*af03003cSMatthias Ringwald        "movs r6, #0 \n\t" /* r6 = i = 0 */
2365*af03003cSMatthias Ringwald        "b 3f \n\t"
2366*af03003cSMatthias Ringwald
2367*af03003cSMatthias Ringwald        "2: \n\t" /* outer loop (k >= uECC_WORDS) */
2368*af03003cSMatthias Ringwald        "movs r6, r5 \n\t"        /* r6 = k */
2369*af03003cSMatthias Ringwald        "subs r6, %[eccdm1] \n\t" /* r6 = i = k - (uECC_WORDS - 1) (times 4) */
2370*af03003cSMatthias Ringwald
2371*af03003cSMatthias Ringwald        "3: \n\t" /* inner loop */
2372*af03003cSMatthias Ringwald        "push {r2, r3, r4, r5} \n\t" /* push things, r2 (c0) is at the top of stack. */
2373*af03003cSMatthias Ringwald        "subs r7, r5, r6 \n\t"       /* r7 = k - i */
2374*af03003cSMatthias Ringwald
2375*af03003cSMatthias Ringwald        "ldr r3, [r1, r7] \n\t" /* r3 = left[k - i] */
2376*af03003cSMatthias Ringwald        "ldr r0, [r1, r6] \n\t" /* r0 = left[i] */
2377*af03003cSMatthias Ringwald
2378*af03003cSMatthias Ringwald        "lsrs r2, r0, #16 \n\t" /* r2 = a1 */
2379*af03003cSMatthias Ringwald        "uxth r0, r0 \n\t"      /* r0 = a0 */
2380*af03003cSMatthias Ringwald
2381*af03003cSMatthias Ringwald        "lsrs r4, r3, #16 \n\t" /* r4 = b1 */
2382*af03003cSMatthias Ringwald        "uxth r3, r3 \n\t"      /* r3 = b0 */
2383*af03003cSMatthias Ringwald
2384*af03003cSMatthias Ringwald        "movs r5, r2 \n\t"     /* r5 = a1 */
2385*af03003cSMatthias Ringwald        "muls r5, r4, r5 \n\t" /* r5 = a1 * b1 */
2386*af03003cSMatthias Ringwald        "muls r2, r3, r2 \n\t" /* r2 = b0 * a1 */
2387*af03003cSMatthias Ringwald        "muls r4, r0, r4 \n\t" /* r4 = a0 * b1 */
2388*af03003cSMatthias Ringwald        "muls r0, r3, r0 \n\t" /* r0 = a0 * b0 */
2389*af03003cSMatthias Ringwald
2390*af03003cSMatthias Ringwald        "movs r3, #0 \n\t"  /* r3 = 0 */
2391*af03003cSMatthias Ringwald        "adds r2, r4 \n\t"  /* r2 = b0 * a1 + a0 * b1 */
2392*af03003cSMatthias Ringwald        "adcs r3, r3 \n\t"  /* r3 = carry */
2393*af03003cSMatthias Ringwald        "lsls r3, #16 \n\t" /* r3 = carry << 16 */
2394*af03003cSMatthias Ringwald        "adds r5, r3 \n\t"  /* r5 = a1 * b1 + carry */
2395*af03003cSMatthias Ringwald
2396*af03003cSMatthias Ringwald        "lsls r3, r2, #16 \n\t" /* r3 = (b0 * a1 + a0 * b1) << 16 */
2397*af03003cSMatthias Ringwald        "lsrs r2, #16 \n\t"     /* r2 = (b0 * a1 + a0 * b1) >> 16 */
2398*af03003cSMatthias Ringwald        "adds r0, r3 \n\t"      /* r0 = low word = a0 * b0 + ((b0 * a1 + a0 * b1) << 16) */
2399*af03003cSMatthias Ringwald        "adcs r5, r2 \n\t"      /* r5 = high word = a1 * b1 + carry + ((b0 * a1 + a0 * b1) >> 16) */
2400*af03003cSMatthias Ringwald
2401*af03003cSMatthias Ringwald        "movs r3, #0 \n\t"  /* r3 = 0 */
2402*af03003cSMatthias Ringwald        "cmp r6, r7 \n\t"   /* (i < k - i) ? */
2403*af03003cSMatthias Ringwald        "mov r7, r3 \n\t"   /* r7 = 0 (does not affect condition)*/
2404*af03003cSMatthias Ringwald        "bge 4f \n\t"       /*   if i >= k - i, skip */
2405*af03003cSMatthias Ringwald        "lsls r5, #1 \n\t"  /* high word << 1 */
2406*af03003cSMatthias Ringwald        "adcs r7, r3 \n\t"  /* r7 = carry bit for c2 */
2407*af03003cSMatthias Ringwald        "lsls r0, #1 \n\t"  /* low word << 1 */
2408*af03003cSMatthias Ringwald        "adcs r5, r3 \n\t"  /* add carry from shift to high word */
2409*af03003cSMatthias Ringwald
2410*af03003cSMatthias Ringwald        "4: \n\t"
2411*af03003cSMatthias Ringwald        "pop {r2, r3, r4} \n\t" /* r2 = c0, r3 = c1, r4 = c2 */
2412*af03003cSMatthias Ringwald        "adds r2, r0 \n\t"      /* add low word to c0 */
2413*af03003cSMatthias Ringwald        "adcs r3, r5 \n\t"      /* add high word to c1, including carry */
2414*af03003cSMatthias Ringwald        "movs r0, #0 \n\t"      /* r0 = 0 (does not affect carry bit) */
2415*af03003cSMatthias Ringwald        "adcs r4, r0 \n\t"      /* add carry to c2 */
2416*af03003cSMatthias Ringwald        "adds r4, r7 \n\t"      /* add carry from doubling (if any) */
2417*af03003cSMatthias Ringwald
2418*af03003cSMatthias Ringwald        "pop {r5} \n\t" /* r5 = k */
2419*af03003cSMatthias Ringwald
2420*af03003cSMatthias Ringwald        "adds r6, #4 \n\t"     /* i += 4 */
2421*af03003cSMatthias Ringwald        "cmp r6, r5 \n\t"      /* i <= k? */
2422*af03003cSMatthias Ringwald        "bge 5f \n\t"          /*   if not, exit the loop */
2423*af03003cSMatthias Ringwald        "subs r7, r5, r6 \n\t" /* r7 = k - i */
2424*af03003cSMatthias Ringwald        "cmp r6, r7 \n\t"      /* i <= k - i? */
2425*af03003cSMatthias Ringwald        "ble 3b \n\t"          /*   if so, continue looping */
2426*af03003cSMatthias Ringwald
2427*af03003cSMatthias Ringwald        "5: \n\t" /* end inner loop */
2428*af03003cSMatthias Ringwald
2429*af03003cSMatthias Ringwald        "ldr r0, [sp, #0] \n\t" /* r0 = result */
2430*af03003cSMatthias Ringwald
2431*af03003cSMatthias Ringwald        "str r2, [r0, r5] \n\t"   /* result[k] = c0 */
2432*af03003cSMatthias Ringwald        "mov r2, r3 \n\t"         /* c0 = c1 */
2433*af03003cSMatthias Ringwald        "mov r3, r4 \n\t"         /* c1 = c2 */
2434*af03003cSMatthias Ringwald        "movs r4, #0 \n\t"        /* c2 = 0 */
2435*af03003cSMatthias Ringwald        "adds r5, #4 \n\t"        /* k += 4 */
2436*af03003cSMatthias Ringwald        "cmp r5, %[eccd] \n\t"    /* k < uECC_WORDS (times 4) ? */
2437*af03003cSMatthias Ringwald        "blt 1b \n\t"             /*   if not, loop back, start with i = 0 */
2438*af03003cSMatthias Ringwald        "cmp r5, %[eccd2m1] \n\t" /* k < uECC_WORDS * 2 - 1 (times 4) ? */
2439*af03003cSMatthias Ringwald        "blt 2b \n\t"             /*   if not, loop back, start with i = (k + 1) - uECC_WORDS */
2440*af03003cSMatthias Ringwald        /* end outer loop */
2441*af03003cSMatthias Ringwald
2442*af03003cSMatthias Ringwald        "str r2, [r0, r5] \n\t" /* result[uECC_WORDS * 2 - 1] = c0 */
2443*af03003cSMatthias Ringwald        "pop {r0} \n\t"        /* pop result off the stack */
2444*af03003cSMatthias Ringwald
2445*af03003cSMatthias Ringwald        ".syntax divided \n\t"
2446*af03003cSMatthias Ringwald        : [r0] "+l" (r0), [r1] "+l" (r1)
2447*af03003cSMatthias Ringwald        : [eccd] "I" (uECC_WORDS * 4), [eccdm1] "I" ((uECC_WORDS-1) * 4),
2448*af03003cSMatthias Ringwald          [eccd2m1] "I" ((uECC_WORDS * 2 - 1) * 4)
2449*af03003cSMatthias Ringwald        : "r2", "r3", "r4", "r5", "r6", "r7", "cc", "memory"
2450*af03003cSMatthias Ringwald    );
2451*af03003cSMatthias Ringwald#endif
2452*af03003cSMatthias Ringwald}
2453*af03003cSMatthias Ringwald#define asm_square 1
2454*af03003cSMatthias Ringwald#endif /* !asm_square */
2455*af03003cSMatthias Ringwald#endif /* uECC_SQUARE_FUNC */
2456