On Sat, 15 Jun 2002, Dmitriy A. Kiryashov wrote: >Hi Peter. > >2nd look... > >Base_4 inc/dec is obvious and not interesting. Actually it's not so obvious because I can't have carry into File.2. It's a flag. So I have adopted (embraced ?) your idea and (I know my code is ugly): ; W=27 ; T=12 (crt) btfsc File,Bb4 ; base four ? goto b4_all btfss File,Bfwd ; count up ? goto b3_bwd ; + b3 movlw 1 btfsc File,1 ; ==2? 2+1=3 -> 0 movlw -2 goto ($+1) ; timing goto all_done b3_bwd: ; - b3 movlw 2 btfss File,1 btfsc File,0 movlw -1 goto all_done b4_all: btfss File,Bfwd goto b4_bwd ; + b4 movlw -3 ; the same idea again btfsc File,1 btfss File,0 movlw 1 goto all_done b4_bwd: ; - b4 movlw 3 btfss File,1 btfsc File,0 movlw -1 nop ; timing all_done: addwf File,f 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: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads