Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/10/12 22:16
Read: 692 times


 
#188303 - just want to check...
Responding to: Per Westermark's previous message
Per Westermark,

i just want to know is it possible or not?

multiple variable bit convert into single variable so its simple to check and to modify,

here this is stucture of variable(unsigned char), we can access individule bits of that variable.

/*********************************/
typedef unsigned char byte;

typedef union {
struct {
byte bit0 :1;
byte bit1 :1;
byte bit2 :1;
byte bit3 :1;
byte bit4 :1;
byte bit5 :1;
byte bit6 :1;
byte bit7 :1;
} Bits;
} check_flags;

check_flags _flag;
#define flag _flag.Byte
#define bit0 _flag.Bits.bit0
#define bit1 _flag.Bits.bit1
#define bit2 _flag.Bits.bit2
#define bit3 _flag.Bits.bit3
#define bit4 _flag.Bits.bit4
#define bit5 _flag.Bits.bit5
#define bit6 _flag.Bits.bit6
#define bit7 _flag.Bits.bit7
/*************************************/
byte addressable, its convert into bit addressable
if have 3 variable like this, merging individule bit into single variable.......

i gave example of interrupt, but it might be anything.
advantage is i can deal with 1 variable instand of 3 variable.

List of 11 messages in thread
TopicAuthorDate
Different variable bit merge into single variable?      Yagnesh Mehta      09/10/12 04:48      
   Of course      Per Westermark      09/10/12 05:02      
      its bit addressable....      Yagnesh Mehta      09/10/12 05:38      
         No      Per Westermark      09/10/12 06:39      
            just want to check...      Yagnesh Mehta      09/10/12 22:16      
               What was missing in the answers you have already received?      Per Westermark      09/11/12 00:21      
                  no defined bit order      Maarten Brock      09/11/12 03:26      
                     Just use C expression      David Prentice      09/11/12 05:39      
         what is wrong with IE?      Erik Malund      09/10/12 07:01      
            Right!!!!!!!!!!      Yagnesh Mehta      09/13/12 00:29      
               gobbledygook      David Prentice      09/13/12 05:09      

Back to Subject List