- for (offset = (num_bits-1); offset >= 0; offset--) {
-
- bit = (data >> offset) & 1; // Get data bit value (0/1)
- byte_idx = (NextOffset / 8); // Get Array Byte Index to Store
- bit_idx = NextOffset - (byte_idx * 8); // Get Bit Index to set/clr
-
- // If set (1) we OR, if clear (0) we AND with inverse
- // Dbprintf ("Add Bit : %d at byte %d bit %d",bit,byte_idx,bit_idx);
- if (bit == 1)
- bit_array[byte_idx] |= (1 << bit_idx); // Set the bit to 1
-
- else
- bit_array[byte_idx] &= (0xff ^ (1 << bit_idx)); // Set the bit to 0 (clr)
-
- NextOffset++;
- }
+ for (offset = (num_bits-1); offset >= 0; offset--)
+ bit_array[NextOffset++] = (data >> offset) & 1;