質問

I need to write function that should use SSE2 to convert radians to degrees. This is for assignment. I have no idea how to do it.

_180_PI is number equal to 180/3.141592... My function needs to just return return rad * _180_PI

This function is in dll and this is how its declaration:

__declspec(dllexport) double __stdcall RadToDegAsm(double rad);

I have:

.DATA
    _180_PI dq 57.2957795130823208767981548141

.CODE

RadToDegAsm PROC rad: QWORD
    movupd xmm0, rad
    mulsd xmm0, _180_PI
    ;I need to somehow return it
RadToDegAsm ENDP

Main question: How to return 64bit(double) contents of xmm0 register so that it works with given declaration?

役に立ちましたか?

解決

Got it working:

.DATA
    _180_PI dq 57.2957795130823208767981548141
.CODE

RadToDegAsm PROC rad: QWORD
    LOCAL returnValue: QWORD
    movsd xmm0, rad
    mulsd xmm0, _180_PI
    movsd returnValue, xmm0
    fld return
    ret
RadToDegAsm ENDP

double value is returned via floating point registers (fld) instruction.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top