Debian Codegraph @

code/asm/ftola.asm

raw
1 ; ===========================================================================
2 ; Copyright (C) 2011 Thilo Schulz <[email protected]>
3 ;
4 ; This file is part of Quake III Arena source code.
5 ;
6 ; Quake III Arena source code is free software; you can redistribute it
7 ; and/or modify it under the terms of the GNU General Public License as
8 ; published by the Free Software Foundation; either version 2 of the License,
9 ; or (at your option) any later version.
10 ;
11 ; Quake III Arena source code is distributed in the hope that it will be
12 ; useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU General Public License for more details.
15 ;
16 ; You should have received a copy of the GNU General Public License
17 ; along with Quake III Arena source code; if not, write to the Free Software
18 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 ; ===========================================================================
20
21 ; MASM ftol conversion functions using SSE or FPU
22 ; assume __cdecl calling convention is being used for x86, __fastcall for x64
23
24 IFNDEF idx64
25 .686p
26 .xmm
27 .model flat, c
28 ENDIF
29
30 .data
31
32 ifndef idx64
33 fpucw WORD 0F7Fh
34 endif
35
36 .code
37
38 IFDEF idx64
39 ; qftol using SSE
40
41 qftolsse PROC
42 cvttss2si eax, xmm0
43 ret
44 qftolsse ENDP
45
46 qvmftolsse PROC
47 movss xmm0, dword ptr [rdi + rbx * 4]
48 cvttss2si eax, xmm0
49 ret
50 qvmftolsse ENDP
51
52 ELSE
53 ; qftol using FPU
54
55 qftolx87m macro src
56 sub esp, 2
57 fnstcw word ptr [esp]
58 fldcw fpucw
59 fld dword ptr src
60 fistp dword ptr src
61 fldcw [esp]
62 mov eax, src
63 add esp, 2
64 ret
65 endm
66
67 qftolx87 PROC
68 qftolx87m [esp + 6]
69 qftolx87 ENDP
70
71 qvmftolx87 PROC
72 qftolx87m [edi + ebx * 4]
73 qvmftolx87 ENDP
74
75 ; qftol using SSE
76 qftolsse PROC
77 movss xmm0, dword ptr [esp + 4]
78 cvttss2si eax, xmm0
79 ret
80 qftolsse ENDP
81
82 qvmftolsse PROC
83 movss xmm0, dword ptr [edi + ebx * 4]
84 cvttss2si eax, xmm0
85 ret
86 qvmftolsse ENDP
87 ENDIF
88
89 end