News:

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

How to use XMMWORD type correctly?

Started by MazeGen, August 16, 2006, 06:31:42 PM

Previous topic - Next topic

MazeGen

I'm learning how to use it, but I get stuck on very basic things.

For instance, if I try to assemble the following code:


.686
.XMM
.MODEL FLAT, STDCALL

.LISTALL

.DATA?
xmmwrd XMMWORD ?

.CODE
xmmwrdproc PROC arg1:XMMWORD
ret
xmmwrdproc ENDP

Start:
invoke xmmwrdproc, [xmmwrd]

invoke xmmwrdproc, xmm0

invoke xmmwrdproc, eax

invoke xmmwrdproc, 100h

END Start


I get errors on each INVOKE:


.686
.XMM
.MODEL FLAT, STDCALL

.LISTALL

00000000 .DATA?
00000000 xmmwrd XMMWORD ?
   00000000000000000000000000000000

00000000 .CODE
00000000 xmmwrdproc PROC arg1:XMMWORD
00000000  55    *     push   ebp
00000001  8B EC    *     mov    ebp, esp
ret
00000003  C9    *     leave 
00000004  C2 0010    *     ret    00010h
00000007 xmmwrdproc ENDP

00000007 Start:
invoke xmmwrdproc, [xmmwrd]
xmmword.asm(17) : error A2114: INVOKE argument type mismatch : argument : 1
00000007  E8 FFFFFFF4    *     call   xmmwrdproc

invoke xmmwrdproc, xmm0
xmmword.asm(19) : error A2033: invalid INVOKE argument : 1
xmmword.asm(19) : error A2114: INVOKE argument type mismatch : argument : 1
0000000C  E8 FFFFFFEF    *     call   xmmwrdproc

invoke xmmwrdproc, eax
xmmword.asm(21) : error A2114: INVOKE argument type mismatch : argument : 1
00000011  E8 FFFFFFEA    *     call   xmmwrdproc

invoke xmmwrdproc, 100h
xmmword.asm(23) : error A2114: INVOKE argument type mismatch : argument : 1
00000016  E8 FFFFFFE5    *     call   xmmwrdproc

END Start


I really have no clue how to get it working :(
The only thing I can see from the listing is that XMMWORD parameter really occupies 16 bytes on the stack (ret 00010h).

(I use ML 8.00.50727.42 from VS2005)

asmfan

May be you should start thinking of using pointers instead? Or push'em all (DWORDs) with your own hands...
Russia is a weird place

MazeGen

Hi asmfan,

I know I can use pointers. I just want to know my tools. If MASM allows me to define an argument as XMMWORD, I'd like to know how can I pass something to this argument.

asmfan

Oh, those pseudo hi-level invokes... disaster. Masm has nothing to do with the real capabilities of a CPU. There's no opcode to push more than a DWORD at a time (in 32 bit mode of course:).
I think the easiest way is

sub  esp, 10h
movdqa  xmm0, xmmwrd
movdqu  [esp], xmm0
call  xmmwrdproc
Russia is a weird place

MazeGen

I know there is no such opcode, but INVOKE can usually handle these cases, for instance REAL10 as a parameter (compiles fine also with ML 6.14):

.686
.MODEL FLAT, STDCALL

.DATA?
real10var REAL10 ?

.CODE
real10proc PROC arg1:REAL10
real10proc ENDP

Start:
invoke real10proc, real10var
END Start

ToutEnMasm

Hello,
I use ml 8.0 and he don't know the XMMWORD typedef.
The SDK don't know it,where it is defined ?
                            ToutEnMasm

MazeGen

ToutEnMasm, do you use the latest version, 8.00.50727.42? IIRC the SDK still contains some older version. Mine comes from VS2005.

ToutEnMasm


I use the 8.00.50727.104 coming from http://www.microsoft.com/downloads/details.aspx?FamilyId=7A1C9DA0-0510-44A2-B042-7EF370530C64&displaylang=en

This free versions don't  seems to know the standard macros and typedefs include in the masm Help.
                               ToutEnMasm

MazeGen

ToutEnMasm, it is really weird. Since I use VS2005 professional, I can't help you.

MazeGen

I decided to report my original problem as a bug:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=181923

Please vote for it and validate it. It helps to accelerate the fixing process.

ToutEnMasm

#10
The answer is here
http://msdn2.microsoft.com/en-us/library/cw0399sf.aspx

using the include files of the SDK with declared typedef is the anwer (follow __m128 link)
                               ToutEnMasm

Note:The sample on the link works also with the free ml.

MazeGen

It doesn't work in my case neither:

Code:

.686
.XMM
.MODEL FLAT, STDCALL

.DATA?
testvar XMMWORD ?

.CODE
testproc PROC arg1:XMMWORD
ret
testproc ENDP

Start:
invoke testproc, xmmword ptr testvar
invoke testproc, xmmword ptr [testvar]
END Start


Listing:

                                .XMM
                                .MODEL FLAT, STDCALL

00000000                       .DATA?
00000000                       testvar XMMWORD ?
           00000000000000000000000000000000

00000000                       .CODE
00000000                       testproc PROC arg1:XMMWORD
                                 ret
00000007                       testproc ENDP

00000007                       Start:
                                 invoke testproc, xmmword ptr testvar
xmmword.asm(15) : error A2114: INVOKE argument type mismatch : argument : 1
                                 invoke testproc, xmmword ptr [testvar]
xmmword.asm(16) : error A2114: INVOKE argument type mismatch : argument : 1
                                END Start

drizz

MazeGen,
poasm can handle this! Pelle will actually listen to you (if you find bugs), what you cant say about masm support.
i strongly suggest you consider poasm...

all i know that masm works ok with qwords (but not immediate qwords)

.DATA?
q1 QWORD ?
.CODE
testproc PROC arg1:qword,arg2:qword,arg3:qword
ret
testproc ENDP
start:
invoke testproc, q1,edx::eax,ebx::ecx
The truth cannot be learned ... it can only be recognized.

MazeGen

Hi drizz,

in fact, I have started this topic because I code macros to support FASTCALL calling convention in ML64 and I need to know first how ML (32-bit) handles XMMWORD type.

As for PoAsm, I already code many macros, which I use in my projects, some of them quite complicated, and I don't believe they would work with PoAsm without modifications. I already stick to MASM so closely that I don't want to move to another (kind of incompatible) assembler. Beside this, I take some exceptions to PoAsm's development, but these are not the matter under discussion.

ToutEnMasm


Hello,
Searching for translating the size of the __m128  typedef size ,P1 provided me with this link
http://www.masm32.com/board/index.php?topic=4808.0
The posts give this another one.
http://www.intel.com/cd/ids/developer/asmo-na/eng/167741.htm?prn=Y

Perhaps it is not usefull with ml 8
                         ToutEnMasm.