2021-05-03 03:25 AM
Solved! Go to Solution.
2021-05-04 11:46 AM
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
2021-05-04 05:33 AM
Simply search the SPL for ITC_GetCPUCC or the define CPU_CC_I1I0, which accesses the CCR at 0x28 at the end.
Regards
/Peter
2021-05-04 05:55 AM
Why do you want to read it? In assembly it is useful but I can't think of any use in C.
2021-05-04 11:27 AM
Hey Peter,
I know this address. I mean, how should I read from it?
2021-05-04 11:30 AM
Hi Wilkol,
I'm translating one Assembly app (some other IC) to C (STM8S) and it's not a very easy task.
2021-05-04 11:46 AM
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
2021-05-04 12:19 PM
Peter, thanks for the comprehensive answer. I'll check it tomorrow
Best regards
Nikolay
2021-05-05 03:51 AM
uint8_t condition_code_register;
condition_code_register = ITC_GetCPUCC();