cpct_getBit

Returns the status of a given bit into a bitarray (0 or !0)

C Definition

u8 cpct_getBit (void* array, u16 index);

Input Parameters (4 Bytes)

(2B DE) arrayPointer to the first byte of the array
(2B HL) indexPosition of the bit in the array to be retrieved

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 bit 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

u8Status of the selected bit: false (0) when the bit value is 0, true (> 0) when the bit value is 1.  Take into account that >0 means any value different than 0, and not necessarily 1.

Known limitations

  • Maximum of 65536 bits, 8192 bytes per array.

Details

Returns 0 or >0 depending on the value of the bit 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 8).

Destroyed Register values

AF, BC, DE, HL

Required memory

C-bindings31 bytes
ASM-bindings28 bytes
bitWeights+8 bytes vector required by both bindings.  Take into account that this vector is included only once if you use different functions referencing to it.

Time Measures

   Case    | microsec (ms) | Cycles
--------------------------------------
   Any     |      44       |   176
--------------------------------------
ASM-Saving |     -12       |   -48
--------------------------------------
unsigned char (u8 = unsigned 8-bits, 1 byte )
Returns the status of a given bit into a bitarray (0 or !0)
unsigned int (u16 = unsigned 16-bits, 2 bytes)
Close