s_lrintf.S 932 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Round argument to nearest integer value. SH4 version.
  2. * According to ISO/IEC 9899:1999. This version doesn't handle range error.
  3. * If arg is not finite or if the result cannot be represented into a long,
  4. * return an unspecified value. No exception raised.
  5. *
  6. * Copyright (C) 2010 STMicroelectronics Ltd.
  7. *
  8. * Author: Christian Bruel <christian.bruel@st.com>
  9. *
  10. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  11. */
  12. #include <sysdep.h>
  13. ENTRY(lrintf)
  14. mov #0,r0
  15. sts fpscr,r3
  16. lds r0,fpscr
  17. flds fr5,fpul
  18. mov.l LOCAL(mask),r1
  19. sts fpul,r2
  20. and r2,r1
  21. mov.l LOCAL(midway),r2
  22. or r1,r2
  23. lds r2,fpul
  24. fsts fpul,fr2
  25. fadd fr2,fr5
  26. ftrc fr5,fpul
  27. sts fpul,r0
  28. float fpul,fr2
  29. fcmp/eq fr5,fr2
  30. bf/s 0f
  31. mov #1,r2
  32. tst r1,r1
  33. and r0,r2
  34. movt r1
  35. shal r1
  36. tst r2,r2
  37. add #-1,r1
  38. bt 0f
  39. sub r1,r0
  40. 0:
  41. rts
  42. lds r3,fpscr
  43. .align 2
  44. LOCAL(mask):
  45. .long 0x80000000
  46. LOCAL(midway):
  47. .long 1056964608
  48. END(lrintf)