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