-static uint16_t bitsToBytes(uint32_t bits) {
- uint8_t byte_count = bits / CHAR_BIT;
- if(bits % CHAR_BIT != 0) {
- ++byte_count;
- }
- return byte_count;
+uint8_t eightbyte_get_nibble(const uint64_t source, const uint8_t nibble_index,
+ const bool big_endian) {
+ return get_bit_field(source, NIBBLE_SIZE * nibble_index, NIBBLE_SIZE,
+ big_endian);
+}
+
+uint8_t eightbyte_get_byte(const uint64_t source, const uint8_t byte_index,
+ const bool big_endian) {
+ // TODO we're not handling swapped endianness - we could use get_bit_field
+ // but this might be more efficient
+ return (source >> (EIGHTBYTE_BIT - ((byte_index + 1) * CHAR_BIT))) & 0xFF;