Are there bit operations?


To gain acess parallel port and get the status(0 & 1) of one bit in it, I write the code as follows:

uintptr_t parallel_port;
int temp;

parallel_port=mmap_device_io(PORT_LENGH, STATUS_ADDRESS);
/* Here needs monitor one bit status of the parallel port through some bit operations */

Unfortunately, there seems no bit operation funtions in C library available as likely as MCU progaming I used to do. I would like to know what’s the proper method to solve the
problem. Thanks.

Peter Z

if ( ( temp & 0x40 ) == 0x40 ) will test if bit 6 is set
if ( ( temp & 0x40 ) == 0 ) will test if bit 6 is zero
if ( ( temp & 0x41 ) == 0x41) will test if bit 6 and 0 are set

Usually this gets optimized for the CPU this is compile for (x86 doesn’t have bit test instruction)