systmodes.S revision 1.1.1.1 1
2 /*
3 ===============================================================================
4
5 This GNU assembler source file is part of TestFloat, Release 2a, a package
6 of programs for testing the correctness of floating-point arithmetic
7 complying to the IEC/IEEE Standard for Floating-Point.
8
9 Written by John R. Hauser. More information is available through the Web
10 page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
11
12 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
13 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
14 TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
15 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
16 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
17
18 Derivative works are acceptable, even for commercial purposes, so long as
19 (1) they include prominent notice that the work is derivative, and (2) they
20 include prominent notice akin to these four paragraphs for those parts of
21 this code that are retained.
22
23 ===============================================================================
24 */
25
26 .text
27
28 /*
29 -------------------------------------------------------------------------------
30 Sets the system's IEC/IEEE floating-point rounding mode. Also disables all
31 system exception traps.
32 -------------------------------------------------------------------------------
33 */
34 .align 4
35 .global _syst_float_set_rounding_mode
36 _syst_float_set_rounding_mode:
37 movb 4(%esp),%al
38 andb $3,%al
39 shlw $10,%ax
40 orw $63,%ax
41 subl $2,%esp
42 fnstcw 0(%esp)
43 andw $768,0(%esp)
44 orw %ax,0(%esp)
45 fldcw 0(%esp)
46 addl $2,%esp
47 ret
48
49 /*
50 -------------------------------------------------------------------------------
51 Sets the rounding precision of subsequent extended double-precision
52 operations. The `precision' argument should be one of 0, 32, 64, or 80.
53 If `precision' is 32, the rounding precision is set equivalent to single
54 precision; else if `precision' is 64, the rounding precision is set
55 equivalent to double precision; else the rounding precision is set to full
56 extended double precision.
57 -------------------------------------------------------------------------------
58 */
59 .align 4
60 .global _syst_float_set_rounding_precision
61 _syst_float_set_rounding_precision:
62 movb 4(%esp),%al
63 movb $0,%ah
64 cmpb $32,%al
65 je setRoundingPrecision
66 movb $2,%ah
67 cmpb $64,%al
68 je setRoundingPrecision
69 movb $3,%ah
70 cmpb $80,%al
71 je setRoundingPrecision
72 movb $0,%ah
73 setRoundingPrecision:
74 movb $0,%al
75 subl $2,%esp
76 fnstcw 0(%esp)
77 andw $64767,0(%esp)
78 orw %ax,0(%esp)
79 fldcw 0(%esp)
80 addl $2,%esp
81 ret
82
83