GCC 数组 位域 问题 求大侠相助
GCC下我编写一下程序typedef struct
{
uint32_t DIV:16;
uint32_t RESERVE0:8;
uint32_t DIVX:4;
uint32_t DIVX1:1;
uint32_t DIVX_EN:1;
uint32_t RESERVE1:2;
} UART_BAUD_T00;
UART_BAUD_T00 *Baud;
Baud-> DIVX1=1;.
Baud-> DIVX_EN =1;
Baud-> DIV =0x5566;
但是有个功能错误.这是反汇编程序
baud->DIVX_EN = 1; /* Try to Set Divider X = 1 (MODE#3)*/
0x00000ba2: ldr r2, [r7, #4]
0x00000ba4: ldr r1, [r2, #0]
0x00000ba6: movs r3, #128 ; 0x80
0x00000ba8: lsls r3, r3, #22
0x00000baa: orrs r3, r1
0x00000bac: str r3, [r2, #0]
108 baud->DIVX1 = 1;
0x00000bae: ldr r2, [r7, #4]
0x00000bb0: ldr r1, [r2, #0]
0x00000bb2: movs r3, #128 ; 0x80
0x00000bb4: lsls r3, r3, #21
0x00000bb6: orrs r3, r1
0x00000bb8: str r3, [r2, #0]
109 baud->DIV = 0x5566;
0x00000bba: ldr r3, [r7, #16]
0x00000bbc: uxth r2, r3
0x00000bbe: ldr r3, [r7, #4]
0x00000bc0: strh r2, [r3, #0] ;错误在这里
在执行上述程序后对应的地址的值应该为 0x30005566;但实际值却是0x00005566;就是因为strh 指令的缘故。谁知道怎么设置GCC选项使得不优化为strh
谢谢各位大侠相助啊!
Xinyun