We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi i want to get the value of the carry flag (after shift to left) from c code how to do it?? thanks
Don't use internal registers in C! Neither ACC nor B, R0-R7, DPTR and so on.
If you have to use the carry bit CY: Try to use an equivalent algorithm (see the suggestion from Erik). If this is not possible or insufficient, then use the alternative solution: It's highly recommended to use CY either as inline assembler (#pragma asm ... #pragma endasm) of a .C51 module/function or in an external .A51 assembler module/function. And, of course, with own proper initialization of ACC in your asm statements, don't rely on the contents of ACC by the C-compiler!
This suggestion is also valid for checking the parity bit P, which has the same problem as CY.
I often use this technique, e.g. when decoding DCF77 radio clock signal (which has three parity bits).
Martin
"It's highly recommended to use CY either as inline assembler (#pragma asm ... #pragma endasm) of a .C51 module/function or in an external .A51 assembler module/function."
I highly recommend that you should not use inline assembler - use an external .A51 assembler module/function and call it from 'C'
Inline Assembler is still subject to the risk of false assumptions about the states of internal registers!