You are, of course, correct, but I have a question. Does your code always use the same # of cycles, I am confused about how the PIC handles a long sequence of 2 byte instructions like this. If it is, is this why you chose goto $+2 for the first goto instead of goto $+4? CIAO - Martin R. Green elimar@bigfoot.com ---------- From: KLAMS10/KLAMS100/XH01G6 on behalf of Mark Langezaal[SMTP:mlangezaal@KLM.NL] Sent: Monday, September 22, 1997 5:54 AM To: 'PICLIST@MITVMA.MIT.EDU' Subject: RE: Multi-byte counter trick Importance: High 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