SmallInteger.st
branchjv
changeset 17951 fa0e1d7467ea
parent 17921 4069fe8e9039
child 17993 956342c369a2
--- a/SmallInteger.st	Thu Jul 05 11:45:05 2012 +0100
+++ b/SmallInteger.st	Wed Jul 18 17:55:48 2012 +0100
@@ -794,7 +794,6 @@
     "
 ! !
 
-
 !SmallInteger methodsFor:'bit operators'!
 
 bitAnd:anInteger
@@ -2095,6 +2094,30 @@
      -16rFF00 digitLength
      -16rFF digitLength
     "
+!
+
+swapBytes
+    "swap byte pair-wise in an integer
+     i.e. a.b.c.d -> b.a.d.c"
+
+%{  /* NOCONTEXT */
+
+#if __POINTER_SIZE__ == 4
+    unsigned int v = __intVal(self);  
+    unsigned int swapped;  
+
+    swapped = ((v&0xFF000000)>>8) | ((v&0xFF0000) << 8) | ((v & 0xFF00)>>8) | ((v & 0xFF)<<8);
+    RETURN (__MKUINT(swapped));
+#endif /* __POINTER_SIZE__ */
+%}.
+    ^ super swapBytes
+
+    "
+     16r11223344 swapBytes hexPrintString  
+     16r44332211 swapBytes hexPrintString 
+    "
+
+    "Created: / 09-01-2012 / 23:01:33 / cg"
 ! !
 
 !SmallInteger methodsFor:'catching messages'!
@@ -4090,17 +4113,13 @@
 !SmallInteger class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.195 2012/02/12 19:57:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.196 2012/07/06 16:33:40 stefan Exp $'
 !
 
 version_CVS
-    ^ 'Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.195 2012/02/12 19:57:49 cg Exp '
+    ^ '§Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.196 2012/07/06 16:33:40 stefan Exp §'
 !
 
 version_SVN
-    ^ '$Id: SmallInteger.st 10777 2012-02-13 19:19:41Z vranyj1 $'
+    ^ '$Id: SmallInteger.st 10824 2012-07-18 16:55:48Z vranyj1 $'
 ! !
-
-
-
-