#include "intrinsics_hc08.h"void foo(void){ unsigned char before = __isflag_int_enabled(); DisableInterrupts; /* disable interrupts */ .. ... if(before) EnableInterrupts; /* enable interrupts */ }
Hi all,
I have a query regarding Z bit in CCR. When the following is performed,
a= 10
b=10
if (a==b), then Z flag should be set to TRUE.
However as soon as the instruction is executed the Z flag is cleared, when any other statements in the code is executed. There are no decision statements which is executed after this.
As I am from a testing background, I expect Z flag to be set to TRUE, until next comparison is performed.
Please help me out on this.
Thanks,
Dharani
Hello Dharani,
If you examine the reference manual for the device you are using, you should observe that a large proportion of the assembly instructions will affect the status of the Z-flag, not just the compare instructions.
You would seem to have two choices within your C code -
For the latter method:
byte a, b, c;
...
c = (a == b); // Result is true or false
...
if (c) {
// Do something
}
Regards,
Mac