home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / MATH04.ASM < prev    next >
Assembly Source File  |  1994-11-26  |  790b  |  41 lines

  1.     PAGE    66,132
  2. ;******************************** MATH04.ASM *********************************
  3. LIBSEG           segment byte public "LIB"
  4.         assume cs:LIBSEG , ds:nothing
  5. ;----------------------------------------------------------------------------
  6.  
  7.  
  8. comment 
  9. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  MATH   )
  10. ; word_sqroot - 
  11. ;  input:  ax = radicand
  12. ;  output: dl = root
  13. ;          ax = remainder
  14. ;
  15. ;* * * * * * * * * * * * * *
  16. 
  17.     public    word_sqroot
  18. word_sqroot    proc    far
  19. root:    xor    dx,dx
  20.     mov    bx,4000h
  21.     mov    cx,8
  22. rt1:    sub    ax,dx
  23.     sub    ax,bx
  24.     js    rt_negative
  25.     shr    dx,1
  26.     or    dx,bx
  27.     jmp    loop_tail
  28. rt_negative:
  29.     add    ax,dx
  30.     add    ax,bx
  31.     shr    dx,1
  32. loop_tail:
  33.          shr    bx,1
  34.     shr    bx,1
  35.     loop    rt1
  36.     retf
  37. word_sqroot    endp    
  38.  
  39. LIBSEG    ENDS
  40.     end
  41.