1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19*/
20//
21// sys_wina.s
22// x86 assembly-language Win-dependent routines.
23
24#include "asm_i386.h"
25#include "quakeasm.h"
26
27//@@@ should be id386-dependent, and have an equivalent C path
28
29	.data
30
31	.align	4
32fpenv:
33	.long	0, 0, 0, 0, 0, 0, 0, 0
34
35	.text
36
37.globl C(MaskExceptions)
38C(MaskExceptions):
39	fnstenv	fpenv
40	orl		$0x3F,fpenv
41	fldenv	fpenv
42
43	ret
44
45#if 0
46.globl C(unmaskexceptions)
47C(unmaskexceptions):
48	fnstenv	fpenv
49	andl		$0xFFFFFFE0,fpenv
50	fldenv	fpenv
51
52	ret
53#endif
54
55	.data
56
57	.align	4
58.globl	ceil_cw, single_cw, full_cw, cw, pushed_cw
59ceil_cw:	.long	0
60single_cw:	.long	0
61full_cw:	.long	0
62cw:			.long	0
63pushed_cw:	.long	0
64
65	.text
66
67.globl C(Sys_LowFPPrecision)
68C(Sys_LowFPPrecision):
69	fldcw	single_cw
70
71	ret
72
73.globl C(Sys_HighFPPrecision)
74C(Sys_HighFPPrecision):
75	fldcw	full_cw
76
77	ret
78
79.globl C(Sys_PushFPCW_SetHigh)
80C(Sys_PushFPCW_SetHigh):
81	fnstcw	pushed_cw
82	fldcw	full_cw
83
84	ret
85
86.globl C(Sys_PopFPCW)
87C(Sys_PopFPCW):
88	fldcw	pushed_cw
89
90	ret
91
92.globl C(Sys_SetFPCW)
93C(Sys_SetFPCW):
94	fnstcw	cw
95	movl	cw,%eax
96#if	id386
97	andb	$0xF0,%ah
98	orb		$0x03,%ah	// round mode, 64-bit precision
99#endif
100	movl	%eax,full_cw
101
102#if	id386
103	andb	$0xF0,%ah
104	orb		$0x0C,%ah	// chop mode, single precision
105#endif
106	movl	%eax,single_cw
107
108#if	id386
109	andb	$0xF0,%ah
110	orb		$0x08,%ah	// ceil mode, single precision
111#endif
112	movl	%eax,ceil_cw
113
114	ret
115
116