[muscle] MUSCLE and MASM (Visual C inline assembler)...

  • From: "Mika Lindqvist" <linki@xxxxxxx>
  • To: <muscle@xxxxxxxxxxxxx>
  • Date: Thu, 17 Feb 2005 17:28:35 +0200

Just wanted to check if we have MASM experts who could double-check my
latest experiment ;) It's not optimized or cleaned up yet... My first
experimenting with inline assembler ;)

---
Index: src/muscle/support/MuscleSupport.h
===================================================================
RCS file: /cvsroot/unizone/unizone/src/muscle/support/MuscleSupport.h,v
retrieving revision 1.23
diff -u -r1.23 MuscleSupport.h
--- src/muscle/support/MuscleSupport.h  7 Feb 2005 18:59:46 -0000       1.23
+++ src/muscle/support/MuscleSupport.h  17 Feb 2005 15:00:44 -0000
@@ -428,17 +428,41 @@
 # elif defined(MUSCLE_USE_X86_INLINE_ASSEMBLY)
 static inline uint16 MuscleX86SwapInt16(uint16 val)
 {
+#ifdef _MSC_VER
+       __asm {
+               mov AX, val
+               xchg AX, AX
+               mov val, AX
+       };
+#else
    __asm__ __volatile__ ("xchgb %b0,%h0" : "=q" (val) : "0" (val));
+#endif
    return val;
 }
 static inline uint32 MuscleX86SwapInt32(uint32 val)
 {
+#ifdef _MSC_VER
+       __asm {
+               mov EAX, val
+               bswap EAX
+               mov val, EAX
+       };
+#else
    __asm__ __volatile__ ("bswap %0" : "+r" (val));
+#endif
    return val;
 }
 static inline float MuscleX86SwapFloat(float val)
 {
+#ifdef _MSC_VER
+       __asm {
+               mov EAX, val
+               bswap EAX
+               mov val, EAX
+       };
+#else
    __asm__ __volatile__ ("bswap %0" : "+r" (val));
+#endif
    return val;
 }
 static inline uint64 MuscleX86SwapInt64(uint64 val)
---


Other related posts: