2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2002-06-07 15:09:20 +00:00
|
|
|
sw_fpua.S
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Intel 32-bit assembly language dependent routines.
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
2001-05-31 05:33:13 +00:00
|
|
|
#include "asm_i386.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_INTEL_ASM
|
2002-06-01 03:00:13 +00:00
|
|
|
|
2004-01-20 03:47:27 +00:00
|
|
|
#ifdef _WIN32
|
2002-06-01 03:00:13 +00:00
|
|
|
# undef PIC //no such thing in win32
|
|
|
|
#endif
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
.data
|
|
|
|
|
|
|
|
.align 4
|
|
|
|
fpenv:
|
|
|
|
.long 0, 0, 0, 0, 0, 0, 0, 0
|
|
|
|
|
2002-06-01 03:00:13 +00:00
|
|
|
#ifdef PIC
|
|
|
|
#define got_base(n) \
|
|
|
|
call .Lpic##n ;\
|
|
|
|
.Lpic##n: ;\
|
|
|
|
popl %edx ;\
|
|
|
|
addl $C(_GLOBAL_OFFSET_TABLE_)+[.-.Lpic##n],%edx
|
|
|
|
|
2002-06-03 06:01:19 +00:00
|
|
|
#define got_var(v) v@GOTOFF(%edx)
|
2002-06-03 04:06:25 +00:00
|
|
|
|
|
|
|
#define F_BEGIN(name) \
|
|
|
|
.globl C(name) ;\
|
|
|
|
.type C(name),@function ;\
|
|
|
|
C(name):
|
|
|
|
|
|
|
|
#define F_END(name) .size C(name),.-C(name)
|
|
|
|
|
2002-06-01 03:00:13 +00:00
|
|
|
#else
|
|
|
|
#define got_base(n)
|
|
|
|
#define got_var(v) v
|
2002-06-03 04:06:25 +00:00
|
|
|
|
|
|
|
#define F_BEGIN(name) \
|
|
|
|
.globl C(name) ;\
|
|
|
|
C(name):
|
|
|
|
|
|
|
|
#define F_END(name)
|
|
|
|
|
2002-06-01 03:00:13 +00:00
|
|
|
#endif
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
.text
|
|
|
|
|
2002-06-03 04:06:25 +00:00
|
|
|
F_BEGIN(MaskExceptions)
|
2002-06-01 03:00:13 +00:00
|
|
|
got_base(1)
|
|
|
|
fnstenv got_var(fpenv)
|
2002-06-02 04:07:18 +00:00
|
|
|
orl $0x3F,got_var(fpenv)
|
2002-06-01 03:00:13 +00:00
|
|
|
fldenv got_var(fpenv)
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
ret
|
2002-06-03 04:06:25 +00:00
|
|
|
F_END(MaskExceptions)
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#if 0
|
2002-06-03 04:06:25 +00:00
|
|
|
F_BEGIN(unmaskexceptions)
|
2002-06-03 04:58:42 +00:00
|
|
|
got_base(2)
|
2002-06-02 04:07:18 +00:00
|
|
|
fnstenv got_var(fpenv)
|
|
|
|
andl $0xFFFFFFE0,got_var(fpenv)
|
|
|
|
fldenv got_var(fpenv)
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
ret
|
2002-06-03 04:06:25 +00:00
|
|
|
F_END(unmaskexceptions)
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
.data
|
|
|
|
|
|
|
|
.align 4
|
2011-09-10 08:49:14 +00:00
|
|
|
.globl C(ceil_cw), C(single_cw), C(full_cw), C(cw), C(pushed_cw)
|
|
|
|
C(ceil_cw): .long 0
|
|
|
|
C(single_cw): .long 0
|
|
|
|
C(full_cw): .long 0
|
|
|
|
C(cw): .long 0
|
|
|
|
C(pushed_cw): .long 0
|
2002-06-03 17:26:09 +00:00
|
|
|
#ifdef PIC
|
2011-09-10 08:49:14 +00:00
|
|
|
.type C(ceil_cw),@object
|
|
|
|
.type C(single_cw),@object
|
|
|
|
.type C(full_cw),@object
|
|
|
|
.type C(cw),@object
|
|
|
|
.type C(pushed_cw),@object
|
|
|
|
.size C(ceil_cw),4
|
|
|
|
.size C(single_cw),4
|
|
|
|
.size C(full_cw),4
|
|
|
|
.size C(cw),4
|
|
|
|
.size C(pushed_cw),4
|
2002-06-03 17:26:09 +00:00
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
.text
|
|
|
|
|
2002-06-07 15:09:20 +00:00
|
|
|
F_BEGIN(R_LowFPPrecision)
|
2002-06-03 04:58:42 +00:00
|
|
|
got_base(3)
|
2011-09-10 08:49:14 +00:00
|
|
|
fldcw got_var(C(single_cw))
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
ret
|
2002-06-07 15:09:20 +00:00
|
|
|
F_END(R_LowFPPrecision)
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-03 04:58:42 +00:00
|
|
|
|
2002-06-07 15:09:20 +00:00
|
|
|
F_BEGIN(R_HighFPPrecision)
|
2002-06-03 04:58:42 +00:00
|
|
|
got_base(4)
|
2011-09-10 08:49:14 +00:00
|
|
|
fldcw got_var(C(full_cw))
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
ret
|
2002-06-07 15:09:20 +00:00
|
|
|
F_END(R_HighFPPrecision)
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-03 04:58:42 +00:00
|
|
|
|
2002-06-07 15:09:20 +00:00
|
|
|
F_BEGIN(R_SetFPCW)
|
2002-06-03 04:58:42 +00:00
|
|
|
got_base(7)
|
2011-09-10 08:49:14 +00:00
|
|
|
fnstcw got_var(C(cw))
|
|
|
|
movl got_var(C(cw)),%eax
|
2001-02-19 21:15:25 +00:00
|
|
|
andb $0xF0,%ah
|
|
|
|
orb $0x03,%ah // round mode, 64-bit precision
|
2011-09-10 08:49:14 +00:00
|
|
|
movl %eax,got_var(C(full_cw))
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
andb $0xF0,%ah
|
|
|
|
orb $0x0C,%ah // chop mode, single precision
|
2011-09-10 08:49:14 +00:00
|
|
|
movl %eax,got_var(C(single_cw))
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
andb $0xF0,%ah
|
|
|
|
orb $0x08,%ah // ceil mode, single precision
|
2011-09-10 08:49:14 +00:00
|
|
|
movl %eax,got_var(C(ceil_cw))
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
ret
|
2002-06-07 15:09:20 +00:00
|
|
|
F_END(R_SetFPCW)
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif /* USE_INTEL_ASM */
|