cpct_get4Bits

Returns the value of a given group of 4 bits into an array ( [0-15] )

C Definition

u8 cpct_get4Bits (void* array, u16 index);

Input Parameters (4 Bytes)

(2B DE) arrayPointer to the first byte of the array
(2B HL) indexPosition of the group of 4 bits to be retrieved from the array

Parameter Restrictions

  • array must be the memory location of the first byte of the array.  However, this function will accept any given 16-value, without performing any check.  So, be warned that giving mistaken values to this function will not make it fail, but giving an unpredictable return result.
  • index position of the group of 4 bits to be retrieved from the array, starting in 0.  As this function does not perform any boundary check, if you gave an index outside the boundaries of the array, the return result would be unpredictable and meaningless.

Return value

u8Value of the selected group of 4 bits: [0-15]

Known limitations

  • Maximum of 65536 groups of 4-bits, 32768 bytes per array.

Details

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).

Destroyed Register values

AF, BC, DE, HL

Required memory

29 bytes

Time Measures

Case      | Cycles | microSecs (us)
-----------------------------------
Best (1)  |   128  |  32.00
-----------------------------------
Worst (0) |   151  |  37.75
-----------------------------------
unsigned char (u8 = unsigned 8-bits, 1 byte )
Returns the value of a given group of 4 bits into an array ( [0-15] )
unsigned int (u16 = unsigned 16-bits, 2 bytes)
Close