cm0002@lemmy.world to Programmer Humor@programming.dev · 1 year agoTell me the truth ...piefed.jeena.netimagemessage-square23fedilinkarrow-up11arrow-down10cross-posted to: programmerhumor@lemmy.ml
arrow-up11arrow-down1imageTell me the truth ...piefed.jeena.netcm0002@lemmy.world to Programmer Humor@programming.dev · 1 year agomessage-square23fedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squareskisnow@lemmy.calinkfedilinkEnglisharrow-up0·1 year 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-squareQuatlicopatlix@feddit.orglinkfedilinkarrow-up1·1 year 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.