fenv.S raw
1 #if __SH_FPU_ANY__ || __SH4__
2
3 .global fegetround
4 .type fegetround, @function
5 fegetround:
6 sts fpscr, r0
7 rts
8 and #3, r0
9
10 .global __fesetround
11 .hidden __fesetround
12 .type __fesetround, @function
13 __fesetround:
14 sts fpscr, r0
15 mov #-4, r1
16 and r1, r0
17 or r4, r0
18 lds r0, fpscr
19 rts
20 mov #0, r0
21
22 .global fetestexcept
23 .type fetestexcept, @function
24 fetestexcept:
25 sts fpscr, r0
26 and r4, r0
27 rts
28 and #0x7c, r0
29
30 .global feclearexcept
31 .type feclearexcept, @function
32 feclearexcept:
33 mov r4, r0
34 and #0x7c, r0
35 not r0, r4
36 sts fpscr, r0
37 and r4, r0
38 lds r0, fpscr
39 rts
40 mov #0, r0
41
42 .global feraiseexcept
43 .type feraiseexcept, @function
44 feraiseexcept:
45 mov r4, r0
46 and #0x7c, r0
47 sts fpscr, r4
48 or r4, r0
49 lds r0, fpscr
50 rts
51 mov #0, r0
52
53 .global fegetenv
54 .type fegetenv, @function
55 fegetenv:
56 sts fpscr, r0
57 mov.l r0, @r4
58 rts
59 mov #0, r0
60
61 .global fesetenv
62 .type fesetenv, @function
63 fesetenv:
64 mov r4, r0
65 cmp/eq #-1, r0
66 bf 1f
67
68 ! the default environment is complicated by the fact that we need to
69 ! preserve the current precision bit, which we do not know a priori
70 sts fpscr, r0
71 mov #8, r1
72 swap.w r1, r1
73 bra 2f
74 and r1, r0
75
76 1: mov.l @r4, r0 ! non-default environment
77 2: lds r0, fpscr
78 rts
79 mov #0, r0
80
81 #endif
82