[Vm-dev] [commit][2919] Correct syntax of inline assembler for byte and word swap operations in win32

commits at squeakvm.org commits at squeakvm.org
Sat May 10 15:08:04 UTC 2014


Revision: 2919
Author:   eliot
Date:     2014-05-10 08:08:04 -0700 (Sat, 10 May 2014)
Log Message:
-----------
Correct syntax of inline assembler for byte and word swap operations in win32
16-bit displays.  Thanks to Nicolai Hess!

Modified Paths:
--------------
    branches/Cog/platforms/win32/vm/sqWin32Window.c

Property Changed:
----------------
    branches/Cog/platforms/Cross/vm/sqSCCSVersion.h


Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
   - Sat May 10 07:52:58 PDT 2014
   + Sat May 10 08:05:46 PDT 2014

Modified: branches/Cog/platforms/win32/vm/sqWin32Window.c
===================================================================
--- branches/Cog/platforms/win32/vm/sqWin32Window.c	2014-05-10 14:57:27 UTC (rev 2918)
+++ branches/Cog/platforms/win32/vm/sqWin32Window.c	2014-05-10 15:08:04 UTC (rev 2919)
@@ -1854,17 +1854,12 @@
 #else /* LSB_FIRST */
 # if defined(__GNUC__) && (defined(_X86_) || defined(i386) || defined(__i386) || defined(__i386__))
    /* GCC generates *optimal* code with a little help */
-#  if __GNUC__ >= 3
-#   define BYTE_SWAP(w) __asm__("bswap %0" : "=r" (w) : "r" (w))
-#   define WORD_SWAP(w) __asm__("roll $16, %0" : "=r" (w) : "r" (w))
-#  else
-#   define BYTE_SWAP(w) __asm__("bswap %%eax" : "=eax" (w) : "eax" (w))
-#   define WORD_SWAP(w) __asm__("roll $16, %%eax" : "=eax" (w) : "eax" (w))
-#  endif
+#  define BYTE_SWAP(w) __asm__("bswap %0" : "+r" (w))
+#  define WORD_SWAP(w) __asm__("roll $16, %0" : "+r" (w))
 #  define SRC_PIX_REG asm("%esi")
 #  define DST_PIX_REG asm("%edi")
-# else /* Not GCC?! Well, it's your own fault */
-#  define BYTE_SWAP(w) w = (w << 24) | ((w & 0xFF00) << 8) | ((w >> 8) & 0xFF00) | (w >> 24)
+# else /* Not GCC?! Well, it's your own fault ;-) */
+#  define BYTE_SWAP(w) w = (w<<24) | ((w&0xFF00)<<8) | ((w>>8)&0xFF00) | (w>>24)
 #  define WORD_SWAP(w) w = (( (unsigned)(w) << 16) | ((unsigned) (w) >> 16))
 # endif /* __GNUC__ */
 #endif /* MSB_FIRST */



More information about the Vm-dev mailing list