Hi Scott, How about, 5 cycles per loop, doesn't use W: clrf lo clrf hi loop incfsz lo,f goto $+2 incfsz hi,f goto loop regards, Reggie -- e-mail: rberdin@bigfoot.com ICQ#: 31651436 URL: http://www.bigfoot.com/~rberdin Scott Dattalo wrote: > > Guys & Alice > > It seems like there's been several questions about delay loops in the > last few weeks. So I thought it'd be interesting to see if we could turn > this into a challenge: > > Create a delay loop that can loop for up to 2^16 times while mininmizing > the number of cycles per iteration. For example: > > clrf lo > clrf hi > > movlw 1 > > loop: > > addwf lo,f ;increment the low byte > skpnc ;if low byte rolls over > addwf hi,f ; then increment the high byte > > skpc ;We're done if the high byte rolls over. > goto loop > > This will loop 2^16 times and each pass through the loop is 6 cycles. > > I've got a solution that takes 5 cycles per iteration and doesn't use W > (oh I shouldn't have said that - now you know the answer!). > > Any takers? > > Scott