I need to implement a simple critical section protection macro.
When enter the critical section, the CPU need to:
1. save the interrupt state to stack
2. disable interrupt.
On exit the critical section
1. restore the interrupt state from stack.
In the x86 world, I've seen
pushf ; save interrupt flag onto stack
cli ; disable interrupt
popf ; restore interrupt flag from stack
both macros must within the same function.
I need to know how such critical section is usually done in HC08 micro.
Best if it is in Codewarrior C macro with inline asm.
Thanks for the help