Hi, How can I read condition code register in C? I use STM8S standard peripheral library Best regards Nikolay
..
..
Regardless of the challenging task of transferring assembler code from another MCU to C code on the STM8, everything is already included in the function ITC_GetCPUCC mentioned above:
uint8_t ITC_GetCPUCC(void)
{
#ifdef _COSMIC_
_asm("push cc");
_asm("pop a");
return; /* Ignore compiler warning, the returned value is in A register */
#elif defined _RAISONANCE_ /* _RAISONANCE_ */
return _getCC_();
#else /* _IAR_ */
asm("push cc");
asm("pop a"); /* Ignore compiler warning, the returned value is in A register */
#endif /* _COSMIC_*/
}In fact it is done using pushing CCR to the stack and pop it back to the accumulator.
But as @Community member already wrote: it is questionable whether it actually makes sense to read the CCR in C directly, since all bits can also be processed in other ways, e.g. by conditional commands.
If this problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.
Good luck!
/Peter
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.