| 507 | |
| 508 | #ifdef _MSC_VER |
| 509 | __declspec(naked) |
| 510 | #else |
| 511 | __attribute__ ((noinline)) |
| 512 | #endif |
| 513 | void RIPEMD160::AsmTransform(const byte* data, word32 times) |
| 514 | { |
| 515 | #ifdef __GNUC__ |
| 516 | #define AS1(x) #x ";" |
| 517 | #define AS2(x, y) #x ", " #y ";" |
| 518 | |
| 519 | #define PROLOG() \ |
| 520 | __asm__ __volatile__ \ |
| 521 | ( \ |
| 522 | ".intel_syntax noprefix;" \ |
| 523 | "push ebx;" \ |
| 524 | "push ebp;" |
| 525 | #define EPILOG() \ |
| 526 | "pop ebp;" \ |
| 527 | "pop ebx;" \ |
| 528 | "emms;" \ |
| 529 | ".att_syntax;" \ |
| 530 | : \ |
| 531 | : "c" (this), "D" (data), "d" (times) \ |
| 532 | : "%esi", "%eax", "memory", "cc" \ |
| 533 | ); |
| 534 | |
| 535 | #else |
| 536 | #define AS1(x) __asm x |
| 537 | #define AS2(x, y) __asm x, y |
| 538 | |
| 539 | #define PROLOG() \ |
| 540 | AS1( push ebp ) \ |
| 541 | AS2( mov ebp, esp ) \ |
| 542 | AS2( movd mm3, edi ) \ |
| 543 | AS2( movd mm4, ebx ) \ |
| 544 | AS2( movd mm5, esi ) \ |
| 545 | AS2( movd mm6, ebp ) \ |
| 546 | AS2( mov edi, DWORD PTR [ebp + 8] ) \ |
| 547 | AS2( mov edx, DWORD PTR [ebp + 12] ) |
| 548 | |
| 549 | #define EPILOG() \ |
| 550 | AS2( movd ebp, mm6 ) \ |
| 551 | AS2( movd esi, mm5 ) \ |
| 552 | AS2( movd ebx, mm4 ) \ |
| 553 | AS2( movd edi, mm3 ) \ |
| 554 | AS2( mov esp, ebp ) \ |
| 555 | AS1( pop ebp ) \ |
| 556 | AS1( emms ) \ |
| 557 | AS1( ret 8 ) |
| 558 | |
| 559 | #endif |
| 560 | |
| 561 | PROLOG() |
| 562 | |
| 563 | #ifdef OLD_GCC_OFFSET |
| 564 | AS2( lea esi, [ecx + 20] ) // digest_[0] |
| 565 | #else |
| 566 | AS2( lea esi, [ecx + 16] ) // digest_[0] |