This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ADDC in C51


What is the most efficient way of assembly instruction ADDC in C51?

Is the following allowed

int add_high,carry,low_poti;

TL0=0x69+low_poti;
TH0=0xF8+add_high+CY;

Or should I do the following?
int add_high,carry,low_poti;

TL0=0x69+low_poti;
if (CY==1)
carry=1;
else
carry=0;
TH0=0xF8+add_high+carry;

Parents
  • Jon is right - if you want to do assembler programming, do it in assembler!

    It is not safe to assume that the Carry flag will contain the "correct" value between 'C' statements (it might happen to work in some specific case, but it ain't necessarily so!)

    'C' provides you with multi-byte data types specifically so that you don't have to manually mess about with the carry flag!

Reply
  • Jon is right - if you want to do assembler programming, do it in assembler!

    It is not safe to assume that the Carry flag will contain the "correct" value between 'C' statements (it might happen to work in some specific case, but it ain't necessarily so!)

    'C' provides you with multi-byte data types specifically so that you don't have to manually mess about with the carry flag!

Children
No data