Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  2.         .data
  3. yint:
  4.         .word   0,0
  5. pow.LCW1:
  6.         .word   0
  7. pow.LCW2:
  8.         .word   0
  9.  
  10.         .text
  11. pow.LC0:
  12.         .double 0d1.0e+00
  13.  
  14. .global pow;
  15.  
  16. frac:
  17.         fstcw   pow.LCW1
  18.         fstcw   pow.LCW2
  19.         fwait
  20.         andw    $0xf3ff,pow.LCW2
  21.         orw     $0x0400,pow.LCW2
  22.         fldcw   pow.LCW2
  23.         fldl    %st(0)
  24.         frndint
  25.         fldcw   pow.LCW1
  26.         fxch    %st(1)
  27.         fsub    %st(1),%st
  28.         ret
  29.  
  30. Lpow2:
  31.         call    frac
  32.         f2xm1
  33.         faddl   pow.LC0
  34.         fscale
  35.         fstp    %st(1)
  36.         ret
  37.  
  38. pow:
  39.         fldl    12(%esp)
  40.         fldl    4(%esp)
  41.         ftst   
  42.         fnstsw  %ax
  43.         sahf
  44.         jbe     xltez
  45.         fyl2x
  46.         jmp     Lpow2
  47. xltez:
  48.         jb      xltz
  49.         fstp    %st(0)
  50.         ftst
  51.         fnstsw  %ax
  52.         sahf
  53.         ja      ygtz
  54.         jb      error
  55.         fstp    %st(0)
  56.         fld1
  57.         fchs
  58. error:
  59.         fsqrt
  60.         ret
  61. ygtz:
  62.         fstp    %st(0)
  63.         fldz
  64.         ret
  65. xltz:
  66.         fabs
  67.         fxch    %st(1)
  68.         call    frac
  69.         ftst
  70.         fnstsw  %ax
  71.         fstp    %st(0)
  72.         sahf
  73.         je      yisint
  74.         fstp    %st(0)
  75.         fchs
  76.         jmp     error
  77. yisint:
  78.         fistl   yint
  79.         fxch    %st(1)
  80.         fyl2x
  81.         call    Lpow2
  82.         andl    $1,yint
  83.         jz      yeven
  84.         fchs
  85. yeven:
  86.         ret
  87.  
  88.