News:

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

Problem with MASM32 and SSE

Started by Dj Ninja, December 22, 2008, 11:18:49 AM

Previous topic - Next topic

Dj Ninja

hi there!

i got a nasty problem trying to use the MOVAPS instruction from the SSE instruction set. don't know i'm doing wrong with it.
even the (not so) simple chunk of code MOVAPS %XMM0, %XMM1 is awarded with a nice "error A2009: syntax error in expression" by the MASM32.
i tried using various mutations of the parameters, resulting in other errors and i didn't found anything on the internet.

would be great if someone can post a short sampe of code which i can assemble using MASM32 and hopefully find out what causes this error.

thanks!

BogdanOntanu

Where from did you get the ideea to use %XMM1, %XMM2?
More exactly why using the "%" symbol in front of a register name?
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Dj Ninja

found it on the internet like that.  :red

removing these "%" will result in "error A2006: undefined symbol : xmm0"  :eek

maybe i forgot to include something... i really don't know.

hutch--

Try adding at the begining,


.XMM


Make sure its after .486 or later directive but the .XMM enables XMM instructions. Note that ML 6.14 does not do the SSE2/3 instructions.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Dj Ninja

thank you... i tried this in various combinations (also found on the internet in various combinations):

.686 (or .686p)
.mmx
.xmm
(.model flat, stdcall)

works in that way that MASM32 "tries" to assemble the MOVAPS command but for some reason fails (see posting #1).
MOVAPS is a SSE(1) command MASM32 6.14 should know.

nobody there who has running MASM32 source code using SSE and could snip an example out of it?

MichaelW

One detail on this that has come up repeatedly is the relative placement of the .MMX or .XMM directives and the option casemap :none directive. If you use this, more natural IMO, ordering:

.686
.MMX
.XMM
.model flat, stdcall
option casemap :none


Then any attempt to use anthing other than all upper-case register names, 'mm0' or 'xmm0' for example, will result in an:

error A2006: undefined symbol

If instead you use this ordering:

.686
.model flat, stdcall
option casemap :none
.MMX
.XMM


Then you can use either case, or even mixed case, for the register names. I have tested ML 6.14, 6.15, and 7.00, and they all behave this way.

eschew obfuscation

dancho

movaps - is for fast copy of 4 aligned floating-point data,
are you sure your data is aligned ?

this have to work...

include masm32rt.inc
.mmx
.xmm

.data
align 16
vector struct
x real4 ?
y real4 ?
z real4 ?
w real4 ?
vector ends
v1 vector <1.0,1.0,1.0,1.0>
v2 vector <2.0,2.0,2.0,2.0>
v3 vector <>

.code
start:

movaps xmm0,v1
addps xmm0,v2
movaps v3,xmm0
exit

end start

Dj Ninja

MOVAPS should fill the 128 bits of a SSE register at once (from aligned memory) quite nicely. i want to use SSE register(s) to improve speed on a really large bit-shift function.

can you explain what the file MASM32RT.INC is exactly needed for (is it essential when using SSE instructions?)? is it a replace for the WINDOWS.INC file?
f i include it i'm getting a lot of errors, such as double definitions. can both files be included at once?

thanks!

dancho

You will find masm32rt.inc in include folder of your masm32 installation,
just open it with notepad and read comment lines...

japheth

Quote from: Dj Ninja on December 22, 2008, 02:30:34 PM
thank you... i tried this in various combinations (also found on the internet in various combinations):

.686 (or .686p)
.mmx
.xmm
(.model flat, stdcall)

works in that way that MASM32 "tries" to assemble the MOVAPS command but for some reason fails (see posting #1).
MOVAPS is a SSE(1) command MASM32 6.14 should know.

nobody there who has running MASM32 source code using SSE and could snip an example out of it?

The cause of the problems reveals if you make Masm v6 and v7 create a symbol listing with -Fl. The access to the sse registers is implemented in these versions as XMM(n) - with 0 <= n <= 7. In other words, just 'XMM' is a reserved word in Masm v6 and 7. To also allow accessing the  registers without an index Masm defines various symbols: XMM0 ... XMM7 are created always; OTOH, xmm0 ... xmm7, Xmm0 ... Xmm7 and xMM0 ... xMM7  are created only if CASEMAP:NONE is active when the .XMM directive has been found.

With Masm v8, MS changed this mess and defined all SSE registers as reserved names. The old access method, which needed an index register - XMM(n) - was removed.



Dj Ninja

okay thanks a lot.

i'll try again today with the directives as ordered as shown above. i don't need chunks of the SSE registers (for now), i need the entire register (because it is 128 bits wide) in order to work with really large integer numbers (up to 2^128).

last question: is there a need for using the MASM32RT.INC when accessing SSE registers or can i go on with the WINDOWS.INC file alone?

japheth

Quote from: Dj Ninja on December 23, 2008, 10:04:33 AM
last question: is there a need for using the MASM32RT.INC when accessing SSE registers or can i go on with the WINDOWS.INC file alone?

No. Since SSE is a cpu feature, you need neither MASM32RT.INC nor WINDOWS.INC. This MASM32RT.INC thing is useful if you want to obfuscate your code by using lots of macros. Most people won't recognize it as assembly code anymore and believe it to be a PowerBasic program...


hutch--

Ninja,

For any instruction in any Windows OS version after win95 you can use any of the non-priveleged instructions including the SSE range. They are processor opcodes and do not depend on include files or macros. If you are using a version of ML that does not support some of the later instructions like SSE2/3 I have seen macros that do them instead, this is a normal feature of MASM with its preprocessor.

Japheth,

Love it or hate it, basic dialects have been around since the early 80s, MASM and compatibles emulate basic just as well as C if you bother to write the macros.

> Most people won't recognize it as assembly code anymore and believe it to be a PowerBasic program...

Most people would not recognise if any program was written in assembler.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

Quote from: japheth on December 23, 2008, 11:53:15 AM
...Most people won't recognize [include masm32rt.inc] as assembly code anymore and believe it to be a PowerBasic program...

That is quite funny. Of course, this include file is really only a shortcut to typing out much longer code. Of course, there is nothing from preventing anyone from writing all of it out (or any part of it) manually... but since this is common to the vast majority of code, why write any of it, if a simple


    include \masm32\include\masm32.inc


does the same thing? Alas, I agree that it is rather obfuscatory. However, once understood, it also simplifies things and makes the code shorter. But it certainly does not make the rest of the code look like PowerBasic, and nowhere is it stipulated that anyone MUST use masm32rt.inc or any of the functions of macros provided by MASM32.LIB and MACROS.ASM (by all means, if you like typing, or want "complete control" then feel free to do anything you want manually...)

Likewise, if one does not believe in this ideology, then they may code in binary if that is what is desired. :bdg For that matter, this might be a better tool for "pure" code creation.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Dj Ninja

of course SSE instructions are processor features and part of their opcodes. i simply wasn't shure - the include file could probably contain some definitions or constants which could be needed by masm32 to generate the SSE opcodes. if not - good, no room for errors! :)