Microchip C inline asm does not generate prefix for immediates in inline asm

Viewed 178

Im trying to implement my own memcpy function in asm. CPU is dsPIC33F, compiler Microchip C30.

asm("repeat %2 \n mov.b [%1++], [%0++]" 
   : : "r"(dst), "r"(src), "ri"(len));

When len is variable, this works fine: the compiler picks a register and there is no problem. But when len is a compile-time constant (eg 10), assembler says: Error: Invalid operands specified ('repeat 10').

This is because microchip assembler requires # before immediates: repeat #10
Using #%2 in the source wouldn't be viable because that would break if the compiler picked a register.

Is it a microchip compiler bug?

Is there any way to write inline asm that will expand correctly to
repeat reg or repeat #imm for "ri" or "g"?

0 Answers
Related