| ??? 01/10/04 11:34 Read: times |
#62293 - RE: RLC using C Responding to: ???'s previous message |
Hi,
while rotating a byte ... to store the carry it is a little bit confusing! Depend on what do you mean with "story". Here is an example how to do in ANSI C: unsigned char a_byte, carry;
// ...
// here we need to do something like RLC a_byte
if (a_byte & 0x80)
{
a_byte = (a_byte << 1) | (carry ? 1 : 0);
carry = 1;
}
else
{
a_byte = (a_byte << 1) | (carry ? 1 : 0);
carry = 0;
}Here I used unsigned char for carry flag. You may use bitfield (carry :1). With Keil you just need to read manual about how to use bit/sbit fields.
But as Andy already said: do not use REAL Carry Flag (PSW.7) because it is subject of change by compiler without notification you. Good days! |
| Topic | Author | Date |
| RLC using C | 01/01/70 00:00 | |
| RE: RLC using C | 01/01/70 00:00 | |
| DO *NOT* DO THIS! | 01/01/70 00:00 | |
RE: RLC using C | 01/01/70 00:00 |



