문제

When using inline assembly with XLC compiler (for powerpc) the labels are translated and as a result it is impossible to know the final label name for jumps. Example:

int main()
{
    __asm__("mylabel:");      
    __asm__("nop");
    __asm__("b mylabel");
}

If I compile the previous code using GCC, everything works as expected. However, when using XLC, the assembly generated is the following:

...
.L1
nop
b mylabel
...

Obviously, the program fails to compile because "mylabel" is never defined. The definition of "mylabel" is automatically translated to ".L1" name. Actually this name depends on the number of local labels defined. So, it can be ".L1", ".L2" ...

I tried using asm, __asm instead of __asm__ but I get the same output. Disabling compiler optimizations does not work either. Does anybody know how to keep local label names when generating assembly in XLC? Any other work-around will help too.

Thank you,

도움이 되었습니까?

해결책

This says Branching to a label in another asm statement is not supported.

Try putting all of your inline assembly code into a single __asm__ statement something like:

    __asm__("mylabel:\n"
            "nop\n"
            "b mylabel");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top