bit-ops/bit-ops.c

31 lines
675 B
C
Raw Normal View History

2020-10-31 12:47:08 +01:00
#include <stdio.h>
2020-10-31 12:49:18 +01:00
void do_bit_ops() {
unsigned char PTAD = 0x10;
2020-10-31 14:33:35 +01:00
printf("PTAD = %#x\n* OR\n", PTAD);
2020-10-31 12:49:18 +01:00
PTAD |= 0x01;
2020-10-31 14:33:35 +01:00
printf("PTAD |= 0x01 --> %#010x (%#x)\n", PTAD, PTAD);
printf("----------\n* AND\n");
printf("PTAD = %#x\n", PTAD=0x1f);
2020-10-31 12:49:18 +01:00
PTAD &= 0xfe;
2020-10-31 14:33:35 +01:00
printf("PTAD &= 0xfe --> %#010x (%#x)\n", PTAD, PTAD);
printf("----------\n* NOT\n");
printf("PTAD = %#x\n", PTAD=0x10);
PTAD = ~PTAD;
printf("PTAD = ~PTAD --> %#010x (%#x)\n", PTAD, PTAD);
printf("----------\n* XOR\n");
printf("PTAD = %#x\n", PTAD=0x10);
PTAD ^= 0xfe;
printf("PTAD ^= 0xfe --> %#010x (%#x)\n", PTAD, PTAD);
2020-10-31 12:49:18 +01:00
}
2020-10-31 12:47:08 +01:00
int main() {
printf("*** bit-ops pls ***\n");
2020-10-31 12:49:18 +01:00
do_bit_ops();
2020-10-31 12:47:08 +01:00
return 0;
}