I did some refactoring at c167 platform specific code and I stumbled upon an inline assembly problem.
Previous code:
asm volatile ( "
extp #pag:%0, #3
mov r4, pof:%0 @ R4 = g_nRcvBufCount
sub r4, #1 @ R4 = R4 - 1
mov pof:%0, r4 @ g_nRcvBufCount = R4"
: "=m" (g_nRcvBufCount)
:
: "r4"
);
[
Basically this code does an atomic decrement of "g_nRcvBufCount" variable
"extp" instruction takes the "page" of the "g_nRcvBufCount" variable and the number of atomic expressions that follow (3 in this case)
]
Current - not compiling code:
asm volatile ( "
extp #pag:%0, #3
mov r4, pof:%0 @ R4 = cfg->g_nRcvBufCount
sub r4, #1 @ R4 = R4 - 1
mov pof:%0, r4 @ cfg->g_nRcvBufCount = R4"
: "=m" (cfg->g_nRcvBufCount)
:
: "r4"
);
where cfg is a pointer to a structure containing the "g_nRcvBufCount" variable.
struct {
...
unsigned short g_nRcvBufCount;
...
}cfg;
The errors received in compilation are:
test.c:1124:Warning:Missing operand value assumed absolute 0.
test.c:1124:extp #pag:[r2+#66],#3: trailing chars after expression
test.c:1125:Warning:Missing operand value assumed absolute 0.
test.c:1125:mov r4,pof:[r2+#66]: trailing chars after expression
test.c:1127:Warning:Missing operand value assumed absolute 0.
test.c:1127:mov pof:[r2+#66],r4: trailing chars after expression
Any hints about how to make this work are welcome. Also an x86 version (of inline assembly) on how to access variables defined in a C/C++ structure would be helpful. Documentation of the GNU inline assembler explaining what "=m" keyword does is also useful.
Thanks in advance,
Iulian