我认为最简单的方法是使用FPU指令fsqrt
:
.data?
int64 dq ?
squareRoot dd ?
.code
fild int64 ;load the integer to ST(0)
fsqrt ;compute square root and store to ST(0)
fistp squareRoot ;store the result in memory (as a 32-bit integer) and pop ST(0)
Run Code Online (Sandbox Code Playgroud)