Syntax error asm volatile

Technical questions regarding the XTC tools and programming with XMOS.
mmar
Experienced Member
Posts: 123
Joined: Fri Jul 05, 2013 5:55 pm

Syntax error asm volatile

Post by mmar »

I use some codes with
#define LDW(dst, mem, ind) asm("ldw %0, %1[%2]" : "=r"(dst) : "r"(mem), "r"(ind))
#define STW(src, mem, ind) asm("stw %0, %1[%2]" : "=r"(src) : "r"(mem), "r"(ind))

but optimizer removes it from code if =r is not used after macro usage.
I read assembler guide and use recommended volatile

#define STW(src, mem, ind) asm volatile("stw %0, %1[%2]" : "=r"(src) : "r"(mem), "r"(ind))

this is compiled but XDE shows SYNTAX ERROR in lines with macro.

How is functional 100% code for pointer type memory array read and write back?

For me only real C code works 100%. But in XC i need very frustrated calls to C code in other source file.


User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Missing semi-colon when calling the macro? Looks like valid syntax otherwise.
mmar
Experienced Member
Posts: 123
Joined: Fri Jul 05, 2013 5:55 pm

Post by mmar »

On screenshot is syntax error.
But no build error.
This error exist only when define have volatile clause.

#define LDW(dst, mem, ind) asm volatile("ldw %0, %1[%2]" : "=r"(dst) : "r"(mem), "r"(ind))
You do not have the required permissions to view the files attached to this post.
User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Ah, I thought you have a build error. Looks like an issue in the IDE.
User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

Post by sethu_jangala »

Which version of the tool are you using? In 13.0.0 version of the tools, this issue is fixed. I presume you are using the older version of the tool.

Sethu.