-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
49 lines (32 loc) · 1.02 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "stdio.h"
#include "stdbool.h"
int64_t maskSixtyFour = 0000000000000000000000000000000000000000000000000000000000000000;
int32_t maskThirtyTwo = 00000000000000000000000000000000;
void setBit(int32_t *data, int bitPos);
void clearBit(int32_t *data, int bitPos);
void toggleBit(int32_t *data, int bitPos);
bool checkBit(int32_t data, int bitPos);
int32_t tag = 0;
int main() {
printf("--START--\r\n");
for (int i=0; i<32; i++) {
setBit(&tag, i);
}
printf("---END---\r\n");
return 0;
}
void setBit(int32_t *data, int bitPos) {
*data |= (1 << bitPos);
printf("setting bit(%d): new value: %d\r\n", bitPos, *data);
}
void clearBit(int32_t *data, int bitPos) {
*data &= ~(1 << bitPos);
printf("clearing bit(%d): new value: %d\r\n", bitPos, *data);
}
void toggleBit(int32_t *data, int bitPos) {
*data ^= (1 << bitPos);
printf("toggling bit(%d): new value: %d\r\n", bitPos, *data);
}
bool checkBit(int32_t data, int bitPos) {
return ((data) & (1<<(bitPos)));
}