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

carry bit

as i am doing in assembly language

 setb c
       clr  c


it work's fine but when i tried it in c

 c  = sd;
      sd = c;

the sd may be the high or low it gives error related to declaration of c, i solved it by defining

 sbit C = PSW^7;


i want to know the reasion why it need the seprate declaration.it not required in assembly so why in c please help me to solve this problem

Parents
  • i want to know the reasion why it need the seprate declaration.

    The carry bit should be declared as CY in your <[processor type].h> include file.

    it not required in assembly so why in c

    Because C, all by itself, does not care about the hardware. As far C is concerned, it is entirely irrelevant if your processor even has a carry bit.

    Assembler, on the other hand, is very machine-specific.

    On a side note, it is generally considered to be a bad idea to mess around with the carry flag in C.

Reply
  • i want to know the reasion why it need the seprate declaration.

    The carry bit should be declared as CY in your <[processor type].h> include file.

    it not required in assembly so why in c

    Because C, all by itself, does not care about the hardware. As far C is concerned, it is entirely irrelevant if your processor even has a carry bit.

    Assembler, on the other hand, is very machine-specific.

    On a side note, it is generally considered to be a bad idea to mess around with the carry flag in C.

Children