#include <stdio.h>
#include <stdint.h>
// Define macros for bit operations
#define SET_BIT(REG, POS) ((REG) |= (1U << (POS)))
#define CLEAR_BIT(REG, POS) ((REG) &= ~(1U << (POS)))
#define TOGGLE_BIT(REG, POS) ((REG) ^= (1U << (POS)))
#define CHECK_BIT(REG, POS) (((REG) >> (POS)) & 1U)
uint8_t modify_register(uint8_t reg) {
// Perform the bit operations
SET_BIT(reg,2);
SET_BIT(reg,7); // OR with 130 → set bit7 and bit1
CLEAR_BIT(reg,3); // AND with 0xF7 → clear bit3
TOGGLE_BIT(reg,5); // XOR with 32 → toggle bit5
return reg;
}
int main() {
uint8_t reg;
scanf("%hhu", ®); // input as decimal number
printf("%u", modify_register(reg));
return 0;
}
Input
0
Expected Output
164