@cm0002@lemmy.world to Programmer Humor@programming.dev • 1 day agoTell me the truth ...piefed.jeena.netimagemessage-square95fedilinkarrow-up1924
arrow-up1924imageTell me the truth ...piefed.jeena.net@cm0002@lemmy.world to Programmer Humor@programming.dev • 1 day agomessage-square95fedilink
minus-square@skisnow@lemmy.calinkfedilinkEnglish39•13 hours agoBack in the day when it mattered, we did it like #define BV00 (1 << 0) #define BV01 (1 << 1) #define BV02 (1 << 2) #define BV03 (1 << 3) ...etc #define IS_SET(flag, bit) ((flag) & (bit)) #define SET_BIT(var, bit) ((var) |= (bit)) #define REMOVE_BIT(var, bit) ((var) &= ~(bit)) #define TOGGLE_BIT(var, bit) ((var) ^= (bit)) ....then... #define MY_FIRST_BOOLEAN BV00 SET_BIT(myFlags, MY_FIRST_BOOLEAN)
minus-square@Quatlicopatlix@feddit.orglinkfedilink6•4 hours agoWith embedded stuff its still done like that. And if you go from the arduino functionss to writing the registers directly its a hell of a lot faster.
Back in the day when it mattered, we did it like
#define BV00 (1 << 0) #define BV01 (1 << 1) #define BV02 (1 << 2) #define BV03 (1 << 3) ...etc #define IS_SET(flag, bit) ((flag) & (bit)) #define SET_BIT(var, bit) ((var) |= (bit)) #define REMOVE_BIT(var, bit) ((var) &= ~(bit)) #define TOGGLE_BIT(var, bit) ((var) ^= (bit)) ....then... #define MY_FIRST_BOOLEAN BV00 SET_BIT(myFlags, MY_FIRST_BOOLEAN)
With embedded stuff its still done like that. And if you go from the arduino functionss to writing the registers directly its a hell of a lot faster.