Matthew Ballinger wrote: > Or a much more efficient routine Yes less instructions, but I have hard to see if it can beat an "addwf PCL" in decode speed, once the input bits are retrieved, and we also have to store them for next time. But I will try your suggestion too. >would be (in parallax mnemonics): >ChkEncoder mov new,encoder ;move the ra port the new var > and new,#00000011 ;clear all but encoder bits > mov temp, new > xor temp,old ;is old and new same? > jz :Return ;if so quit > clc ;clear carry > rl old ;shift old to align old.0 with new.1 >bit > xor old,new ;xor bits to determine direction > jb old.1,:up ;if bit is 1 then up (CW,etc), if bit >is 0 then down (ccw,etc) And then wee need to rotate the other way to align the other bits and xor them to see if it was up. And if neither up or dn, and not same, both bits changed = overspeed or error. Did I get it right? /Morgan Morgans Reglerteknik, HŠllekŒs, 277 35 KIVIK, SWEDEN tel +46(0)414-446620, fax -70331, mrt@iname.com