Hi Peter and guys. Couple final steps to bit my favorite 12 clocks/words. ;) The code is not tested though... ;11 words/clocks asyncronous btfsc direction ;skip if dec comf File,F ;11->00 ; movlw 2 btfsc base ;skip if base_3 movlw 3 btfss File,1 btfsc File,0 movlw -1 addwf File,F ; btfsc direction ;skip if dec comf File,F ;recover Explanation: -((-x-1)+a)-1 = x+1-a-1 = x - a WBR Dmitry. > Attempt to do some further steps in optimization... > ( Cy polarity still depends from inc/dec , so use > direction flag in addition to) Code is untested... > > #define File,3 base ;0/1 base_3/base_4 > #define File,2 direction ;0/1 dec/inc > > // inc(b3) -> if (File>=2) W=-2 else W=1 ;sub 2/-1 > // inc(b4) -> if (File==3) W=-3 else W=1 ;sub 3/-1 > // dec(b3) -> if (File==0) W=2 else W=-1 ;add 2/-1 > // dec(b4) -> if (File==0) W=3 else W=-1 ;add 3/-1 > > ;15_Words/11_Clocks > > movlw 2 > btfsc base ;skip if base_3 > movlw 3 > > btfsc direction ;skip if dec > goto check_inc > > check_dec: > > btfss File,0 > btfsc File,1 > movlw -1 skip ( -1 ) if File==0 > > addwf File,F > goto all_done > > check_inc: > btfsc base ;avoid .0 check if base_3 > btfsc File,0 > btfss File,1 > movlw -1 skip ( -1 ) if File==3 > > subwf File,F > > all_done: > > ;..... > > WBR Dmitry. > > > I feel that this can be improved probably by merging some shared parts of > > the different blocks but it is fast enough as is and I have plenty of > > space. > > > > And no, it's not a motor driver ;-). > > > > >>>>>>> previous posting, quoted > > >;Base_3 inc / File 1.0 used, other bits are preserved > > >;inc(0)=1 Cy=0, inc(1)=2 Cy=0, inc(2)=0 Cy=1, ... > > > > > >movlw 1 > > >btfsc File,1 ; ==2? 2+1=3 -> 0 > > >movlw -2 > > >addwf File,F > > > > > >;Base_3 dec / File 1.0 used, other bits are preserved > > >;dec(2)=1 Cy=1, dec(1)=0 Cy=1, dec(0)=2 Cy=0, ... > > > > > >movlw 2 > > >btfss File,1 <---- > > >btfsc File,0 <---- > > >movlw -1 > > >addwf File,F > > > > this is the neat eye-opener idea. > > thank you very much, > > Peter -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.