1. 程式人生 > >IAR中C內嵌彙編格式

IAR中C內嵌彙編格式

/*示例*/
extern volatile char UART1_SR;
#pragma required=UART1_SR
char sFlag;
void Foo(void)
{
while (!sFlag)
{
    asm(" ldr r2,[pc,#0] \n"        /* r2 = address of sFlag */
    " b .+8 \n"                     /* jump over constant */
    " DCD sFlag \n"                 /* address of sFlag */
    " ldr r3,[pc,#0] \n"
/* r3 = address of UART1_SR */ " b .+8 \n" /* jump over constant */ " DCD UART1_SR \n" /* address of UART1_SR */ " ldr r0,[r3] \n" /* r0 = UART1_SR */ " str r0,[r2]"); /* sFlag = r0 */ } }