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" );
__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.
../../Setup/HardFault_handler.c(72): error: predicated instructions must be in IT block
^
<inline asm>(1): note: instantiated into assembly here
MRSNE R0, PSP
../../Setup/HardFault_handler.c(73): error: predicated instructions must be in IT block
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" ...
__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)