变量定义如下: #define false 0 #define true 1 #define flag_timer0_a_1ms 0 extern volatile INT16U timer0_a_Flags; 使用HWREGBITW和直接操作两种方式对timer0_a_Flags的最低位置1和置0
产生汇编如下,请问BIT-BAND有什么优势??
HWREGBITW(&timer0_a_Flags, flag_timer0_a_1ms)= true;//1ms 0x000001A2 2001 MOVS r0,#0x01 0x000001A4 492C LDR r1,[pc,#176] ; @0x00000258 0x000001A6 F0014170 AND r1,r1,#0xF0000000 0x000001AA F0417100 ORR r1,r1,#0x2000000 0x000001AE 4A2A LDR r2,[pc,#168] ; @0x00000258 0x000001B0 F3C20213 UBFX r2,r2,#0,#20 0x000001B4 EA411142 ORR r1,r1,r2,LSL #5 0x000001B8 6008 STR r0,[r1,#0x00] HWREGBITW(&timer0_a_Flags, flag_timer0_a_1ms)= false;//1ms 0x000001BA 2000 MOVS r0,#0x00 0x000001BC 4926 LDR r1,[pc,#152] ; @0x00000258 0x000001BE F0014170 AND r1,r1,#0xF0000000 0x000001C2 F0417100 ORR r1,r1,#0x2000000 0x000001C6 4A24 LDR r2,[pc,#144] ; @0x00000258 0x000001C8 F3C20213 UBFX r2,r2,#0,#20 0x000001CC EA411142 ORR r1,r1,r2,LSL #5 0x000001D0 6008 STR r0,[r1,#0x00] timer0_a_Flags&=~(1<<flag_timer0_a_1ms); 0x000001D2 4821 LDR r0,[pc,#132] ; @0x00000258 0x000001D4 8800 LDRH r0,[r0,#0x00] 0x000001D6 F0200001 BIC r0,r0,#0x01 0x000001DA 491F LDR r1,[pc,#124] ; @0x00000258 0x000001DC 8008 STRH r0,[r1,#0x00] timer0_a_Flags|=(1<<flag_timer0_a_1ms); 0x000001DE 4608 MOV r0,r1 0x000001E0 8800 LDRH r0,[r0,#0x00] 0x000001E2 F0400001 ORR r0,r0,#0x01 0x000001E6 8008 STRH r0,[r1,#0x00] |