home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / prog / realasm1 / ftpower.asm < prev    next >
Encoding:
Assembly Source File  |  1993-07-18  |  1.4 KB  |  46 lines

  1. .286
  2. ;================================================
  3. ; invoke ftpower, real, power
  4. ;
  5. ; Returns real**power
  6. ;------------------------------------------------
  7. cseg          segment word public 'code'
  8.               assume  cs:cseg,ss:cseg
  9.               assume  ds:cseg,es:cseg
  10.  
  11.               include math.inc
  12.  
  13. ftpower       proc    near uses cx si di ds, real:NPR10, power:WORD
  14.               local   t:REAL10
  15.  
  16.               mov     cx, power
  17.               .IF     (cx == 0)                 ;
  18.                  invoke  load1, real            ; real**0 = 1.0
  19.               .ELSEIF (cx == 1)
  20.                  jmp     exit                   ; real**1 = real
  21.               .ELSE
  22.                  mov     si, real               ;
  23.                  lea     di, t                  ;
  24.                  invoke  movx, di, si, 5        ; t = real
  25.  
  26.                  dec     cx
  27.                  .WHILE (cx)
  28.                     invoke ftmul, si, di        ; real *= t
  29.                     dec    cx
  30.                  .ENDW
  31. ;------------------------------------------------
  32. ; if even power and -real, result is +ve
  33. ;------------------------------------------------
  34.                  .IF ((word ptr [di]+8 & 8000h) && (!(power & 1)))
  35.                     and     word ptr [si]+8, 7fffh
  36.                  .ENDIF
  37.               .ENDIF
  38. exit:
  39.               ret
  40. ftpower       endp
  41.  
  42. cseg          ends
  43.               end
  44.  
  45.  
  46.