In a message dated 10/2/99 3:46:23 AM Eastern Daylight Time, morgans.rt@TELIA.COM writes: > 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? > Not quite. *Everything* is taken care of with this code. 1.If code jumps to :return , then no change in posistion was made. 2.If the final xor produces a 1 then the encoder went CW 3.If the final xor produces a 0 then the encoder went CCW Nothing more to do. Ok, well, add 1 instruction to store the old bits (oops). Speed doesn't really suffer either. I'll count the instructions though to be sure. You may be right. Matt Ballinger