home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 17
/
CD_ASCQ_17_101194.iso
/
vrac
/
roots02.zip
/
ROOT26.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-09-18
|
846b
|
43 lines
; Copyright (C) 1992-1994 by Celso Minnitti Jr. All Rights Reserved.
PUBLIC root26
_TEXT segment byte public 'CODE'
assume cs:_TEXT, ds:_TEXT
;**************************************************************************
; ROOT26
; enter: AX = 1 - 0FE01h (65025=255*255)
; return: AX = square root
; DX = reminder
;**************************************************************************
root26 proc near
push cx
push bx
mov cx,1
mov dx,cx
mov bx,cx
root26_loop: cmp dx,ax
je root26_ret
ja root26_ret0
add bx,2 ;bx=1,3,5,7 ,9 ,11,13...
add dx,bx ;dx=1,4,9,16,25,36,49...
inc cx ;cx=1,2,3,4 ,5 ,6, 7 ...
jmp root26_loop
root26_ret0: dec cx
sub dx,bx
root26_ret: sub dx,ax
neg dx
mov ax,cx
pop bx
pop cx
ret
root26 endp
_TEXT ends
end