fif8.s 624 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #
  2. ! $Source$
  3. ! $State$
  4. ! $Revision$
  5. #include "powerpc.h"
  6. .sect .text
  7. ! Multiplies two floats, and returns the fraction and integer.
  8. .define .fif8
  9. .fif8:
  10. lfd f0, 8(sp)
  11. lfd f1, 0(sp)
  12. fmul f0, f0, f1
  13. fabs f1, f0 ! f0 = result
  14. ! The following chunk does f1 = floor(f1). See page 158 of the book.
  15. mtfsfi cr7, 3 ! set rounding mode to -inf.
  16. mtfsb0 23
  17. fctid f2, f1
  18. fcfid f2, f2
  19. mcrfs cr7, cr5
  20. bc IFFALSE, 31, toobig
  21. fmr f1, f2
  22. toobig:
  23. fabs f2, f1 ! f2 = fabs(f1)
  24. fsub f2, f2, f1
  25. stfd f2, 8(sp)
  26. fneg f2, f1
  27. fsel f2, f0, f1, f2
  28. stfd f2, 0(sp)
  29. bclr ALWAYS, 0, 0