The hint (Euler) is an excellent example of true intelligence
Codice:
;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: x
;Output: y
;ROM - 10
;RAM - 2
;Timing, including call and return
;Best case: 6+9=15 cycles
;Worst case: 6+2+8*16-2+1=135 cycles
;**********************************************************************
Sqrt8s
        mov     W, #-1
        mov     y, W
Sqrt8s1
        inc     y
        inc     y
        mov     W, y
        sub     x, W
        snb     C
        jmp     Sqrt8s1
        rr      y
        ret