Dmitry Kiryashov wrote: >Hello Piclister members ! > > I am sure that I am not first discover of this but it's greate ! > PIC have nice ability to implement normal multi-byte counters . > Look at example below . (Let it will 3 byte incrementing) > --- > incfsz low,f > skpnz > incfsz medium,f > skpnz > incf high,f >--- >Last instruction is INCF not INCFSZ . >Execution time is always equal to 7 clocks ! > >So any n-byte inc/dec operation have execution time equal to: 1+(n-1)*3 >And previous carry flag not corrupted . > >WBR Dmitry. Unfortunately this code will NOT work as you might expect! When you read the pic manual carefully you will see that the incfsz instruction does NOT modify the status register, and so will not set or clear the Z flag. Don't ask me how I found this out... If the above routine is called with the Z flag set, then the files medium and high are ALWAYS incremented. However, If you change your code to: incfsz low,f goto $+2 incfsz medium,f goto $+2 incf high,f then it will work. Mark Langezaal