#include <stdio.h>
int main()
{
//HEX Numbers in C
unsigned char myreg = 0x0;
printf("set myreg Enable.\n");
//Setting a BIT in Register
myreg |= (1<<5);
//Testing The Status of a Bit
if (myreg & (1<<5))
{
printf("myreg is Enable\n");
}
else
{
printf("myreg is not Enable\n");
}
printf("set myreg Disable.\n");
//Clearing a BIT in Register
myreg &= ~(1<<5);
//Testing The Status of a Bit
if (myreg & (1<<5))
{
printf("myreg is Enable\n");
}
else
{
printf("myreg is not Enable\n");
}
return 0;
}
熟悉C语言的位操作
最新推荐文章于 2022-06-02 16:40:59 发布