GNU Inline Build Issue

I did some refactoring in the c167 specific platform code, and I came across a problem with the built-in build.

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 executes the atomic decrement of the variable "g_nRcvBufCount"

Team

"extp" takes "the page of the" variable "g_nRcvBufCount" and the number of subsequent atomic expressions (in this case 3)

]

Current - not compiled 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 variable g_nRcvBufCount.

struct {
  ...
  unsigned short g_nRcvBufCount;
  ...
}cfg;

Errors received during compilation are as follows:

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

, , . x86 ( ) , , C/++. GNU, , "= m", .

,

+3
2

asm :

extp #pag:[r2+#66],#3

-, #pag: , , , [r2+#66]. , "r", cfg->g_nRcvBufCount "m", .

, , , , gcc , asm.

+2

ibiblio

"m": , .

"" - "" - .c , objdump . , .

+1

Source: https://habr.com/ru/post/1777454/


All Articles