How can i Inline assembly use in 64bit?

  32bit-64bit, assembly, c++, inline-assembly, visual-studio

I was try to 32bit game client to 64bit but i can’t compile, because client have inline asm code, 64bit don’t support __asm inline. So i can’t find a solution for this. I hope i can getting in this community.

define inline code:

#define PR_FLOAT_TO_INTASM __asm    
{                                   
    __asm fld PR_FCNV               
    __asm fistp PR_ICNV             
}
#define PR_FLOAT_TO_INT(inreal, outint)                         
{                                                               
    PR_FCNV = (inreal);                                         
    PR_FLOAT_TO_INTASM;                                         
    (outint) = PR_ICNV > PR_FCNV ? PR_ICNV - 1 : PR_ICNV;       
}

Example code using:

float CMapOutdoor::GetTerrainHeight(float fx, float fy)
{
    if (fy < 0)
        fy = -fy;
    long lx, ly;
    PR_FLOAT_TO_INT(fx, lx);
    PR_FLOAT_TO_INT(fy, ly);

    WORD usCoordX, usCoordY;

    usCoordX = (WORD)(lx / CTerrainImpl::TERRAIN_XSIZE);
    usCoordY = (WORD)(ly / CTerrainImpl::TERRAIN_YSIZE);

    BYTE byTerrainNum;
    if (!GetTerrainNumFromCoord(usCoordX, usCoordY, &byTerrainNum))
        return 0.0f;

    CTerrain* pTerrain;

    if (!GetTerrainPointer(byTerrainNum, &pTerrain))
        return 0.0f;

    return pTerrain->GetHeight(lx, ly);
}

Error code:

error C2146: syntax error : missing ';' before identifier 'PR_ICNV'
error C2146: syntax error : missing ';' before identifier 'fistp'
error C2146: syntax error : missing ';' before identifier '}'

Source: Windows Questions C++

LEAVE A COMMENT