home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / vrac / roots02.zip / ROOT36.ASM < prev    next >
Assembly Source File  |  1994-09-18  |  889b  |  48 lines

  1. ; Copyright (C) 1992-1994 by Celso Minnitti Jr. All Rights Reserved.
  2.  
  3. PUBLIC root36
  4.  
  5. _TEXT    segment byte public 'CODE'
  6.     assume cs:_TEXT, ds:_TEXT
  7.  
  8. ;**************************************************************************
  9. ;                 ROOT36
  10. ; enter:   AX = 1 - 0FA00h (64000=40*40*40)
  11. ; return:  AX = cubic root
  12. ;       DX = reminder
  13. ;**************************************************************************
  14. root36        proc    near
  15.         push    cx
  16.         push    bx
  17.         push    si
  18.  
  19.         mov    cx,1
  20.         mov    dx,cx
  21.         mov    bx,cx
  22.         mov    si,6
  23.  
  24. root36_loop:    cmp    dx,ax
  25.         je    root36_ret
  26.         ja    root36_ret0
  27.  
  28.         add    bx,si             ;bx=7 ,19,37,61...
  29.         add    si,6             ;si=12,18,24,30...
  30.         add    dx,bx             ;dx=8 ,27,64,125...
  31.         inc    cx             ;cx=2 , 3, 4, 5
  32.         jmp    root36_loop
  33.  
  34. root36_ret0:    dec    cx
  35.         sub    dx,bx
  36. root36_ret:    sub    dx,ax
  37.         neg    dx
  38.         mov    ax,cx
  39.  
  40.         pop    si
  41.         pop    bx
  42.         pop    cx
  43.         ret
  44. root36        endp
  45.  
  46. _TEXT    ends
  47. end
  48.