The MASM Forum

General => The Campus => Topic started by: RuiLoureiro on July 03, 2014, 09:24:47 PM

Title: problems using SSE instructions
Post by: RuiLoureiro on July 03, 2014, 09:24:47 PM
Hi

I tried this little test

;include \masm32\include\masm32rt.inc

.686P
.xmm
.mmx
      .model flat, stdcall                      ; 32 bit memory model
      option casemap :none                      ; case sensitive

;     include files
;     ~~~~~~~~~~~~~
      include \masm32\include\windows.inc       ; main windows include file
      include \masm32\include\masm32.inc        ; masm32 library include

    ; -------------------------
    ; Windows API include files
    ; -------------------------
      include \masm32\include\gdi32.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc
      include \masm32\include\Comctl32.inc
      include \masm32\include\comdlg32.inc
      include \masm32\include\shell32.inc
      include \masm32\include\oleaut32.inc
      include \masm32\include\ole32.inc
      include \masm32\include\msvcrt.inc

      include \masm32\include\dialogs.inc       ; macro file for dialogs
      include \masm32\macros\macros.asm         ; masm32 macro file

;     libraries
;     ~~~~~~~~~
      includelib \masm32\lib\masm32.lib         ; masm32 static library

    ; ------------------------------------------
    ; import libraries for Windows API functions
    ; ------------------------------------------
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      includelib \masm32\lib\Comctl32.lib
      includelib \masm32\lib\comdlg32.lib
      includelib \masm32\lib\shell32.lib
      includelib \masm32\lib\oleaut32.lib
      includelib \masm32\lib\ole32.lib


; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.data
value           db ?

                dd 16
stringA16       db "This string here",0
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.code
start:
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
                mov         esi, offset stringA16
                movups      xmm0, [esi]             ; <<<--- line 58
;--------------------------------------------------------------------------
                inkey " ********** END I ********** "
                exit
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


but i got this error.
How to solve it ?
Quote
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: C:\...\SSEtest.asm
C:\...\SSEtest.asm(58) : error A2085: instruction or register not accepted in current CPU mode
_
Assembly Error
Prima qualquer tecla para continuar . . .
Title: Re: problems using SSE instructions
Post by: peter_asm on July 03, 2014, 09:32:25 PM
take out the .mmx directive
Title: Re: problems using SSE instructions
Post by: RuiLoureiro on July 03, 2014, 09:48:15 PM
Quote from: peter_asm on July 03, 2014, 09:32:25 PM
take out the .mmx directive
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: C:\...\SSEtest.asm
C:\...\SSEtest.asm(58) : error A2006: undefined symbol : xmm0   <<<------
_
Assembly Error
Prima qualquer tecla para continuar . . .
Title: Re: problems using SSE instructions
Post by: jj2007 on July 03, 2014, 10:29:01 PM
For ML 6.14 ... 10.0
Only JWasm needs the bold .686

include \masm32\include\masm32rt.inc
.686
.xmm

.code

start:   MsgBox 0, "Hello World", "Hi", MB_OK
   exit
   movups      xmm0, [esi]
end start
Title: Re: problems using SSE instructions
Post by: dedndave on July 04, 2014, 12:57:33 AM
i thought the .MMX had to go before the .XMM
Title: Re: problems using SSE instructions
Post by: RuiLoureiro on July 04, 2014, 01:00:39 AM
Quote from: dedndave on July 04, 2014, 12:57:33 AM
i thought the .MMX had to go before the .XMM
even with

           .686
           .mmx
           .xmm

i got undefined symbol :xmm0.

Has this something to do with Microsoft (R) Macro Assembler Version 6.14.8444 ?
Title: Re: problems using SSE instructions
Post by: dedndave on July 04, 2014, 01:02:01 AM
ohhhhhhhhhh
you are using masm version 6.14   :P
Title: Re: problems using SSE instructions
Post by: RuiLoureiro on July 04, 2014, 01:04:11 AM
Quote from: dedndave on July 04, 2014, 01:02:01 AM
ohhhhhhhhhh
you are using masm version 6.14   :P
Where to get the new one, Dave ?
Title: Re: problems using SSE instructions
Post by: dedndave on July 04, 2014, 01:14:32 AM
you can find 6.15 easily

http://win32assembly.programminghorizon.com/download.html (http://win32assembly.programminghorizon.com/download.html)

or you can d/l one of the visual studio express editions and extract the binaries
sent you a PM, Rui   :t
Title: Re: problems using SSE instructions
Post by: RuiLoureiro on July 04, 2014, 01:15:51 AM
Ok, Dave, thank you so much  :t
Title: Re: problems using SSE instructions
Post by: jj2007 on July 04, 2014, 01:40:23 AM
Quote from: jj2007 on July 03, 2014, 10:29:01 PM
For ML 6.14 ... 10.0

Do you occasionally read my posts?
Title: Re: problems using SSE instructions
Post by: RuiLoureiro on July 04, 2014, 02:15:06 AM
Quote from: jj2007 on July 04, 2014, 01:40:23 AM
Quote from: jj2007 on July 03, 2014, 10:29:01 PM
For ML 6.14 ... 10.0

Do you occasionally read my posts?
occasionally, Jochen !
                The problem here is with ML 6.14 like Dave said before
               and i will try to solve it.
Title: Re: problems using SSE instructions
Post by: Gunther on July 04, 2014, 04:15:07 AM
Hi Rui,

Quote from: RuiLoureiro on July 04, 2014, 02:15:06 AM
                The problem here is with ML 6.14 like Dave said before
               and i will try to solve it.

I had the same problem. Version 6.14.8444 comes with the current MASM32 package. That's the tricky thing.

Gunther
Title: Re: problems using SSE instructions
Post by: jj2007 on July 04, 2014, 08:28:36 AM
Quote from: RuiLoureiro on July 04, 2014, 02:15:06 AM
                The problem here is with ML 6.14 like Dave said before
               and i will try to solve it.

There is no problem with 6.14, it will assemble your code
- either if you follow my scheme above (masm32rt.inc)
- or, if you insist to list the includes explicitly:

.686P
.model flat, stdcall                      ; 32 bit memory model
option casemap :none                      ; case sensitive
.xmm

The exact order is important. And don't forget the msvcrt.lib, which is of course included in the standard masm32rt.inc solution.
Title: Re: problems using SSE instructions
Post by: RuiLoureiro on July 04, 2014, 08:01:51 PM
Hi Jochen,
                It seems i am doing what you say correctly.
                The problem is this:
                I am not able to assemble this instruction
               movups      xmm1, [esi+edx*8]                              
               I GET: instruction or register not accepted in current CPU mode.
                I dont know why.
:icon14:
Title: Re: problems using SSE instructions
Post by: jj2007 on July 04, 2014, 08:40:16 PM
Hi Rui,

Perhaps you could construct a little test piece with the order as shown above, and post the full code here?
Title: Re: problems using SSE instructions
Post by: MichaelW on July 04, 2014, 09:32:50 PM
With ML 6.15 even this will work:

;==============================================================================
include \masm32\include\masm32rt.inc
.xmm
;==============================================================================
.data
    junk db 16 dup(0)
.code
;==============================================================================
start:
;==============================================================================
    lea esi, junk
    xor edx, edx
    movups xmm1, [esi+edx*8]
    inkey
    exit
;==============================================================================
end start

Title: Re: problems using SSE instructions
Post by: Gunther on July 05, 2014, 01:36:43 AM
Hi Rui,

Quote from: RuiLoureiro on July 04, 2014, 08:01:51 PM
                The problem is this:
                I am not able to assemble this instruction
               movups      xmm1, [esi+edx*8]                              
               I GET: instruction or register not accepted in current CPU mode.
                I dont know why.
:icon14:

That won't work. Please check Daves links in the other thread.

Gunther
Title: Re: problems using SSE instructions
Post by: RuiLoureiro on July 05, 2014, 02:14:43 AM
I find out the problem   

The file where i have the macros
START_COUNTER_CYCLE_HIGH_PRIORITY_CLASS
(written by MichaelW) and some data
and some procedures etc.
starts with .686 (i don't know why i put it there!).

So i have

   include \masm32\include\masm32rt.inc
   .xmm
   include macros.mac (starts with .686)

The result is what we know !
Now, my junk works fine (it seems).

Thank you Jochen
thank you also MichaelW
:icon14:
Title: Re: problems using SSE instructions
Post by: RuiLoureiro on July 08, 2014, 05:29:16 AM
Hi MichaelW,
                    Now i know why i put .686 in that file.
                    If i use
                     START_COUNTER_CYCLE_HIGH_PRIORITY_CLASS
                     i am not able to assemble it.
                     If i use .686 it assembles.