c庫函式
阿新 • • 發佈:2019-01-11
字元與字串
4 #define vi *( volatile unsigned int * )
5
6 #define SET_ZERO( addr, bit ) ( (vi addr) &= ( ~ ( 1 << (bit) ) ) )
7 #define SET_ONE( addr, bit ) ( (vi addr) |= ( 1 << ( bit ) ) )
8
9 #define SET_BIT( addr, bit, val ) ( (vi addr) = (( vi addr)&=(~(1<<(bit))) ) | ( (val)<<(bit) ) )
10
11 #define SET_2BIT( addr, bit, val ) ( (vi addr) = (( vi addr)&(~(3<<(bit))) ) | ( (val)<<(bit) ) )
12
13 #define SET_NBIT( addr, bit, len, val ) \
14 ( (vi addr) = ((( vi addr)&(~(( ((1<<(len))-1) )<<(bit)))) | ( (val)<<(bit) ) ))
15
16 #define GET_BIT( addr, bit ) ( (( vi addr ) & ( 1 << (bit) )) > 0 )
17
18 #define GET_VAL( addr, val ) ( (val) = vi addr )
19 #define SET_VAL( addr, val ) ( (vi addr) = (val) )
20 #define OR_VAL( addr, val ) ( (vi addr) |= (val) )