我注意到,使用我的内联汇编代码要么非常慢,要么停止与我的C++代码相比很快完成.当我在一个不同的函数中调用内联汇编程序而不是让函数被调用的汇编程序时,我很好奇为什么会发生这种情况.我测试了两种方法,发现我的程序在省略该功能时没有冻结.
__asm {
push dword ptr[rw] //rw is a C++ floating-point variable
fld[esp] // Using the stack as temporary storage in order to insert it into the FPU
add esp, 4 //preserving the memory
push dword ptr[lwB]
fld[esp]
add esp, 4
fsubp ST(1), ST(0) // Subtracting rw - lwB
push dword ptr[sp]
fld[esp]
add esp, 4
fdivp ST(1), ST(0) // Dividing previous resultant by span -> (rw - lwB) / sp
push dword ptr[dimen]
fld[esp]
add esp, 4
fmulp ST(1), …Run Code Online (Sandbox Code Playgroud)