News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

DirectX and GoASM in 64bit

Started by Anunak, December 30, 2011, 10:28:38 AM

Previous topic - Next topic

Anunak

I'm actually new to GoAsm and Iike using ist. Until now I've used MASM32 package for 32bit. But I'm experimenting now 64bit. And this stack alignment and data alignment is getting me a little bit crazy. I try to do some calls to DX9 and it works, it means it doesn't crash. It took me a while to comprehend that parameter passing for floating points is different that stated in mostly all papers. Floating points are passed to the xmm registers! and not rcx, rdx,r8,r9! So it took me about 2 weeks to find that out. Sorry that I've posted it wrong in bug and request section.

See for more details http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx

So, when I'm trying to call DX-functions I can't use ARG+INVOKE.

For one call in my test program it works -> it means i can see that the parameters are passed correctly by changing them!
For my second call it doesn't work, because changing parameters doesn't do anything, also when the call is not done it's the same.

I think I'm doing something wrong with stack alignment and so on. But the mentioned method with push rsp, push [rsp], etc.. I can't get it to work, because it always crashes, so I use following code, which does no alignment:

        sub rsp,48
        lea rcx,[matProj]
        movss xmm1, [PI2]
        movss xmm2,[Aspect]
        movss xmm3,[zn]
        movss xmm4,[zf]
        movss [rsp+32],xmm4
         call D3DXMatrixPerspectiveFovLH
         add rsp,48


   ARG ADDR matProj
   ARG D3DTS_PROJECTION
   DXInvoke (D3DD9,SetTransform) -> DXInvoke is just a macro I#ve defined for com-calling

This call works

But the second seems to do nothing

   lea rcx,[matTrans]
        movss xmm1,[transx]
        movss xmm2,[transy]
        movss xmm3,[transz]
        sub rsp,20h
        call D3DXMatrixTranslation
        add rsp,20h

   ARG ADDR matTrans
   ARG D3DTS_WORLD
   DXInvoke (D3DD9,SetTransform)   

The variables are defined with dd (floating points are passed )

So is it possible to implement that floating points are passed to the xmm registers or could anybody help me with doing the calls correctly as described:

Thanx in advance

Anunak

 :bg

Actually I found the problem. The code works. Something with the Headerfile conversion went wrong. D3DTS_WORLD has been wrong converted to 0, but it must be 256. With it the code does, what it should do. Anyway it would be cool, if INVOKE would support floating point parameters to xmm registers.

Happy programming.