home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 17
/
CD_ASCQ_17_101194.iso
/
vrac
/
roots02.zip
/
ROOT22.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-09-18
|
935b
|
45 lines
; Copyright (C) 1992-1994 by Celso Minnitti Jr. All Rights Reserved.
PUBLIC root22
_TEXT segment byte public 'CODE'
assume cs:_TEXT, ds:_TEXT
.386
;**************************************************************************
; ROOT22
; enter: EAX = 1 - 0FFFE0001h (4294836225=65535*65535)
; return: EAX = square root
; EDX = reminder
;**************************************************************************
root22 proc near
push ecx
push ebx
xor ecx,ecx
inc cx
mov edx,ecx
mov ebx,ecx ;ecx=edx=ebx=1
root22_loop: cmp edx,eax
je short root22_ret
ja short root22_ret0
add ebx,2 ;ebx=1,3,5,7 ,9 ,11,13...
add edx,ebx ;edx=1,4,9,16,25,36,49...
inc ecx ;ecx=1,2,3,4 ,5 ,6 ,7 ...
jmp short root22_loop
root22_ret0: dec ecx
sub edx,ebx
root22_ret: sub edx,eax
neg edx
mov eax,ecx
pop ebx
pop ecx
ret
root22 endp
_TEXT ends
end