Hi, All !
Consider the following code:
volatile unsigned long a;
void __attribute__((critical)) x(void)
{
a++;
}
Output of the compiler:
/***********************
* Function `x' (OS critical)
***********************/
x:
/* prologue: frame size = 0; addenum 0; alloca:0, varargs:0 , fpr:0*/
.L__FrameSize_x=0x0
.L__FrameOffset_x=0x2
push r2
dint
/* prologue end (size=2) */
;<<<<<<We need to insert nop here
add #llo(1), &a ;<<<<<<Interrupt are not disabled here yet
addc #lhi(1), &a+2
/* epilogue: frame size=0 */
pop r2
ret
/* epilogue end (size=2) */
/* function x size 8 (4) */
.Lfe1:
.size x,.Lfe1-x
/********* End of function ******/
Also I want to propose a simple optimization to replace the sequence
pop r2 ;1 word/2 cycle instruction
ret ; 1 word/3 cycle instruction
with single instruction
reti ; 1 word/5 cycle instruction
I am sure it is easy to implement.
All the best, Oleg.