Hi Mike, Verry interesting - I just looked it up in the docs, but in both MPLAB Simulator and MPSIM these two instructions work fine for clearing the status registers bits. Maybe somebody should write a little program to see what is actually true... The original purpose of the program this construct is in the book is to reset the flags to show how the different instructions and different values set them - it still works at that, but I'm surprised that an error like this would creep into the simulators. myke Maybe it would be wor >On Wed, 26 Nov 1997 09:50:33 -0500 myke predko writes: > >>>movlw 0x0F8 >>>andwf STATUS > >>The purpose of this was to clear the Zero, Half Carry and Carry >Flags >in the Status Register so changes caused by different >instrutions could >be easily seen. > >It doesn't work this way though. Since the andwf instruction inherently >affects the Z flag, the PIC logic will 'lock out' the write to the other >2 flags. The result: > >Z - Set if high 5 bits of STATUS = 00000, clear otherwise. >C - Unchanged. >DC - Unchanged. > >I suggest using either 3 bcf instructions or movlw 0 / movwf STATUS to >clear the flags. This also clears the page select bits of course. >Notice that clrf STATUS will not work for the same reason andwf STATUS >doesn't. However, movwf doesn't inherently affect any status bits so it >will write to the bits properly. > > "I was well aware that the processes of puberty are often fatal to psychic power." - Sir Arthur Conan Doyle