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
  • Why don't you write C code rather than trying to write assembler code in C. Then, you won't have to worry about the carry bit and such things. For example:

    unsigned int new_timer_reload;
    unsigned int low_poti;
    
    new_timer_reload = 0xF869 + low_poti;
    
    TL0 = new_timer_reload;
    TH0 = new_timer_reload >> 8;
    

    You may want to stop the timer before reloading it and restart it afterwards.

    Jon

Reply
  • Why don't you write C code rather than trying to write assembler code in C. Then, you won't have to worry about the carry bit and such things. For example:

    unsigned int new_timer_reload;
    unsigned int low_poti;
    
    new_timer_reload = 0xF869 + low_poti;
    
    TL0 = new_timer_reload;
    TH0 = new_timer_reload >> 8;
    

    You may want to stop the timer before reloading it and restart it afterwards.

    Jon

Children
No data