Skip to content

Commit c41979d

Browse files
committed
Add win32/q3asm.asm from jk2mv for MSVC builds.
1 parent cf10de6 commit c41979d

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/Modules")
102102
# ${Architecture} must match ARCH_STRING in q_platform.h,
103103
# and is used in DLL names (jagamex86.dll, jagamex86.dylib, jagamei386.so).
104104
if(WIN32)
105+
106+
if(MSVC)
107+
enable_language(ASM_MASM)
108+
endif()
109+
105110
set(X86 ON)
106111
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
107112
set(Architecture "x86_64")

codemp/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ if(BuildMPEngine OR BuildMPDed)
271271
)
272272
endif()
273273

274+
if(MSVC)
275+
set(MPEngineAndDedCommonFiles ${MPEngineAndDedCommonFiles}
276+
"${MPDir}/win32/q3asm.asm"
277+
)
278+
endif()
279+
274280
if(WIN32)
275281
set(MPEngineAndDedCommonFiles ${MPEngineAndDedCommonFiles})
276282
endif(WIN32)

codemp/win32/q3asm.asm

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 WIN64
25+
.686p
26+
.xmm
27+
.model flat, c
28+
ENDIF
29+
30+
.data
31+
ALIGN 16
32+
ssemask DWORD 0FFFFFFFFh, 0FFFFFFFFh, 0FFFFFFFFh, 00000000h
33+
34+
.code
35+
36+
; dummy
37+
IFNDEF WIN64
38+
.safeseh SEH_handler
39+
SEH_handler proc
40+
ret
41+
SEH_handler endp
42+
ENDIF
43+
44+
IFDEF WIN64
45+
Q_VMftol PROC
46+
movss xmm0, dword ptr [rdi + rbx * 4]
47+
cvttss2si eax, xmm0
48+
ret
49+
Q_VMftol ENDP
50+
51+
qvmcall64 PROC
52+
push rsi ; push non-volatile registers to stack
53+
push rdi
54+
push rbx
55+
push rcx ; need to save pointer in rcx so we can write back the programData value to caller
56+
57+
; registers r8 and r9 have correct value already thanx to __fastcall
58+
xor rbx, rbx ; opStackOfs starts out being 0
59+
mov rdi, rdx ; opStack
60+
mov esi, dword ptr [rcx] ; programStack
61+
62+
call qword ptr [r8] ; instructionPointers[0] is also the entry point
63+
64+
pop rcx
65+
66+
mov dword ptr [rcx], esi ; write back the programStack value
67+
mov al, bl ; return opStack offset
68+
69+
pop rbx
70+
pop rdi
71+
pop rsi
72+
73+
ret
74+
qvmcall64 ENDP
75+
ELSE
76+
Q_VMftol PROC
77+
movss xmm0, dword ptr [edi + ebx * 4]
78+
cvttss2si eax, xmm0
79+
ret
80+
Q_VMftol ENDP
81+
ENDIF
82+
83+
end

0 commit comments

Comments
 (0)