gcc - Compilation errors with inline assembly code in c file, probably with branching -


i have below code. when try compile giving errors mentioned after code snippet.

void func()   __asm__ (     "mfspr     12, 1017;"     "rotrwi    12,12,%0;"     "andi.     11, 12, %1;"     "beq       done;" "3:;"     "mfspr     12, 1017;"     "andi.     11, 12, %2;"     "bne       3b;"     "ori       12, 12, %2;"     "mtspr     1017, 12;"     "isync;" "3:;"     "mfspr     12, 1017;"     "andi.     11, 12, %2;"     "bne       3b;" "done:;"     ::"r"(31), "r"(1), "r"(2048));      } 

errors:

{standard input}: assembler messages: {standard input}:3607: error: bad expression {standard input}:3607: error: missing ')' {standard input}:3607: error: missing ')' {standard input}:3607: error: syntax error; found `r', expected `,' {standard input}:3607: error: junk @ end of line: `r9)!31)&((%r9)|31),0,31' 

i think problem branching doing, not sure whats wrong. can me fixing this?

try instead:

  void func()     __asm__ (       "mfspr     12, 1017\n"       "rotrwi    12,12,%0\n"       "andi.     11, 12, %1\n"       "beq       done\n"   "3:\n"       "mfspr     12, 1017\n"       "andi.     11, 12, %2\n"       "bne       3b\n"       "ori       12, 12, %2\n"       "mtspr     1017, 12\n"       "isync\n"   "3:\n"       "mfspr     12, 1017\n"       "andi.     11, 12, %2\n"       "bne       3b\n"   "done:\n"       ::"i"(31), "i"(1), "i"(2048));   } 

; changed \n make easier see line(s) wrong.

"r"(n) changed "i"(n) instructions use immediates instead of registers.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -