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)
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