This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MIXING C & ASSEMBLY CODE in keil IDE

Dear ARM,
I am using Nordic nrf51 chip for development in Keil IDE Whats wrong with the below code. It works well in RFduino but when I try to port the same code in Keil environment.Its not working throwing error as
1.identifier "asm is undefined
2. expected a ";"
code below
void mixC_and_Assembly()
{ volatile uint32_t *out = &NRF_GPIO->OUT; byte *_ptbytes = txBuf; byte *_ptbytes1 = &txBuf[32]; uint32_t rbyte;

// out =%0 //_ptbytes = %1 //rbyte = %2 asm volatile ( //"headSP:\n\t" "push {r0,r1,r2,r3}\n\t"

"ldrb %2, [%1,#0]\n\t" // rbyte = *_ptbytes "str %2,[%0,#0] \n\t" // *out = _ptbytes[0]

"ldrb %2,[%1,#1] \n\t" // rbyte = *_ptbytes "str %2,[%0,#0] \n\t" // *out = _ptbytes[1]

"ldrb %2,[%1,#2] \n\t" // rbyte = *_ptbytes "str %2,[%0,#0] \n\t" // *out = _ptbytes[2]

...... ..... ..... ......

"pop {r0,r1,r2,r3} \n\t" :: "r" (out), // %0 "r" (_ptbytes), // %1 "r" (rbyte), //%2 "r" (_ptbytes1) // %3 :"memory" );
} after going through core_cmo.h file I have changes asm into __asm
void mixC_and_Assembly()
{ volatile uint32_t *out = &NRF_GPIO->OUT; byte *_ptbytes = txBuf; byte *_ptbytes1 = &txBuf[32]; uint32_t rbyte;

// out =%0 //_ptbytes = %1 //rbyte = %2

__asm volatile ( //"headSP:\n\t" "push {r0,r1,r2,r3}\n\t"

"ldrb %2, [%1,#0]\n\t" // rbyte = *_ptbytes "str %2,[%0,#0] \n\t" // *out = _ptbytes[0]

"ldrb %2,[%1,#1] \n\t" // rbyte = *_ptbytes "str %2,[%0,#0] \n\t" // *out = _ptbytes[1]

"ldrb %2,[%1,#2] \n\t" // rbyte = *_ptbytes "str %2,[%0,#0] \n\t" // *out = _ptbytes[2]

...... ..... ..... ......

"pop {r0,r1,r2,r3} \n\t" :: "r" (out), // %0 "r" (_ptbytes), // %1 "r" (rbyte), //%2 "r" (_ptbytes1) // %3 :"memory" );
}

still I am getting error as "expected ")" ".
is there anything I need to add in compiler option in keil ?
kindly advise
Thanks and Regards
Lakshman,PMP,PMI-RMP

Parents Reply Children
No data