- Timestamp:
- Jan 26, 2007 12:50:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r1 r353 2646 2646 2647 2647 /** 2648 * Multiplies two signed 32-bit values returning a signed 64-bit result. 2649 * 2650 * @returns u32F1 * u32F2. 2651 */ 2652 #if RT_INLINE_ASM_EXTERNAL && !defined(__AMD64__) 2653 DECLASM(int64_t) ASMMult2xS32RetS64(int32_t i32F1, int32_t i32F2); 2654 #else 2655 DECLINLINE(int64_t) ASMMult2xS32RetS64(int32_t i32F1, int32_t i32F2) 2656 { 2657 # ifdef __AMD64__ 2658 return (int64_t)i32F1 * i32F2; 2659 # else /* !__AMD64__ */ 2660 int64_t i64; 2661 # if RT_INLINE_ASM_GNU_STYLE 2662 __asm__ __volatile__("imull %%edx" 2663 : "=A" (i64) 2664 : "a" (i32F2), "d" (i32F1)); 2665 # else 2666 __asm 2667 { 2668 mov edx, [i32F1] 2669 mov eax, [i32F2] 2670 mul edx 2671 mov dword ptr [i64], eax 2672 mov dword ptr [i64 + 4], edx 2673 } 2674 # endif 2675 return i64; 2676 # endif /* !__AMD64__ */ 2677 } 2678 #endif 2679 2680 2681 /** 2648 2682 * Devides a 64-bit unsigned by a 32-bit unsigned returning an unsigned 32-bit result. 2649 2683 * … … 2674 2708 # endif 2675 2709 return u32; 2710 # endif /* !__AMD64__ */ 2711 } 2712 #endif 2713 2714 2715 /** 2716 * Devides a 64-bit signed by a 32-bit signed returning a signed 32-bit result. 2717 * 2718 * @returns u64 / u32. 2719 */ 2720 #if RT_INLINE_ASM_EXTERNAL && !defined(__AMD64__) 2721 DECLASM(int32_t) ASMDivS64ByS32RetS32(int64_t i64, int32_t i32); 2722 #else 2723 DECLINLINE(int32_t) ASMDivS64ByS32RetS32(int64_t i64, int32_t i32) 2724 { 2725 # ifdef __AMD64__ 2726 return (int32_t)(i64 / i32); 2727 # else /* !__AMD64__ */ 2728 # if RT_INLINE_ASM_GNU_STYLE 2729 RTUINTREG iDummy; 2730 __asm__ __volatile__("idivl %3" 2731 : "=a" (i32), "=d"(iDummy) 2732 : "A" (i64), "r" (i32)); 2733 # else 2734 __asm 2735 { 2736 mov eax, dword ptr [i64] 2737 mov edx, dword ptr [i64 + 4] 2738 mov ecx, [i32] 2739 div ecx 2740 mov [i32], eax 2741 } 2742 # endif 2743 return i32; 2676 2744 # endif /* !__AMD64__ */ 2677 2745 }
Note:
See TracChangeset
for help on using the changeset viewer.