使用SSE将浮点值从汇编程序DLL返回到C ++

时间:2016-12-04 11:17:37

标签: c++ assembly sse masm masm32

我有一个问题,从DLL汇编程序返回一个浮点值到C ++程序。我想它应该在xmm0寄存器中处理,我错了吗?这是主文件:

#include "stdafx.h"
#include<windows.h>
#include<iostream>
#include <cstdio>
#include <thread>
#include <vector>
using namespace std;

extern "C" float _stdcall MyProc1(float begin, float end, float x2 ,float x1, float x0);    //dll assembler

int main(int argc, _TCHAR* argv[])
{
    float suma=0;
    suma = MyProc1(12.75,9.3,0,0,1);
    cout << std::hex<< suma << endl;
    getchar();
    return 0;
}

这是我的汇编程序DLL:

.686p
.MODEL FLAT, STDCALL
OPTION CASEMAP:NONE
INCLUDE C:\masm32\include\windows.inc
.mmx
.xmm

.DATA
    pi dd 3.14159265358979 ; constant

.CODE

DllEntry PROC hInstDLL:HINSTANCE, reason:DWORD, reserved1:DWORD
    mov eax, TRUE 
    ret 
DllEntry ENDP


MyProc1 proc b:DWORD, e:DWORD, x2: DWORD, x1: DWORD, x0:DWORD 

    movss xmm0,[b]  
    ret

MyProc1 endp    

END DllEntry 

,返回值为-1。#IND,为什么?

0 个答案:

没有答案