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
i want to get the value of the carry flag (after shift to left) from c code how to do it??
The CY bit should be defined in your processor-specific .h file.
However:
Don't do it. Messing around with registers in C is a good way to create a maintenance and debugging nightmare. There is no specified way that these registers behave in C.
Write a short assembly routine that does what you're trying to accomplish and call it from C. This is the clean way to do it.
As Christoph says, it is possible - but definitely not advisable.
Sure, you can access the CY flag in 'C' - but you can never be sure that it relates to the operation that you think and/or require...
The only safe way, as Christoph says, is to use assembler and call it from 'C'.
i want to get the value of the carry flag (after shift to left) from c code one answver The only safe way, as Christoph says, is to use assembler and call it from 'C'.
in C, the same is possible, but by other means:
bit flag;
flag = 0; if (var &0x80) flag = 1; var <<= 1;
use 'flag' as you would CY
Erik
the trigger to use the carry is to remove the "if" ...
consult Jack Sprat, he will tell you to read the manual and see this is how it is, whether you like it or not. C is a magificent product, nobody is to quesation it.