How to save HC08's interrupt state to the stack without using register?

How to save HC08's interrupt state to the stack without using register?

Post by Fred » Fri, 05 Mar 2004 17:21:39


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
on entry:
pushf ; save interrupt flag onto stack
cli ; disable interrupt

on exit:
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

Fred