Howdy! I have not actually tried to complement the C bit directly in a PIC. However, based on this discuession I took a careful look at the docs, and they seem to imply that: > movlw 1 > xorlw STATUS, F WILL NOT WORK. I guess the simulator in MPLAB has a bug in this regard, or is an undocumented feature? See section 4.2.2.1 of the PIC16C84 data sheet (page14): "When the status register is the destination for an instruction that affects the Z, DC or C bits, then the write to these bits is disabled. The specified bits(s) will be updated according to the device logic." This seems unnatural indeed. However, can you imagine what it would be like to try an understand arithmatic involving the status register.... but why would we want to do that? incf STATUS,F or movlw 42 addwf STATUS,F I suspect that the "write to these bits is disabled" is not as intentional as it sounds. I suspect that it is more of a result of the state machine nature of the device. At the start of an instruction, the C, DC, Z bits are latched into the ALU section, the instruction is executed, and then the C, DC, Z bits are then latched back into the status register from the ALU... NOT from the normal data paths (as with other normal registers). Just my thoughts! I will write some code to see what really happens! Cheers, Don At 09:35 AM 11/25/98 +0100, you wrote: >At 09:11 1998-11-25 +0800, you wrote: >>Hi, >> >>I guess you're right. I thought STATUS works like any other registers. >>Thanks for the advice. I should have read the datasheets thoroughly. >> >>regards, >>Reggie > >?? > >Guys, it *do* work in MPLAB (3.99.23), and why should it not? > > movlw 1 > xorlw STATUS, F > >The internal operation of xorwf do not affect carry, and as the STATUS >register is the destination the carry flag is indeed *written to*, as with >any other register. > >However Dimitry's solution is cool :) > >Regards >/Morgan > >>Dmitry Kiryashov wrote: >>> Hello Reggie. >>> >>> C bit is only may changed after ADDLW/ADDWF/SUBLW/SUBWF/RLF/RRF >>> commands. >>> Also it modified after BCF/BSF instructions but I think this BxF >>> commands >>> are helpless in this case. >>> >>> BTW check your code practically - it's not work. >>> >>> WBR Dmitry. >> >> > Morgan Olsson ph +46(0)414 70741 > MORGANS REGLERTEKNIK fax +46(0)414 70331 > H€LLEKS (in A-Z letters: "HALLEKAS") > SE-277 35 KIVIK, SWEDEN mrt@iname.com >___________________________________________________________ > >