home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
031
/
roots02.zip
/
ROOT32.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-09-18
|
994b
|
50 lines
; Copyright (C) 1992-1994 by Celso Minnitti Jr. All Rights Reserved.
PUBLIC root32
_TEXT segment byte public 'CODE'
assume cs:_TEXT, ds:_TEXT
.386
;**************************************************************************
; ROOT32
; enter: EAX = 1 - 0FFC3B3C9h (4291015625=1625*1625*1625)
; return: EAX = cubic root
; EDX = reminder
;**************************************************************************
root32 proc near
push ecx
push ebx
push esi
xor ecx,ecx
inc cx
mov edx,ecx
mov ebx,ecx ;ecx=edx=ebx=1
mov esi,6
root32_loop: cmp edx,eax
je short root32_ret
ja short root32_ret0
add ebx,esi ;ebx=7 ,19,37,61...
add esi,6 ;esi=12,18,24,30...
add edx,ebx ;edx=8 ,27,64,125...
inc ecx ;ecx=2 , 3, 4, 5
jmp root32_loop
root32_ret0: dec ecx
sub edx,ebx
root32_ret: sub edx,eax
neg edx
mov eax,ecx
pop esi
pop ebx
pop ecx
ret
root32 endp
_TEXT ends
end