;Program to find the integer square root of a byte
;Uses the fact that the sum of the first N odd integers is the
;  square of N
;input   --   400h
;output  --   401h
;
;
        mov     al, byte ptr 400h       ;grab the input6
        mov     cl, 0                   ; count for square root
        mov     bl, 1                   ; odd nums
lp:     cmp     al, bl                  ; can we do the subtract??
        jb      ex                      ;  jump if we cannot!
        sub     al, bl                  ; else, go ahead and do the sub
        add     bl, 2                   ; create the next odd number
        add     cl, 1                   ; increase the count of subs (which
;                                           will also be the sqr root)
        jmp     lp
ex:     mov     byte ptr 401h, cl
        hlt
        end