> How does the carry bit on a 16c54 work with the DECF opcode? > > Using PSIM I saw that the carry bit is cleared when a subtraction results in >a borrow. If I decrement a variable though, and a borrow occurs, why does >the carry bit not get affected? The Data sheet on the chip says the DECF >affects the carry bit. When does it? > >Thanks >Dave >Applied Magnetics Hi Dave. The carry bit is not affected be INCF or DECF instructions. Only the zero bit is affected. The instructions that affect the carry bit are: BSF STATUS,C ;C=1 BCF STATUS,C ;C=0 CLRF STATUS ;C=0 ADDLW DATA ;depends of result, 1 if borrow ADDWF REG(,W) ;depends of result, 1 if borrow RLF REG(,W) ;C=MSB of REG RRF REG(,W) ;C=LSB of REG SUBLW DATA ;depends of result, 0 if borrow SUBWF REG(,W) ;depends of result, 0 if borrow My data sheets told me this and my experience confirms it. I use the 1994 and 1995 data books. I hope this helps. Fernando Soares