On Wed, 16 Feb 2000, Nikolai Golovchenko wrote: > May be you miscounted instructions again? I squeezed one instruction > (10%) out. I wonder how did you find this method, intuition or what? > > ;********************************************************************** > ;SMALL 8 BIT SQUARE ROOT > ; > ;Author: Nikolai Golovchenko > ;Idea: Scott Dattalo > ;"Hint: n^2 = sum of the first n odd integers.(e.g 9 = 3*3 = 1 + 3 + 5)" > ;Date: February 16, 2000 > ; > ;Input and output in ACCB0 > ;ROM - 9 > ;RAM - 1 > ;Timing - 12..87 cycles including call and return > ;********************************************************************** > Sqrt8s > movlw -1 > Sqrt8s1 > addlw 2 > subwf ACCB0, f > skpnc > goto Sqrt8s1 > movwf ACCB0 > decf ACCB0, f > rrf ACCB0, f > return > ;********************************************************************** No, I didn't miscount instructions (I did miscount cycles). I use W to pass and return the number being rooted (and place the burden on the callee instead of the caller). But otherwise, we got the same kind of solution - not identical but very similar... 2 stones to kill one bird: sqrt8 movwf temp movlw 1 sqrt8a addlw -2 addwf temp,f skpnc goto sqrt8a movwf temp comf temp,f rrf temp,w return In fact, if I pass and return the root in a file register: sqrt8 movlw 1 sqrt8a addlw -2 addwf temp,f skpnc goto sqrt8a movwf temp comf temp,f rrf temp,f return Then the execution time is the same :) Scott