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"
"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
Looks like you have syntax issues (but you could also use
to format your code on the forum).
Refer to the user's guide www.keil.com/.../armcc_chr1359124245889.htm
You don't finish the
with a ).
To help your fellow forum followers, it helps if you
put persnickety problem code in "pre" tags
see:
http://www.keil.com/forum/tips.asp