home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
031
/
roots02.zip
/
ROOT36.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-09-18
|
889b
|
48 lines
; Copyright (C) 1992-1994 by Celso Minnitti Jr. All Rights Reserved.
PUBLIC root36
_TEXT segment byte public 'CODE'
assume cs:_TEXT, ds:_TEXT
;**************************************************************************
; ROOT36
; enter: AX = 1 - 0FA00h (64000=40*40*40)
; return: AX = cubic root
; DX = reminder
;**************************************************************************
root36 proc near
push cx
push bx
push si
mov cx,1
mov dx,cx
mov bx,cx
mov si,6
root36_loop: cmp dx,ax
je root36_ret
ja root36_ret0
add bx,si ;bx=7 ,19,37,61...
add si,6 ;si=12,18,24,30...
add dx,bx ;dx=8 ,27,64,125...
inc cx ;cx=2 , 3, 4, 5
jmp root36_loop
root36_ret0: dec cx
sub dx,bx
root36_ret: sub dx,ax
neg dx
mov ax,cx
pop si
pop bx
pop cx
ret
root36 endp
_TEXT ends
end