;
; math.asm
; x86 assembly-language math routines.
; this file uses NASM syntax.
;
; 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.
; 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
;

%include "asm_nasm.inc"

; underscore prefix handling
; for C-shared symbols:
%ifmacro _sym_prefix
; C-shared externs:
 _sym_prefix vright
 _sym_prefix vup
 _sym_prefix vpn
; C-shared globals:
 _sym_prefix TransformVector
%endif	;_sym_prefix

; externs from C code
 extern vright
 extern vup
 extern vpn

; externs from ASM-only code


SEGMENT .text

 ALIGN 2

 global TransformVector
TransformVector:
 mov eax, dword [4+esp]
 mov edx, dword [8+esp]
 fld  dword [eax]
 fmul  dword [vright]
 fld  dword [eax]
 fmul  dword [vup]
 fld  dword [eax]
 fmul  dword [vpn]
 fld  dword [4+eax]
 fmul  dword [vright+4]
 fld  dword [4+eax]
 fmul  dword [vup+4]
 fld  dword [4+eax]
 fmul  dword [vpn+4]
 fxch st2
 faddp st5,st0
 faddp st3,st0
 faddp st1,st0
 fld  dword [8+eax]
 fmul  dword [vright+8]
 fld  dword [8+eax]
 fmul  dword [vup+8]
 fld  dword [8+eax]
 fmul  dword [vpn+8]
 fxch st2
 faddp st5,st0
 faddp st3,st0
 faddp st1,st0
 fstp  dword [8+edx]
 fstp  dword [4+edx]
 fstp  dword [edx]
 ret
