This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Predicated inline assembly instructions raise error

Hi there,

I was inlining some assembly code according to an example for a fault handler as:

__asm volatile( "ITE NE" );
__asm volatile( "MRSNE R0, PSP" );
__asm volatile( "MRSEQ R0, MSP" );

However, that raised an error when compiling:

../../Setup/HardFault_handler.c(72): error: predicated instructions must be in IT block
        __asm volatile( "MRSNE R0, PSP" );
                        ^
<inline asm>(1): note: instantiated into assembly here
        MRSNE R0, PSP
        ^
../../Setup/HardFault_handler.c(73): error: predicated instructions must be in IT block
        __asm volatile( "MRSEQ R0, MSP" );
                        ^
<inline asm>(1): note: instantiated into assembly here
        MRSEQ R0, MSP
        ^
2 errors generated.

When rewriting this to a single __asm function, the equivalent code compiles fine:

__asm volatile (
  ...
  "ITE EQ \n\t"
  "MRSEQ R0, MSP \n\t"
  "MRSNE R0, PSP \n\t"
  ...

);

In my opinion, the compiler in the upper example should somehow remember from the last translated __asm instruction that an IT block is already opened, and how many lines it comprises.

(Compiler 6 in Keil µVision, Code for ARM Cortex M4)

Parents
  • Hi Ronan, yes, makes sense from the standpoint that every __asm function is independent.
    I had not done inline ASM so far, and in this case, I have seen examples which used an __asm for each line. Even declaring labels and jumping to them works that way. So it was surprising that declaring an IT block does not.
    Whatever, using several commands in one __asm function is less noise anyway. Thanks for confirming!

    Regards, Ingmar

Reply
  • Hi Ronan, yes, makes sense from the standpoint that every __asm function is independent.
    I had not done inline ASM so far, and in this case, I have seen examples which used an __asm for each line. Even declaring labels and jumping to them works that way. So it was surprising that declaring an IT block does not.
    Whatever, using several commands in one __asm function is less noise anyway. Thanks for confirming!

    Regards, Ingmar

Children
No data