Returns the value of a given group of 4 bits into an array ( [0-15] )
u8 cpct_get4Bits (void* array, u16 index);
(2B DE) array | Pointer to the first byte of the array |
(2B HL) index | Position of the group of 4 bits to be retrieved from the array |
call cpct_get4Bits_asm
u8 | Value of the selected group of 4 bits: [0-15] |
Returns a value from 0 to 15 depending on the value of the 4-bits group at the given position (index) in the specified array. It will assume that the array elements have a size of 8 bits and also that the given position is not bigger than the number of bits in the array (size of the array multiplied by 2).
AF, BC, DE, HL
C-bindings | 25 bytes |
ASM-bindings | 22 bytes |
Case | microSecs (us) | CPU Cycles | ----------------------------------------- Best (1) | 30 | 120 | ----------------------------------------- Worst (0) | 33 | 132 | ----------------------------------------- ASM Saving| -12 | -48 | -----------------------------------------
We need to know how many bytes do we have to jump into the array, to move HL to that point. We advance 1 byte for each 2 index positions (8 bits) So, first, we calculate INDEX/2 (HL/2) to know the target byte, and the remainder to know the group of 4bits we want [ 0000 1111 ], and that will go to the Carry Flag.