I think Keong is looking for something slightly different. movfw port xorwf old_sh,W xorwf old_sh,F andwf old_sh,W ;low2high ? 0=no/1=yes iorwf flags,F ;OR resulting flags Where bits in flag have to be cleared by another procedure after reading and executing. WBR Dmitry. Olin Lathrop wrote: > > > Ok. Now I am using the PIC16CE624 to monitor 8 data > > lines by software polling. Memory location called > > Result is used to store the states of the I/O pins > > with a special condition. In any event say data line 2 > > is toggled from a low to a high, bit 2 of Result will > > be toggle to a '1'. > > So you want a 1 when the previous value of a bit was 0 and the new value is > 1. You have 4 possible cases as shown by this truth table: > > old | new | out > -----|-------|----- > 0 | 0 | 0 > 0 | 1 | 1 > 1 | 0 | 0 > 1 | 1 | 0 > > One way (there are others) to describe what you want is OUT = (-OLD and > NEW). Here is a brute force example with bank selection left as an exercise > to the reader: > > movf portb, w ;get the NEW bits into W > movwf temp ;temp save them > andwf nold, w ;AND the NEW bits with -OLD bits > movwf out ;save OUT bits > comf temp, w ;get -NEW bits > movwf nold ;save as -OLD bits for next time > > This can probably be optimized (Dimitry? Scott?) but I'm trying to > illustrate the algorithm and show how it implements the truth table above. > > ***************************************************************** > Embed Inc, embedded system specialists in Littleton Massachusetts > (978) 742-9014, http://www.embedinc.com > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads