macros.h
changeset 2238 14ec09c1a272
parent 2187 2a51f8925eeb
child 2398 70de6626d65f
--- a/macros.h	Sat Jul 30 08:15:15 2005 +0000
+++ b/macros.h	Sat Jul 30 09:29:20 2005 +0000
@@ -146,8 +146,10 @@
 
 /// Fetch n bits starting at bit s from x
 #define GB(x, s, n) (((x) >> (s)) & ((1 << (n)) - 1))
-/// Set n bits in x starting at bit s to d
+/// Set n bits starting at bit s in x to d
 #define SB(x, s, n, d) ((x) = ((x) & ~(((1 << (n)) - 1) << (s))) | ((d) << (s)))
+/// Add i to the n bits starting at bit s in x
+#define AB(x, s, n, i) ((x) = ((x) & ~(((1 << (n)) - 1) << (s))) | (((x) + ((i) << (s))) & (((1 << (n)) - 1) << (s))))
 
 /**
  * ROtate x Left/Right by n (must be >= 0)