2011-07-26 08:52:24 +00:00
|
|
|
; ===========================================================================
|
|
|
|
; Copyright (C) 2011 Thilo Schulz <thilo@tjps.eu>
|
|
|
|
;
|
|
|
|
; This file is part of Quake III Arena source code.
|
|
|
|
;
|
|
|
|
; Quake III Arena source code 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.
|
|
|
|
;
|
|
|
|
; Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
|
|
|
|
; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
; ===========================================================================
|
|
|
|
|
|
|
|
; MASM ftol conversion functions using SSE or FPU
|
|
|
|
; assume __cdecl calling convention is being used for x86, __fastcall for x64
|
|
|
|
|
|
|
|
IFNDEF idx64
|
2017-07-10 01:33:41 +00:00
|
|
|
.686p
|
|
|
|
.xmm
|
2011-07-26 08:52:24 +00:00
|
|
|
.model flat, c
|
|
|
|
ENDIF
|
|
|
|
|
2011-12-10 00:15:42 +00:00
|
|
|
.data
|
2011-07-26 08:52:24 +00:00
|
|
|
|
2011-12-10 00:15:42 +00:00
|
|
|
ifndef idx64
|
|
|
|
fpucw WORD 0F7Fh
|
|
|
|
endif
|
2011-07-26 08:52:24 +00:00
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
IFDEF idx64
|
|
|
|
; qftol using SSE
|
|
|
|
|
|
|
|
qftolsse PROC
|
|
|
|
cvttss2si eax, xmm0
|
|
|
|
ret
|
|
|
|
qftolsse ENDP
|
|
|
|
|
|
|
|
qvmftolsse PROC
|
|
|
|
movss xmm0, dword ptr [rdi + rbx * 4]
|
|
|
|
cvttss2si eax, xmm0
|
|
|
|
ret
|
|
|
|
qvmftolsse ENDP
|
|
|
|
|
|
|
|
ELSE
|
|
|
|
; qftol using FPU
|
|
|
|
|
|
|
|
qftolx87m macro src
|
2011-12-10 00:15:42 +00:00
|
|
|
sub esp, 2
|
|
|
|
fnstcw word ptr [esp]
|
|
|
|
fldcw fpucw
|
2011-07-26 08:52:24 +00:00
|
|
|
fld dword ptr src
|
|
|
|
fistp dword ptr src
|
2011-12-10 00:15:42 +00:00
|
|
|
fldcw [esp]
|
2011-07-26 08:52:24 +00:00
|
|
|
mov eax, src
|
2011-12-10 00:15:42 +00:00
|
|
|
add esp, 2
|
2011-07-26 08:52:24 +00:00
|
|
|
ret
|
|
|
|
endm
|
|
|
|
|
|
|
|
qftolx87 PROC
|
2011-12-10 00:15:42 +00:00
|
|
|
qftolx87m [esp + 6]
|
2011-07-26 08:52:24 +00:00
|
|
|
qftolx87 ENDP
|
|
|
|
|
|
|
|
qvmftolx87 PROC
|
|
|
|
qftolx87m [edi + ebx * 4]
|
|
|
|
qvmftolx87 ENDP
|
|
|
|
|
|
|
|
; qftol using SSE
|
|
|
|
qftolsse PROC
|
|
|
|
movss xmm0, dword ptr [esp + 4]
|
|
|
|
cvttss2si eax, xmm0
|
|
|
|
ret
|
|
|
|
qftolsse ENDP
|
|
|
|
|
|
|
|
qvmftolsse PROC
|
|
|
|
movss xmm0, dword ptr [edi + ebx * 4]
|
|
|
|
cvttss2si eax, xmm0
|
|
|
|
ret
|
|
|
|
qvmftolsse ENDP
|
|
|
|
ENDIF
|
|
|
|
|
|
|
|
end
|