c - Compilation error with %hi() and %lo() with inline assembly code -


i have below in-line assembly code. getting compilation error "error: invalid 'asm': operand number missing after %-letter" @ each line %hi, %lo present.

void func() {    __asm__ (   "lis %%r4, %hi(%0);"   "ori %%r4,%%r4,%lo(%0);"   "stw r3, 0(%%r4);"   "lis %%r4, %hi(%0);"   "ori %%r4,%%r4,%lo(%0);"   "lis %%r3, %hi(%1);"   "ori %%r3,%%r3,%lo(%1);"   "stw %%r3, 0(%%r4);"   ::"r"(var1), "r"(var2)); } 

on further analysis found inline assembly expects number(%0, %1...) whenever finds % symbol. changed % %%(its blind shot), ended in getting many 1 shown below.

{standard input}: assembler messages: {standard input}:3394: error: bad expression {standard input}:3394: error: syntax error; found `h', expected `,' {standard input}:3394: error: junk @ end of line: `hi(%r9)' {standard input}:3394: error: bad expression {standard input}:3394: error: syntax error; found `l', expected `,' {standard input}:3394: error: junk @ end of line: `lo(%r9)' {standard input}:3394: error: bad expression 

after lot of efforts came know there problem if use %hi() or %lo in inline assembly code. if remove %hi , %lo code getting compiled. can suggest me how use %hi() , %lo inside inline assembly code?

gnu not support %hi() , %lo(). instead, uses @h , @l suffixes on symbols denote high , low parts. note can't use register operands, , used r constraint.


Comments

Popular posts from this blog

Email notification in google apps script -

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

javascript - IE11 incompatibility with jQuery's 'readonly'? -