chore: add 0th bit test

This commit is contained in:
surtur 2020-10-31 15:40:43 +01:00
parent 490ad2847c
commit bcf29a697f
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

@ -1,7 +1,11 @@
#include <stdio.h>
void zeroth_bit_test();
unsigned char PTAD;
void do_bit_ops() {
unsigned char PTAD = 0x10;
PTAD = 0x10;
printf("PTAD = %#x\n* OR\n", PTAD);
PTAD |= 0x01;
printf("PTAD |= 0x01 --> %#010x (%#x)\n", PTAD, PTAD);
@ -20,6 +24,25 @@ void do_bit_ops() {
printf("PTAD = %#x\n", PTAD=0x10);
PTAD ^= 0xfe;
printf("PTAD ^= 0xfe --> %#010x (%#x)\n", PTAD, PTAD);
zeroth_bit_test();
}
void zeroth_bit_test() {
PTAD = 0x10;
printf("----------\n* 0th bit test\n");
for (PTAD = 0x00; PTAD < 0x0a; PTAD++){
printf("PTAD = %u (", PTAD);
for (int i = 0; i < 8; i++) {
printf("%d", !!((PTAD << i) & 0x80));
}
printf(")\n");
if ( PTAD & 0x01 ) {
printf("0th bit is 1\n");
} else {
printf("0th bit is 0\n");
}
}
}