반응형
#define Macro_Set_Bit(dest, position) ((dest) |= ((unsigned)0x1<<(position)))
#define Macro_Clear_Bit(dest, position) ((dest) &= ~((unsigned)0x1<<(position)))
#define Macro_Invert_Bit(dest, position) ((dest) ^= ((unsigned)0x1<<(position)))
#define Macro_Clear_Area(dest, bits, position) ((dest) &= ~(((unsigned)bits)<<(position)))
#define Macro_Set_Area(dest, bits, position) ((dest) |= (((unsigned)bits)<<(position)))
#define Macro_Invert_Area(dest, bits, position) ((dest) ^= (((unsigned)bits)<<(position)))
#define Macro_Write_Block(dest, bits, data, position) ((dest) = (((unsigned)dest) & ~(((unsigned)bits)<<(position))) | (((unsigned)data)<<(position)))
#define Macro_Check_Bit_Set(dest, position) ((((unsigned)dest)>>(position)) & 0x1)
#define Macro_Check_Bit_Clear(dest, position) (!((((unsigned)dest)>>(position)) & 0x1))
#define Macro_Extract_Area(dest, bits, position) ((((unsigned)dest)>>(position)) & (bits))
반응형
'【Programming】 > C' 카테고리의 다른 글
Writing Efficient C and C Code Optimization (0) | 2013.07.11 |
---|---|
비트 필드의 인식과 코딩의 자유로움에 대하여 (0) | 2012.08.16 |
restrict type qualifier (0) | 2012.02.04 |
define으로 해결하는 C 자료구조 (0) | 2011.10.07 |
함수포인터의 재정의: typedef와 함수포인터 (0) | 2010.08.30 |