Index: /trunk/rtcm3torinex/lib/rtcm3torinex.c
===================================================================
--- /trunk/rtcm3torinex/lib/rtcm3torinex.c	(revision 2859)
+++ /trunk/rtcm3torinex/lib/rtcm3torinex.c	(revision 2860)
@@ -131,4 +131,23 @@
     bitfield = (bitfield<<8)|*(data++); \
     numbits += 8; \
+  } \
+}
+
+/* extract bits from data stream
+   b = variable to store result, a = number of bits */
+#define GETBITS64(b, a) \
+{ \
+  if(((a) > 56) && ((a)-56) > numbits) \
+  { \
+    uint64_t x; \
+    GETBITS(x, 56) \
+    LOADBITS((a)-56) \
+    b = ((x<<((a)-56)) | (bitfield<<(sizeof(bitfield)*8-numbits)) \
+    >>(sizeof(bitfield)*8-((a)-56))); \
+    numbits -= ((a)-56); \
+  } \
+  else \
+  { \
+    GETBITS(b, a) \
   } \
 }
@@ -1060,5 +1079,5 @@
         GETBITS(syncf, 1)
         SKIPBITS(3+7+1)
-        GETBITS(satmask, RTCM3_MSM_NUMSAT)
+        GETBITS64(satmask, RTCM3_MSM_NUMSAT)
 
         /* http://gurmeetsingh.wordpress.com/2008/08/05/fast-bit-counting-routines/ */
@@ -1069,5 +1088,5 @@
           ++numsig;
         i = numsat*numsig;
-        GETBITS(cellmask, (unsigned)i)
+        GETBITS64(cellmask, (unsigned)i)
 
         switch(type % 10)
