Skip to content

Commit 4bbf0c0

Browse files
authored
[CORE] Remove naked function declaration for WWMath::Inv_Sqrt (#1009)
1 parent 2856a23 commit 4bbf0c0

File tree

1 file changed

+10
-5
lines changed
  • Core/Libraries/Source/WWVegas/WWMath

1 file changed

+10
-5
lines changed

Core/Libraries/Source/WWVegas/WWMath/wwmath.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,21 +602,23 @@ WWINLINE int WWMath::Float_To_Int_Floor (const float& f)
602602
// ----------------------------------------------------------------------------
603603

604604
#if defined(_MSC_VER) && defined(_M_IX86)
605-
WWINLINE __declspec(naked) float __fastcall WWMath::Inv_Sqrt(float a)
605+
WWINLINE float __fastcall WWMath::Inv_Sqrt(float a)
606606
{
607+
float retval;
608+
607609
__asm {
608610
mov eax, 0be6eb508h
609611
mov DWORD PTR [esp-12],03fc00000h ; 1.5 on the stack
610-
sub eax, DWORD PTR [esp+4]; a
611-
sub DWORD PTR [esp+4], 800000h ; a/2 a=Y0
612+
sub eax, DWORD PTR [a]; a
613+
sub DWORD PTR [a], 800000h ; a/2 a=Y0
612614
shr eax, 1 ; firs approx in eax=R0
613615
mov DWORD PTR [esp-8], eax
614616

615617
fld DWORD PTR [esp-8] ;r
616618
fmul st, st ;r*r
617619
fld DWORD PTR [esp-8] ;r
618620
fxch st(1)
619-
fmul DWORD PTR [esp+4];a ;r*r*y0
621+
fmul DWORD PTR [a];a ;r*r*y0
620622
fld DWORD PTR [esp-12];load 1.5
621623
fld st(0)
622624
fsub st,st(2) ;r1 = 1.5 - y1
@@ -644,8 +646,11 @@ WWINLINE __declspec(naked) float __fastcall WWMath::Inv_Sqrt(float a)
644646
;x3 = st(1)
645647
;r3 = st(0)
646648
fmulp st(1), st
647-
ret 4
649+
650+
fstp retval
648651
}
652+
653+
return retval;
649654
}
650655
#else
651656
WWINLINE float WWMath::Inv_Sqrt(float val)

0 commit comments

Comments
 (0)