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
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.