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 "xorq %%r8, %%r8 \n\t" 167 #define MULADDC_CORE \ 168 "movq (%%rsi), %%rax \n\t" \ 170 "addq $8, %%rsi \n\t" \ 171 "addq %%rcx, %%rax \n\t" \ 172 "movq %%r8, %%rcx \n\t" \ 173 "adcq $0, %%rdx \n\t" \ 175 "addq %%rax, (%%rdi) \n\t" \ 176 "adcq %%rdx, %%rcx \n\t" \ 177 "addq $8, %%rdi \n\t" 179 #define MULADDC_STOP \ 180 : "+c" (c), "+D" (d), "+S" (s) \ 182 : "rax", "rdx", "r8" \ 187 #if defined(__mc68020__) || defined(__mcpu32__) 189 #define MULADDC_INIT \ 191 "movl %3, %%a2 \n\t" \ 192 "movl %4, %%a3 \n\t" \ 193 "movl %5, %%d3 \n\t" \ 194 "movl %6, %%d2 \n\t" \ 195 "moveq #0, %%d0 \n\t" 197 #define MULADDC_CORE \ 198 "movel %%a2@+, %%d1 \n\t" \ 199 "mulul %%d2, %%d4:%%d1 \n\t" \ 200 "addl %%d3, %%d1 \n\t" \ 201 "addxl %%d0, %%d4 \n\t" \ 202 "moveq #0, %%d3 \n\t" \ 203 "addl %%d1, %%a3@+ \n\t" \ 204 "addxl %%d4, %%d3 \n\t" 206 #define MULADDC_STOP \ 207 "movl %%d3, %0 \n\t" \ 208 "movl %%a3, %1 \n\t" \ 209 "movl %%a2, %2 \n\t" \ 210 : "=m" (c), "=m" (d), "=m" (s) \ 211 : "m" (s), "m" (d), "m" (c), "m" (b) \ 212 : "d0", "d1", "d2", "d3", "d4", "a2", "a3" \ 215 #define MULADDC_HUIT \ 216 "movel %%a2@+, %%d1 \n\t" \ 217 "mulul %%d2, %%d4:%%d1 \n\t" \ 218 "addxl %%d3, %%d1 \n\t" \ 219 "addxl %%d0, %%d4 \n\t" \ 220 "addl %%d1, %%a3@+ \n\t" \ 221 "movel %%a2@+, %%d1 \n\t" \ 222 "mulul %%d2, %%d3:%%d1 \n\t" \ 223 "addxl %%d4, %%d1 \n\t" \ 224 "addxl %%d0, %%d3 \n\t" \ 225 "addl %%d1, %%a3@+ \n\t" \ 226 "movel %%a2@+, %%d1 \n\t" \ 227 "mulul %%d2, %%d4:%%d1 \n\t" \ 228 "addxl %%d3, %%d1 \n\t" \ 229 "addxl %%d0, %%d4 \n\t" \ 230 "addl %%d1, %%a3@+ \n\t" \ 231 "movel %%a2@+, %%d1 \n\t" \ 232 "mulul %%d2, %%d3:%%d1 \n\t" \ 233 "addxl %%d4, %%d1 \n\t" \ 234 "addxl %%d0, %%d3 \n\t" \ 235 "addl %%d1, %%a3@+ \n\t" \ 236 "movel %%a2@+, %%d1 \n\t" \ 237 "mulul %%d2, %%d4:%%d1 \n\t" \ 238 "addxl %%d3, %%d1 \n\t" \ 239 "addxl %%d0, %%d4 \n\t" \ 240 "addl %%d1, %%a3@+ \n\t" \ 241 "movel %%a2@+, %%d1 \n\t" \ 242 "mulul %%d2, %%d3:%%d1 \n\t" \ 243 "addxl %%d4, %%d1 \n\t" \ 244 "addxl %%d0, %%d3 \n\t" \ 245 "addl %%d1, %%a3@+ \n\t" \ 246 "movel %%a2@+, %%d1 \n\t" \ 247 "mulul %%d2, %%d4:%%d1 \n\t" \ 248 "addxl %%d3, %%d1 \n\t" \ 249 "addxl %%d0, %%d4 \n\t" \ 250 "addl %%d1, %%a3@+ \n\t" \ 251 "movel %%a2@+, %%d1 \n\t" \ 252 "mulul %%d2, %%d3:%%d1 \n\t" \ 253 "addxl %%d4, %%d1 \n\t" \ 254 "addxl %%d0, %%d3 \n\t" \ 255 "addl %%d1, %%a3@+ \n\t" \ 256 "addxl %%d0, %%d3 \n\t" 260 #if defined(__powerpc64__) || defined(__ppc64__) 262 #if defined(__MACH__) && defined(__APPLE__) 264 #define MULADDC_INIT \ 270 "addi r3, r3, -8 \n\t" \ 271 "addi r4, r4, -8 \n\t" \ 272 "addic r5, r5, 0 \n\t" 274 #define MULADDC_CORE \ 275 "ldu r7, 8(r3) \n\t" \ 276 "mulld r8, r7, r6 \n\t" \ 277 "mulhdu r9, r7, r6 \n\t" \ 278 "adde r8, r8, r5 \n\t" \ 279 "ld r7, 8(r4) \n\t" \ 280 "addze r5, r9 \n\t" \ 281 "addc r8, r8, r7 \n\t" \ 282 "stdu r8, 8(r4) \n\t" 284 #define MULADDC_STOP \ 285 "addze r5, r5 \n\t" \ 286 "addi r4, r4, 8 \n\t" \ 287 "addi r3, r3, 8 \n\t" \ 291 : "=m" (c), "=m" (d), "=m" (s) \ 292 : "m" (s), "m" (d), "m" (c), "m" (b) \ 293 : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ 299 #define MULADDC_INIT \ 305 "addi %%r3, %%r3, -8 \n\t" \ 306 "addi %%r4, %%r4, -8 \n\t" \ 307 "addic %%r5, %%r5, 0 \n\t" 309 #define MULADDC_CORE \ 310 "ldu %%r7, 8(%%r3) \n\t" \ 311 "mulld %%r8, %%r7, %%r6 \n\t" \ 312 "mulhdu %%r9, %%r7, %%r6 \n\t" \ 313 "adde %%r8, %%r8, %%r5 \n\t" \ 314 "ld %%r7, 8(%%r4) \n\t" \ 315 "addze %%r5, %%r9 \n\t" \ 316 "addc %%r8, %%r8, %%r7 \n\t" \ 317 "stdu %%r8, 8(%%r4) \n\t" 319 #define MULADDC_STOP \ 320 "addze %%r5, %%r5 \n\t" \ 321 "addi %%r4, %%r4, 8 \n\t" \ 322 "addi %%r3, %%r3, 8 \n\t" \ 323 "std %%r5, %0 \n\t" \ 324 "std %%r4, %1 \n\t" \ 325 "std %%r3, %2 \n\t" \ 326 : "=m" (c), "=m" (d), "=m" (s) \ 327 : "m" (s), "m" (d), "m" (c), "m" (b) \ 328 : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ 333 #elif defined(__powerpc__) || defined(__ppc__) 335 #if defined(__MACH__) && defined(__APPLE__) 337 #define MULADDC_INIT \ 343 "addi r3, r3, -4 \n\t" \ 344 "addi r4, r4, -4 \n\t" \ 345 "addic r5, r5, 0 \n\t" 347 #define MULADDC_CORE \ 348 "lwzu r7, 4(r3) \n\t" \ 349 "mullw r8, r7, r6 \n\t" \ 350 "mulhwu r9, r7, r6 \n\t" \ 351 "adde r8, r8, r5 \n\t" \ 352 "lwz r7, 4(r4) \n\t" \ 353 "addze r5, r9 \n\t" \ 354 "addc r8, r8, r7 \n\t" \ 355 "stwu r8, 4(r4) \n\t" 357 #define MULADDC_STOP \ 358 "addze r5, r5 \n\t" \ 359 "addi r4, r4, 4 \n\t" \ 360 "addi r3, r3, 4 \n\t" \ 364 : "=m" (c), "=m" (d), "=m" (s) \ 365 : "m" (s), "m" (d), "m" (c), "m" (b) \ 366 : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ 371 #define MULADDC_INIT \ 373 "lwz %%r3, %3 \n\t" \ 374 "lwz %%r4, %4 \n\t" \ 375 "lwz %%r5, %5 \n\t" \ 376 "lwz %%r6, %6 \n\t" \ 377 "addi %%r3, %%r3, -4 \n\t" \ 378 "addi %%r4, %%r4, -4 \n\t" \ 379 "addic %%r5, %%r5, 0 \n\t" 381 #define MULADDC_CORE \ 382 "lwzu %%r7, 4(%%r3) \n\t" \ 383 "mullw %%r8, %%r7, %%r6 \n\t" \ 384 "mulhwu %%r9, %%r7, %%r6 \n\t" \ 385 "adde %%r8, %%r8, %%r5 \n\t" \ 386 "lwz %%r7, 4(%%r4) \n\t" \ 387 "addze %%r5, %%r9 \n\t" \ 388 "addc %%r8, %%r8, %%r7 \n\t" \ 389 "stwu %%r8, 4(%%r4) \n\t" 391 #define MULADDC_STOP \ 392 "addze %%r5, %%r5 \n\t" \ 393 "addi %%r4, %%r4, 4 \n\t" \ 394 "addi %%r3, %%r3, 4 \n\t" \ 395 "stw %%r5, %0 \n\t" \ 396 "stw %%r4, %1 \n\t" \ 397 "stw %%r3, %2 \n\t" \ 398 : "=m" (c), "=m" (d), "=m" (s) \ 399 : "m" (s), "m" (d), "m" (c), "m" (b) \ 400 : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ 411 #if 0 && defined(__sparc__) 412 #if defined(__sparc64__) 414 #define MULADDC_INIT \ 416 "ldx %3, %%o0 \n\t" \ 417 "ldx %4, %%o1 \n\t" \ 421 #define MULADDC_CORE \ 422 "ld [%%o0], %%o4 \n\t" \ 424 "ld [%%o1], %%o5 \n\t" \ 425 "umul %%o3, %%o4, %%o4 \n\t" \ 426 "addcc %%o4, %%o2, %%o4 \n\t" \ 427 "rd %%y, %%g1 \n\t" \ 428 "addx %%g1, 0, %%g1 \n\t" \ 429 "addcc %%o4, %%o5, %%o4 \n\t" \ 430 "st %%o4, [%%o1] \n\t" \ 431 "addx %%g1, 0, %%o2 \n\t" \ 434 #define MULADDC_STOP \ 436 "stx %%o1, %1 \n\t" \ 437 "stx %%o0, %2 \n\t" \ 438 : "=m" (c), "=m" (d), "=m" (s) \ 439 : "m" (s), "m" (d), "m" (c), "m" (b) \ 440 : "g1", "o0", "o1", "o2", "o3", "o4", \ 446 #define MULADDC_INIT \ 453 #define MULADDC_CORE \ 454 "ld [%%o0], %%o4 \n\t" \ 456 "ld [%%o1], %%o5 \n\t" \ 457 "umul %%o3, %%o4, %%o4 \n\t" \ 458 "addcc %%o4, %%o2, %%o4 \n\t" \ 459 "rd %%y, %%g1 \n\t" \ 460 "addx %%g1, 0, %%g1 \n\t" \ 461 "addcc %%o4, %%o5, %%o4 \n\t" \ 462 "st %%o4, [%%o1] \n\t" \ 463 "addx %%g1, 0, %%o2 \n\t" \ 466 #define MULADDC_STOP \ 470 : "=m" (c), "=m" (d), "=m" (s) \ 471 : "m" (s), "m" (d), "m" (c), "m" (b) \ 472 : "g1", "o0", "o1", "o2", "o3", "o4", \ 479 #if defined(__microblaze__) || defined(microblaze) 481 #define MULADDC_INIT \ 487 "andi r7, r6, 0xffff \n\t" \ 488 "bsrli r6, r6, 16 \n\t" 490 #define MULADDC_CORE \ 491 "lhui r8, r3, 0 \n\t" \ 492 "addi r3, r3, 2 \n\t" \ 493 "lhui r9, r3, 0 \n\t" \ 494 "addi r3, r3, 2 \n\t" \ 495 "mul r10, r9, r6 \n\t" \ 496 "mul r11, r8, r7 \n\t" \ 497 "mul r12, r9, r7 \n\t" \ 498 "mul r13, r8, r6 \n\t" \ 499 "bsrli r8, r10, 16 \n\t" \ 500 "bsrli r9, r11, 16 \n\t" \ 501 "add r13, r13, r8 \n\t" \ 502 "add r13, r13, r9 \n\t" \ 503 "bslli r10, r10, 16 \n\t" \ 504 "bslli r11, r11, 16 \n\t" \ 505 "add r12, r12, r10 \n\t" \ 506 "addc r13, r13, r0 \n\t" \ 507 "add r12, r12, r11 \n\t" \ 508 "addc r13, r13, r0 \n\t" \ 509 "lwi r10, r4, 0 \n\t" \ 510 "add r12, r12, r10 \n\t" \ 511 "addc r13, r13, r0 \n\t" \ 512 "add r12, r12, r5 \n\t" \ 513 "addc r5, r13, r0 \n\t" \ 514 "swi r12, r4, 0 \n\t" \ 515 "addi r4, r4, 4 \n\t" 517 #define MULADDC_STOP \ 521 : "=m" (c), "=m" (d), "=m" (s) \ 522 : "m" (s), "m" (d), "m" (c), "m" (b) \ 523 : "r3", "r4" "r5", "r6", "r7", "r8", \ 524 "r9", "r10", "r11", "r12", "r13" \ 529 #if defined(__tricore__) 531 #define MULADDC_INIT \ 533 "ld.a %%a2, %3 \n\t" \ 534 "ld.a %%a3, %4 \n\t" \ 535 "ld.w %%d4, %5 \n\t" \ 536 "ld.w %%d1, %6 \n\t" \ 537 "xor %%d5, %%d5 \n\t" 539 #define MULADDC_CORE \ 540 "ld.w %%d0, [%%a2+] \n\t" \ 541 "madd.u %%e2, %%e4, %%d0, %%d1 \n\t" \ 542 "ld.w %%d0, [%%a3] \n\t" \ 543 "addx %%d2, %%d2, %%d0 \n\t" \ 544 "addc %%d3, %%d3, 0 \n\t" \ 545 "mov %%d4, %%d3 \n\t" \ 546 "st.w [%%a3+], %%d2 \n\t" 548 #define MULADDC_STOP \ 549 "st.w %0, %%d4 \n\t" \ 550 "st.a %1, %%a3 \n\t" \ 551 "st.a %2, %%a2 \n\t" \ 552 : "=m" (c), "=m" (d), "=m" (s) \ 553 : "m" (s), "m" (d), "m" (c), "m" (b) \ 554 : "d0", "d1", "e2", "d4", "a2", "a3" \ 571 #if defined(__GNUC__) && !defined(__OPTIMIZE__) 572 #define MULADDC_CANNOT_USE_R7 575 #if defined(__arm__) && !defined(MULADDC_CANNOT_USE_R7) 577 #if defined(__thumb__) && !defined(__thumb2__) 579 #define MULADDC_INIT \ 585 "lsr r7, r3, #16 \n\t" \ 587 "lsl r7, r3, #16 \n\t" \ 588 "lsr r7, r7, #16 \n\t" \ 591 #define MULADDC_CORE \ 592 "ldmia r0!, {r6} \n\t" \ 593 "lsr r7, r6, #16 \n\t" \ 594 "lsl r6, r6, #16 \n\t" \ 595 "lsr r6, r6, #16 \n\t" \ 604 "lsr r3, r6, #16 \n\t" \ 605 "add r5, r5, r3 \n\t" \ 606 "lsr r3, r7, #16 \n\t" \ 607 "add r5, r5, r3 \n\t" \ 608 "add r4, r4, r2 \n\t" \ 611 "lsl r3, r6, #16 \n\t" \ 612 "add r4, r4, r3 \n\t" \ 614 "lsl r3, r7, #16 \n\t" \ 615 "add r4, r4, r3 \n\t" \ 617 "ldr r3, [r1] \n\t" \ 618 "add r4, r4, r3 \n\t" \ 620 "stmia r1!, {r4} \n\t" 622 #define MULADDC_STOP \ 626 : "=m" (c), "=m" (d), "=m" (s) \ 627 : "m" (s), "m" (d), "m" (c), "m" (b) \ 628 : "r0", "r1", "r2", "r3", "r4", "r5", \ 629 "r6", "r7", "r8", "r9", "cc" \ 634 #define MULADDC_INIT \ 641 #define MULADDC_CORE \ 642 "ldr r4, [r0], #4 \n\t" \ 644 "ldr r6, [r1] \n\t" \ 645 "umlal r2, r5, r3, r4 \n\t" \ 646 "adds r7, r6, r2 \n\t" \ 647 "adc r2, r5, #0 \n\t" \ 648 "str r7, [r1], #4 \n\t" 650 #define MULADDC_STOP \ 654 : "=m" (c), "=m" (d), "=m" (s) \ 655 : "m" (s), "m" (d), "m" (c), "m" (b) \ 656 : "r0", "r1", "r2", "r3", "r4", "r5", \ 664 #if defined(__alpha__) 666 #define MULADDC_INIT \ 673 #define MULADDC_CORE \ 674 "ldq $6, 0($1) \n\t" \ 675 "addq $1, 8, $1 \n\t" \ 676 "mulq $6, $4, $7 \n\t" \ 677 "umulh $6, $4, $6 \n\t" \ 678 "addq $7, $3, $7 \n\t" \ 679 "cmpult $7, $3, $3 \n\t" \ 680 "ldq $5, 0($2) \n\t" \ 681 "addq $7, $5, $7 \n\t" \ 682 "cmpult $7, $5, $5 \n\t" \ 683 "stq $7, 0($2) \n\t" \ 684 "addq $2, 8, $2 \n\t" \ 685 "addq $6, $3, $3 \n\t" \ 686 "addq $5, $3, $3 \n\t" 688 #define MULADDC_STOP \ 692 : "=m" (c), "=m" (d), "=m" (s) \ 693 : "m" (s), "m" (d), "m" (c), "m" (b) \ 694 : "$1", "$2", "$3", "$4", "$5", "$6", "$7" \ 698 #if defined(__mips__) && !defined(__mips64) 700 #define MULADDC_INIT \ 707 #define MULADDC_CORE \ 708 "lw $14, 0($10) \n\t" \ 709 "multu $13, $14 \n\t" \ 710 "addi $10, $10, 4 \n\t" \ 713 "addu $14, $12, $14 \n\t" \ 714 "lw $15, 0($11) \n\t" \ 715 "sltu $12, $14, $12 \n\t" \ 716 "addu $15, $14, $15 \n\t" \ 717 "sltu $14, $15, $14 \n\t" \ 718 "addu $12, $12, $9 \n\t" \ 719 "sw $15, 0($11) \n\t" \ 720 "addu $12, $12, $14 \n\t" \ 721 "addi $11, $11, 4 \n\t" 723 #define MULADDC_STOP \ 727 : "=m" (c), "=m" (d), "=m" (s) \ 728 : "m" (s), "m" (d), "m" (c), "m" (b) \ 729 : "$9", "$10", "$11", "$12", "$13", "$14", "$15" \ 735 #if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) 737 #define MULADDC_INIT \ 743 #define MULADDC_CORE \ 748 __asm add eax, [edi] \ 753 #if defined(MBEDTLS_HAVE_SSE2) 755 #define EMIT __asm _emit 757 #define MULADDC_HUIT \ 758 EMIT 0x0F EMIT 0x6E EMIT 0xC9 \ 759 EMIT 0x0F EMIT 0x6E EMIT 0xC3 \ 760 EMIT 0x0F EMIT 0x6E EMIT 0x1F \ 761 EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ 762 EMIT 0x0F EMIT 0x6E EMIT 0x16 \ 763 EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \ 764 EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \ 765 EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \ 766 EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \ 767 EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \ 768 EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \ 769 EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \ 770 EMIT 0x0F EMIT 0xD4 EMIT 0xCA \ 771 EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \ 772 EMIT 0x0F EMIT 0xD4 EMIT 0xDC \ 773 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \ 774 EMIT 0x0F EMIT 0xD4 EMIT 0xEE \ 775 EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \ 776 EMIT 0x0F EMIT 0xD4 EMIT 0xFC \ 777 EMIT 0x0F EMIT 0x7E EMIT 0x0F \ 778 EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \ 779 EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \ 780 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ 781 EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \ 782 EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \ 783 EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ 784 EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \ 785 EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \ 786 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \ 787 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ 788 EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \ 789 EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \ 790 EMIT 0x0F EMIT 0xD4 EMIT 0xCD \ 791 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \ 792 EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \ 793 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \ 794 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ 795 EMIT 0x0F EMIT 0xD4 EMIT 0xCF \ 796 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \ 797 EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \ 798 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \ 799 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ 800 EMIT 0x0F EMIT 0xD4 EMIT 0xCA \ 801 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \ 802 EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \ 803 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \ 804 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ 805 EMIT 0x0F EMIT 0xD4 EMIT 0xCC \ 806 EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \ 807 EMIT 0x0F EMIT 0xD4 EMIT 0xDD \ 808 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \ 809 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ 810 EMIT 0x0F EMIT 0xD4 EMIT 0xCE \ 811 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \ 812 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ 813 EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ 814 EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \ 815 EMIT 0x83 EMIT 0xC7 EMIT 0x20 \ 816 EMIT 0x83 EMIT 0xC6 EMIT 0x20 \ 817 EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ 818 EMIT 0x0F EMIT 0x7E EMIT 0xC9 820 #define MULADDC_STOP \ 821 EMIT 0x0F EMIT 0x77 \ 828 #define MULADDC_STOP \ 838 #if !defined(MULADDC_CORE) 839 #if defined(MBEDTLS_HAVE_UDBL) 841 #define MULADDC_INIT \ 844 mbedtls_mpi_uint r0, r1; 846 #define MULADDC_CORE \ 847 r = *(s++) * (mbedtls_t_udbl) b; \ 848 r0 = (mbedtls_mpi_uint) r; \ 849 r1 = (mbedtls_mpi_uint)( r >> biL ); \ 850 r0 += c; r1 += (r0 < c); \ 851 r0 += *d; r1 += (r0 < *d); \ 854 #define MULADDC_STOP \ 858 #define MULADDC_INIT \ 860 mbedtls_mpi_uint s0, s1, b0, b1; \ 861 mbedtls_mpi_uint r0, r1, rx, ry; \ 862 b0 = ( b << biH ) >> biH; \ 865 #define MULADDC_CORE \ 866 s0 = ( *s << biH ) >> biH; \ 867 s1 = ( *s >> biH ); s++; \ 868 rx = s0 * b1; r0 = s0 * b0; \ 869 ry = s1 * b0; r1 = s1 * b1; \ 870 r1 += ( rx >> biH ); \ 871 r1 += ( ry >> biH ); \ 872 rx <<= biH; ry <<= biH; \ 873 r0 += rx; r1 += (r0 < rx); \ 874 r0 += ry; r1 += (r0 < ry); \ 875 r0 += c; r1 += (r0 < c); \ 876 r0 += *d; r1 += (r0 < *d); \ 879 #define MULADDC_STOP \ Multi-precision integer library.