;********************************************************************** ;SMALL 8 BIT SQUARE ROOT ; ;Author: Nikolai Golovchenko <golovchenko at mail.ru> ;Idea: Scott Dattalo <www.dattalo.com> ;"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 mov W, #-1 Sqrt8s1 ;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. ; addlw 2 mov Hack, W mov W, #2 add W, Hack sub ACCB0, W snb C jmp Sqrt8s1 mov ACCB0, W ; dec ACCB0 ;Dmitry Kiryashov says: Since W is always holding odd value this decf ; isn't required I guess. ... W is always 1,3,5,7,9,.. right? ;and Scott Dattalo aggrees. rr ACCB0 ret ;**********************************************************************