37 #ifndef MBEDTLS_BN_MUL_H
38 #define MBEDTLS_BN_MUL_H
42 #if defined(MBEDTLS_HAVE_ASM)
49 #if defined(__GNUC__) && \
50 ( !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000 )
53 #define MULADDC_INIT \
55 "movl %%ebx, %0 \n\t" \
56 "movl %5, %%esi \n\t" \
57 "movl %6, %%edi \n\t" \
58 "movl %7, %%ecx \n\t" \
61 #define MULADDC_CORE \
64 "addl %%ecx, %%eax \n\t" \
65 "adcl $0, %%edx \n\t" \
66 "addl (%%edi), %%eax \n\t" \
67 "adcl $0, %%edx \n\t" \
68 "movl %%edx, %%ecx \n\t" \
71 #if defined(MBEDTLS_HAVE_SSE2)
73 #define MULADDC_HUIT \
74 "movd %%ecx, %%mm1 \n\t" \
75 "movd %%ebx, %%mm0 \n\t" \
76 "movd (%%edi), %%mm3 \n\t" \
77 "paddq %%mm3, %%mm1 \n\t" \
78 "movd (%%esi), %%mm2 \n\t" \
79 "pmuludq %%mm0, %%mm2 \n\t" \
80 "movd 4(%%esi), %%mm4 \n\t" \
81 "pmuludq %%mm0, %%mm4 \n\t" \
82 "movd 8(%%esi), %%mm6 \n\t" \
83 "pmuludq %%mm0, %%mm6 \n\t" \
84 "movd 12(%%esi), %%mm7 \n\t" \
85 "pmuludq %%mm0, %%mm7 \n\t" \
86 "paddq %%mm2, %%mm1 \n\t" \
87 "movd 4(%%edi), %%mm3 \n\t" \
88 "paddq %%mm4, %%mm3 \n\t" \
89 "movd 8(%%edi), %%mm5 \n\t" \
90 "paddq %%mm6, %%mm5 \n\t" \
91 "movd 12(%%edi), %%mm4 \n\t" \
92 "paddq %%mm4, %%mm7 \n\t" \
93 "movd %%mm1, (%%edi) \n\t" \
94 "movd 16(%%esi), %%mm2 \n\t" \
95 "pmuludq %%mm0, %%mm2 \n\t" \
96 "psrlq $32, %%mm1 \n\t" \
97 "movd 20(%%esi), %%mm4 \n\t" \
98 "pmuludq %%mm0, %%mm4 \n\t" \
99 "paddq %%mm3, %%mm1 \n\t" \
100 "movd 24(%%esi), %%mm6 \n\t" \
101 "pmuludq %%mm0, %%mm6 \n\t" \
102 "movd %%mm1, 4(%%edi) \n\t" \
103 "psrlq $32, %%mm1 \n\t" \
104 "movd 28(%%esi), %%mm3 \n\t" \
105 "pmuludq %%mm0, %%mm3 \n\t" \
106 "paddq %%mm5, %%mm1 \n\t" \
107 "movd 16(%%edi), %%mm5 \n\t" \
108 "paddq %%mm5, %%mm2 \n\t" \
109 "movd %%mm1, 8(%%edi) \n\t" \
110 "psrlq $32, %%mm1 \n\t" \
111 "paddq %%mm7, %%mm1 \n\t" \
112 "movd 20(%%edi), %%mm5 \n\t" \
113 "paddq %%mm5, %%mm4 \n\t" \
114 "movd %%mm1, 12(%%edi) \n\t" \
115 "psrlq $32, %%mm1 \n\t" \
116 "paddq %%mm2, %%mm1 \n\t" \
117 "movd 24(%%edi), %%mm5 \n\t" \
118 "paddq %%mm5, %%mm6 \n\t" \
119 "movd %%mm1, 16(%%edi) \n\t" \
120 "psrlq $32, %%mm1 \n\t" \
121 "paddq %%mm4, %%mm1 \n\t" \
122 "movd 28(%%edi), %%mm5 \n\t" \
123 "paddq %%mm5, %%mm3 \n\t" \
124 "movd %%mm1, 20(%%edi) \n\t" \
125 "psrlq $32, %%mm1 \n\t" \
126 "paddq %%mm6, %%mm1 \n\t" \
127 "movd %%mm1, 24(%%edi) \n\t" \
128 "psrlq $32, %%mm1 \n\t" \
129 "paddq %%mm3, %%mm1 \n\t" \
130 "movd %%mm1, 28(%%edi) \n\t" \
131 "addl $32, %%edi \n\t" \
132 "addl $32, %%esi \n\t" \
133 "psrlq $32, %%mm1 \n\t" \
134 "movd %%mm1, %%ecx \n\t"
136 #define MULADDC_STOP \
138 "movl %4, %%ebx \n\t" \
139 "movl %%ecx, %1 \n\t" \
140 "movl %%edi, %2 \n\t" \
141 "movl %%esi, %3 \n\t" \
142 : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \
143 : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \
144 : "eax", "ecx", "edx", "esi", "edi" \
149 #define MULADDC_STOP \
150 "movl %4, %%ebx \n\t" \
151 "movl %%ecx, %1 \n\t" \
152 "movl %%edi, %2 \n\t" \
153 "movl %%esi, %3 \n\t" \
154 : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \
155 : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \
156 : "eax", "ecx", "edx", "esi", "edi" \
161 #if defined(__amd64__) || defined (__x86_64__)
163 #define MULADDC_INIT \
165 "movq %3, %%rsi \n\t" \
166 "movq %4, %%rdi \n\t" \
167 "movq %5, %%rcx \n\t" \
168 "movq %6, %%rbx \n\t" \
169 "xorq %%r8, %%r8 \n\t"
171 #define MULADDC_CORE \
172 "movq (%%rsi), %%rax \n\t" \
174 "addq $8, %%rsi \n\t" \
175 "addq %%rcx, %%rax \n\t" \
176 "movq %%r8, %%rcx \n\t" \
177 "adcq $0, %%rdx \n\t" \
179 "addq %%rax, (%%rdi) \n\t" \
180 "adcq %%rdx, %%rcx \n\t" \
181 "addq $8, %%rdi \n\t"
183 #define MULADDC_STOP \
184 "movq %%rcx, %0 \n\t" \
185 "movq %%rdi, %1 \n\t" \
186 "movq %%rsi, %2 \n\t" \
187 : "=m" (c), "=m" (d), "=m" (s) \
188 : "m" (s), "m" (d), "m" (c), "m" (b) \
189 : "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" \
194 #if defined(__mc68020__) || defined(__mcpu32__)
196 #define MULADDC_INIT \
198 "movl %3, %%a2 \n\t" \
199 "movl %4, %%a3 \n\t" \
200 "movl %5, %%d3 \n\t" \
201 "movl %6, %%d2 \n\t" \
202 "moveq #0, %%d0 \n\t"
204 #define MULADDC_CORE \
205 "movel %%a2@+, %%d1 \n\t" \
206 "mulul %%d2, %%d4:%%d1 \n\t" \
207 "addl %%d3, %%d1 \n\t" \
208 "addxl %%d0, %%d4 \n\t" \
209 "moveq #0, %%d3 \n\t" \
210 "addl %%d1, %%a3@+ \n\t" \
211 "addxl %%d4, %%d3 \n\t"
213 #define MULADDC_STOP \
214 "movl %%d3, %0 \n\t" \
215 "movl %%a3, %1 \n\t" \
216 "movl %%a2, %2 \n\t" \
217 : "=m" (c), "=m" (d), "=m" (s) \
218 : "m" (s), "m" (d), "m" (c), "m" (b) \
219 : "d0", "d1", "d2", "d3", "d4", "a2", "a3" \
222 #define MULADDC_HUIT \
223 "movel %%a2@+, %%d1 \n\t" \
224 "mulul %%d2, %%d4:%%d1 \n\t" \
225 "addxl %%d3, %%d1 \n\t" \
226 "addxl %%d0, %%d4 \n\t" \
227 "addl %%d1, %%a3@+ \n\t" \
228 "movel %%a2@+, %%d1 \n\t" \
229 "mulul %%d2, %%d3:%%d1 \n\t" \
230 "addxl %%d4, %%d1 \n\t" \
231 "addxl %%d0, %%d3 \n\t" \
232 "addl %%d1, %%a3@+ \n\t" \
233 "movel %%a2@+, %%d1 \n\t" \
234 "mulul %%d2, %%d4:%%d1 \n\t" \
235 "addxl %%d3, %%d1 \n\t" \
236 "addxl %%d0, %%d4 \n\t" \
237 "addl %%d1, %%a3@+ \n\t" \
238 "movel %%a2@+, %%d1 \n\t" \
239 "mulul %%d2, %%d3:%%d1 \n\t" \
240 "addxl %%d4, %%d1 \n\t" \
241 "addxl %%d0, %%d3 \n\t" \
242 "addl %%d1, %%a3@+ \n\t" \
243 "movel %%a2@+, %%d1 \n\t" \
244 "mulul %%d2, %%d4:%%d1 \n\t" \
245 "addxl %%d3, %%d1 \n\t" \
246 "addxl %%d0, %%d4 \n\t" \
247 "addl %%d1, %%a3@+ \n\t" \
248 "movel %%a2@+, %%d1 \n\t" \
249 "mulul %%d2, %%d3:%%d1 \n\t" \
250 "addxl %%d4, %%d1 \n\t" \
251 "addxl %%d0, %%d3 \n\t" \
252 "addl %%d1, %%a3@+ \n\t" \
253 "movel %%a2@+, %%d1 \n\t" \
254 "mulul %%d2, %%d4:%%d1 \n\t" \
255 "addxl %%d3, %%d1 \n\t" \
256 "addxl %%d0, %%d4 \n\t" \
257 "addl %%d1, %%a3@+ \n\t" \
258 "movel %%a2@+, %%d1 \n\t" \
259 "mulul %%d2, %%d3:%%d1 \n\t" \
260 "addxl %%d4, %%d1 \n\t" \
261 "addxl %%d0, %%d3 \n\t" \
262 "addl %%d1, %%a3@+ \n\t" \
263 "addxl %%d0, %%d3 \n\t"
267 #if defined(__powerpc64__) || defined(__ppc64__)
269 #if defined(__MACH__) && defined(__APPLE__)
271 #define MULADDC_INIT \
277 "addi r3, r3, -8 \n\t" \
278 "addi r4, r4, -8 \n\t" \
279 "addic r5, r5, 0 \n\t"
281 #define MULADDC_CORE \
282 "ldu r7, 8(r3) \n\t" \
283 "mulld r8, r7, r6 \n\t" \
284 "mulhdu r9, r7, r6 \n\t" \
285 "adde r8, r8, r5 \n\t" \
286 "ld r7, 8(r4) \n\t" \
287 "addze r5, r9 \n\t" \
288 "addc r8, r8, r7 \n\t" \
289 "stdu r8, 8(r4) \n\t"
291 #define MULADDC_STOP \
292 "addze r5, r5 \n\t" \
293 "addi r4, r4, 8 \n\t" \
294 "addi r3, r3, 8 \n\t" \
298 : "=m" (c), "=m" (d), "=m" (s) \
299 : "m" (s), "m" (d), "m" (c), "m" (b) \
300 : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
306 #define MULADDC_INIT \
312 "addi %%r3, %%r3, -8 \n\t" \
313 "addi %%r4, %%r4, -8 \n\t" \
314 "addic %%r5, %%r5, 0 \n\t"
316 #define MULADDC_CORE \
317 "ldu %%r7, 8(%%r3) \n\t" \
318 "mulld %%r8, %%r7, %%r6 \n\t" \
319 "mulhdu %%r9, %%r7, %%r6 \n\t" \
320 "adde %%r8, %%r8, %%r5 \n\t" \
321 "ld %%r7, 8(%%r4) \n\t" \
322 "addze %%r5, %%r9 \n\t" \
323 "addc %%r8, %%r8, %%r7 \n\t" \
324 "stdu %%r8, 8(%%r4) \n\t"
326 #define MULADDC_STOP \
327 "addze %%r5, %%r5 \n\t" \
328 "addi %%r4, %%r4, 8 \n\t" \
329 "addi %%r3, %%r3, 8 \n\t" \
330 "std %%r5, %0 \n\t" \
331 "std %%r4, %1 \n\t" \
332 "std %%r3, %2 \n\t" \
333 : "=m" (c), "=m" (d), "=m" (s) \
334 : "m" (s), "m" (d), "m" (c), "m" (b) \
335 : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
340 #elif defined(__powerpc__) || defined(__ppc__)
342 #if defined(__MACH__) && defined(__APPLE__)
344 #define MULADDC_INIT \
350 "addi r3, r3, -4 \n\t" \
351 "addi r4, r4, -4 \n\t" \
352 "addic r5, r5, 0 \n\t"
354 #define MULADDC_CORE \
355 "lwzu r7, 4(r3) \n\t" \
356 "mullw r8, r7, r6 \n\t" \
357 "mulhwu r9, r7, r6 \n\t" \
358 "adde r8, r8, r5 \n\t" \
359 "lwz r7, 4(r4) \n\t" \
360 "addze r5, r9 \n\t" \
361 "addc r8, r8, r7 \n\t" \
362 "stwu r8, 4(r4) \n\t"
364 #define MULADDC_STOP \
365 "addze r5, r5 \n\t" \
366 "addi r4, r4, 4 \n\t" \
367 "addi r3, r3, 4 \n\t" \
371 : "=m" (c), "=m" (d), "=m" (s) \
372 : "m" (s), "m" (d), "m" (c), "m" (b) \
373 : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
378 #define MULADDC_INIT \
380 "lwz %%r3, %3 \n\t" \
381 "lwz %%r4, %4 \n\t" \
382 "lwz %%r5, %5 \n\t" \
383 "lwz %%r6, %6 \n\t" \
384 "addi %%r3, %%r3, -4 \n\t" \
385 "addi %%r4, %%r4, -4 \n\t" \
386 "addic %%r5, %%r5, 0 \n\t"
388 #define MULADDC_CORE \
389 "lwzu %%r7, 4(%%r3) \n\t" \
390 "mullw %%r8, %%r7, %%r6 \n\t" \
391 "mulhwu %%r9, %%r7, %%r6 \n\t" \
392 "adde %%r8, %%r8, %%r5 \n\t" \
393 "lwz %%r7, 4(%%r4) \n\t" \
394 "addze %%r5, %%r9 \n\t" \
395 "addc %%r8, %%r8, %%r7 \n\t" \
396 "stwu %%r8, 4(%%r4) \n\t"
398 #define MULADDC_STOP \
399 "addze %%r5, %%r5 \n\t" \
400 "addi %%r4, %%r4, 4 \n\t" \
401 "addi %%r3, %%r3, 4 \n\t" \
402 "stw %%r5, %0 \n\t" \
403 "stw %%r4, %1 \n\t" \
404 "stw %%r3, %2 \n\t" \
405 : "=m" (c), "=m" (d), "=m" (s) \
406 : "m" (s), "m" (d), "m" (c), "m" (b) \
407 : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
418 #if 0 && defined(__sparc__)
419 #if defined(__sparc64__)
421 #define MULADDC_INIT \
423 "ldx %3, %%o0 \n\t" \
424 "ldx %4, %%o1 \n\t" \
428 #define MULADDC_CORE \
429 "ld [%%o0], %%o4 \n\t" \
431 "ld [%%o1], %%o5 \n\t" \
432 "umul %%o3, %%o4, %%o4 \n\t" \
433 "addcc %%o4, %%o2, %%o4 \n\t" \
434 "rd %%y, %%g1 \n\t" \
435 "addx %%g1, 0, %%g1 \n\t" \
436 "addcc %%o4, %%o5, %%o4 \n\t" \
437 "st %%o4, [%%o1] \n\t" \
438 "addx %%g1, 0, %%o2 \n\t" \
441 #define MULADDC_STOP \
443 "stx %%o1, %1 \n\t" \
444 "stx %%o0, %2 \n\t" \
445 : "=m" (c), "=m" (d), "=m" (s) \
446 : "m" (s), "m" (d), "m" (c), "m" (b) \
447 : "g1", "o0", "o1", "o2", "o3", "o4", \
453 #define MULADDC_INIT \
460 #define MULADDC_CORE \
461 "ld [%%o0], %%o4 \n\t" \
463 "ld [%%o1], %%o5 \n\t" \
464 "umul %%o3, %%o4, %%o4 \n\t" \
465 "addcc %%o4, %%o2, %%o4 \n\t" \
466 "rd %%y, %%g1 \n\t" \
467 "addx %%g1, 0, %%g1 \n\t" \
468 "addcc %%o4, %%o5, %%o4 \n\t" \
469 "st %%o4, [%%o1] \n\t" \
470 "addx %%g1, 0, %%o2 \n\t" \
473 #define MULADDC_STOP \
477 : "=m" (c), "=m" (d), "=m" (s) \
478 : "m" (s), "m" (d), "m" (c), "m" (b) \
479 : "g1", "o0", "o1", "o2", "o3", "o4", \
486 #if defined(__microblaze__) || defined(microblaze)
488 #define MULADDC_INIT \
494 "andi r7, r6, 0xffff \n\t" \
495 "bsrli r6, r6, 16 \n\t"
497 #define MULADDC_CORE \
498 "lhui r8, r3, 0 \n\t" \
499 "addi r3, r3, 2 \n\t" \
500 "lhui r9, r3, 0 \n\t" \
501 "addi r3, r3, 2 \n\t" \
502 "mul r10, r9, r6 \n\t" \
503 "mul r11, r8, r7 \n\t" \
504 "mul r12, r9, r7 \n\t" \
505 "mul r13, r8, r6 \n\t" \
506 "bsrli r8, r10, 16 \n\t" \
507 "bsrli r9, r11, 16 \n\t" \
508 "add r13, r13, r8 \n\t" \
509 "add r13, r13, r9 \n\t" \
510 "bslli r10, r10, 16 \n\t" \
511 "bslli r11, r11, 16 \n\t" \
512 "add r12, r12, r10 \n\t" \
513 "addc r13, r13, r0 \n\t" \
514 "add r12, r12, r11 \n\t" \
515 "addc r13, r13, r0 \n\t" \
516 "lwi r10, r4, 0 \n\t" \
517 "add r12, r12, r10 \n\t" \
518 "addc r13, r13, r0 \n\t" \
519 "add r12, r12, r5 \n\t" \
520 "addc r5, r13, r0 \n\t" \
521 "swi r12, r4, 0 \n\t" \
522 "addi r4, r4, 4 \n\t"
524 #define MULADDC_STOP \
528 : "=m" (c), "=m" (d), "=m" (s) \
529 : "m" (s), "m" (d), "m" (c), "m" (b) \
530 : "r3", "r4" "r5", "r6", "r7", "r8", \
531 "r9", "r10", "r11", "r12", "r13" \
536 #if defined(__tricore__)
538 #define MULADDC_INIT \
540 "ld.a %%a2, %3 \n\t" \
541 "ld.a %%a3, %4 \n\t" \
542 "ld.w %%d4, %5 \n\t" \
543 "ld.w %%d1, %6 \n\t" \
544 "xor %%d5, %%d5 \n\t"
546 #define MULADDC_CORE \
547 "ld.w %%d0, [%%a2+] \n\t" \
548 "madd.u %%e2, %%e4, %%d0, %%d1 \n\t" \
549 "ld.w %%d0, [%%a3] \n\t" \
550 "addx %%d2, %%d2, %%d0 \n\t" \
551 "addc %%d3, %%d3, 0 \n\t" \
552 "mov %%d4, %%d3 \n\t" \
553 "st.w [%%a3+], %%d2 \n\t"
555 #define MULADDC_STOP \
556 "st.w %0, %%d4 \n\t" \
557 "st.a %1, %%a3 \n\t" \
558 "st.a %2, %%a2 \n\t" \
559 : "=m" (c), "=m" (d), "=m" (s) \
560 : "m" (s), "m" (d), "m" (c), "m" (b) \
561 : "d0", "d1", "e2", "d4", "a2", "a3" \
568 #if defined(__thumb__) && !defined(__thumb2__)
570 #define MULADDC_INIT \
576 "lsr r7, r3, #16 \n\t" \
578 "lsl r7, r3, #16 \n\t" \
579 "lsr r7, r7, #16 \n\t" \
582 #define MULADDC_CORE \
583 "ldmia r0!, {r6} \n\t" \
584 "lsr r7, r6, #16 \n\t" \
585 "lsl r6, r6, #16 \n\t" \
586 "lsr r6, r6, #16 \n\t" \
595 "lsr r3, r6, #16 \n\t" \
596 "add r5, r5, r3 \n\t" \
597 "lsr r3, r7, #16 \n\t" \
598 "add r5, r5, r3 \n\t" \
599 "add r4, r4, r2 \n\t" \
602 "lsl r3, r6, #16 \n\t" \
603 "add r4, r4, r3 \n\t" \
605 "lsl r3, r7, #16 \n\t" \
606 "add r4, r4, r3 \n\t" \
608 "ldr r3, [r1] \n\t" \
609 "add r4, r4, r3 \n\t" \
611 "stmia r1!, {r4} \n\t"
613 #define MULADDC_STOP \
617 : "=m" (c), "=m" (d), "=m" (s) \
618 : "m" (s), "m" (d), "m" (c), "m" (b) \
619 : "r0", "r1", "r2", "r3", "r4", "r5", \
620 "r6", "r7", "r8", "r9", "cc" \
625 #define MULADDC_INIT \
632 #define MULADDC_CORE \
633 "ldr r4, [r0], #4 \n\t" \
635 "ldr r6, [r1] \n\t" \
636 "umlal r2, r5, r3, r4 \n\t" \
637 "adds r7, r6, r2 \n\t" \
638 "adc r2, r5, #0 \n\t" \
639 "str r7, [r1], #4 \n\t"
641 #define MULADDC_STOP \
645 : "=m" (c), "=m" (d), "=m" (s) \
646 : "m" (s), "m" (d), "m" (c), "m" (b) \
647 : "r0", "r1", "r2", "r3", "r4", "r5", \
655 #if defined(__alpha__)
657 #define MULADDC_INIT \
664 #define MULADDC_CORE \
665 "ldq $6, 0($1) \n\t" \
666 "addq $1, 8, $1 \n\t" \
667 "mulq $6, $4, $7 \n\t" \
668 "umulh $6, $4, $6 \n\t" \
669 "addq $7, $3, $7 \n\t" \
670 "cmpult $7, $3, $3 \n\t" \
671 "ldq $5, 0($2) \n\t" \
672 "addq $7, $5, $7 \n\t" \
673 "cmpult $7, $5, $5 \n\t" \
674 "stq $7, 0($2) \n\t" \
675 "addq $2, 8, $2 \n\t" \
676 "addq $6, $3, $3 \n\t" \
677 "addq $5, $3, $3 \n\t"
679 #define MULADDC_STOP \
683 : "=m" (c), "=m" (d), "=m" (s) \
684 : "m" (s), "m" (d), "m" (c), "m" (b) \
685 : "$1", "$2", "$3", "$4", "$5", "$6", "$7" \
689 #if defined(__mips__) && !defined(__mips64)
691 #define MULADDC_INIT \
698 #define MULADDC_CORE \
699 "lw $14, 0($10) \n\t" \
700 "multu $13, $14 \n\t" \
701 "addi $10, $10, 4 \n\t" \
704 "addu $14, $12, $14 \n\t" \
705 "lw $15, 0($11) \n\t" \
706 "sltu $12, $14, $12 \n\t" \
707 "addu $15, $14, $15 \n\t" \
708 "sltu $14, $15, $14 \n\t" \
709 "addu $12, $12, $9 \n\t" \
710 "sw $15, 0($11) \n\t" \
711 "addu $12, $12, $14 \n\t" \
712 "addi $11, $11, 4 \n\t"
714 #define MULADDC_STOP \
718 : "=m" (c), "=m" (d), "=m" (s) \
719 : "m" (s), "m" (d), "m" (c), "m" (b) \
720 : "$9", "$10", "$11", "$12", "$13", "$14", "$15" \
726 #if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
728 #define MULADDC_INIT \
734 #define MULADDC_CORE \
739 __asm add eax, [edi] \
744 #if defined(MBEDTLS_HAVE_SSE2)
746 #define EMIT __asm _emit
748 #define MULADDC_HUIT \
749 EMIT 0x0F EMIT 0x6E EMIT 0xC9 \
750 EMIT 0x0F EMIT 0x6E EMIT 0xC3 \
751 EMIT 0x0F EMIT 0x6E EMIT 0x1F \
752 EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
753 EMIT 0x0F EMIT 0x6E EMIT 0x16 \
754 EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
755 EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \
756 EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
757 EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \
758 EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
759 EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \
760 EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \
761 EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
762 EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \
763 EMIT 0x0F EMIT 0xD4 EMIT 0xDC \
764 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \
765 EMIT 0x0F EMIT 0xD4 EMIT 0xEE \
766 EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \
767 EMIT 0x0F EMIT 0xD4 EMIT 0xFC \
768 EMIT 0x0F EMIT 0x7E EMIT 0x0F \
769 EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \
770 EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
771 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
772 EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \
773 EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
774 EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
775 EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \
776 EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
777 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \
778 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
779 EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \
780 EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \
781 EMIT 0x0F EMIT 0xD4 EMIT 0xCD \
782 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \
783 EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \
784 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \
785 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
786 EMIT 0x0F EMIT 0xD4 EMIT 0xCF \
787 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \
788 EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \
789 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \
790 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
791 EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
792 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \
793 EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \
794 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \
795 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
796 EMIT 0x0F EMIT 0xD4 EMIT 0xCC \
797 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \
798 EMIT 0x0F EMIT 0xD4 EMIT 0xDD \
799 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \
800 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
801 EMIT 0x0F EMIT 0xD4 EMIT 0xCE \
802 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \
803 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
804 EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
805 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \
806 EMIT 0x83 EMIT 0xC7 EMIT 0x20 \
807 EMIT 0x83 EMIT 0xC6 EMIT 0x20 \
808 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
809 EMIT 0x0F EMIT 0x7E EMIT 0xC9
811 #define MULADDC_STOP \
812 EMIT 0x0F EMIT 0x77 \
819 #define MULADDC_STOP \
829 #if !defined(MULADDC_CORE)
830 #if defined(MBEDTLS_HAVE_UDBL)
832 #define MULADDC_INIT \
835 mbedtls_mpi_uint r0, r1;
837 #define MULADDC_CORE \
838 r = *(s++) * (mbedtls_t_udbl) b; \
839 r0 = (mbedtls_mpi_uint) r; \
840 r1 = (mbedtls_mpi_uint)( r >> biL ); \
841 r0 += c; r1 += (r0 < c); \
842 r0 += *d; r1 += (r0 < *d); \
845 #define MULADDC_STOP \
849 #define MULADDC_INIT \
851 mbedtls_mpi_uint s0, s1, b0, b1; \
852 mbedtls_mpi_uint r0, r1, rx, ry; \
853 b0 = ( b << biH ) >> biH; \
856 #define MULADDC_CORE \
857 s0 = ( *s << biH ) >> biH; \
858 s1 = ( *s >> biH ); s++; \
859 rx = s0 * b1; r0 = s0 * b0; \
860 ry = s1 * b0; r1 = s1 * b1; \
861 r1 += ( rx >> biH ); \
862 r1 += ( ry >> biH ); \
863 rx <<= biH; ry <<= biH; \
864 r0 += rx; r1 += (r0 < rx); \
865 r0 += ry; r1 += (r0 < ry); \
866 r0 += c; r1 += (r0 < c); \
867 r0 += *d; r1 += (r0 < *d); \
870 #define MULADDC_STOP \
Multi-precision integer library.