AnsweredAssumed Answered

function for set reset

Question asked by caramaliu.radu on Jul 17, 2013
Latest reply on Jul 17, 2013 by Clive One
HI , 

i have this function which sets x bit( passed as a parameter) of a byte . after some code the variable should be restored to it's initial value .

char a ; global variable 
void function(char x){
int b = a;
a |= (1<<x);  //set the x bit 
...some other code ....
a = b ;
So when i leave the function the value of a is restored to initial state . Is there any way i can optimize this (set reset procedure of a bit )?