News:

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

SSE

Started by bomz, December 08, 2011, 07:13:49 AM

Previous topic - Next topic

bomz

#30
Quote.386
.MMX
.XMM

.model flat, stdcall
option casemap :none

   include \MASM32\INCLUDE\windows.inc
   include \MASM32\INCLUDE\masm32.inc
   include \MASM32\INCLUDE\gdi32.inc
   include \MASM32\INCLUDE\user32.inc
   include \MASM32\INCLUDE\kernel32.inc
   include \MASM32\INCLUDE\fpu.inc
   includelib \MASM32\LIB\masm32.lib
   includelib \MASM32\LIB\gdi32.lib
   includelib \MASM32\LIB\user32.lib
   includelib \MASM32\LIB\kernel32.lib
   includelib \MASM32\LIB\fpu.lib

.data
   VAR1         REAL4 0.0, 0.0, 0.0, 0.0
   VAR2         REAL4 1.0, 1.0, 1.0, 1.0
   VAR3         REAL4 1.0, 1.0, 1.0, 1.0
   VAR4         REAL4 1.0, 1.0, 1.0, 1.0
   mestitle      db "SSE",0
   shell32         db 'shell32.dll',0
   MessBox         MSGBOXPARAMS <sizeof MSGBOXPARAMS, 0, 0, offset buffer,\
            offset mestitle, MB_OK OR MB_USERICON, 48, 0, 0, 0>
.data?
   buffer         db 512 dup(?)
   string         db 32  dup(?)

.code
start:
   lea   esi, VAR2
   lea   edi, VAR1
   movdqa   XMM0, [esi]
   movdqa   XMM1, [esi+16]
   ADDPS   XMM0, XMM1
   movdqa   [edi], XMM0
   finit
   fld   dword ptr[VAR1]
   invoke   FpuFLtoA, 0, 1110h, ADDR string, SRC1_FPU or SRC2_DIMM
   invoke   lstrcpy, addr buffer, addr string
   fld   dword ptr[VAR1+4]
   invoke   FpuFLtoA, 0, 1110h, ADDR string, SRC1_FPU or SRC2_DIMM
   invoke   lstrcat, addr buffer, addr string
   fld   dword ptr[VAR1+8]
   invoke   FpuFLtoA, 0, 1110h, ADDR string, SRC1_FPU or SRC2_DIMM
   invoke   lstrcat, addr buffer, addr string
   fld   dword ptr[VAR1+12]
   invoke   FpuFLtoA, 0, 1110h, ADDR string, SRC1_FPU or SRC2_DIMM
   invoke   lstrcat, addr buffer, addr string

   invoke   LoadLibrary, addr shell32
   mov   MessBox.hInstance, eax
   invoke   MessageBeep, MB_ICONASTERISK
   invoke   MessageBoxIndirect, addr MessBox
   invoke   ExitProcess,0
end start
Quote.386
.MMX
.XMM

.model flat, stdcall
option casemap :none

include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\user32.inc
include \MASM32\INCLUDE\kernel32.inc
includelib \MASM32\LIB\user32.lib
includelib \MASM32\LIB\kernel32.lib
include \MASM32\INCLUDE\masm32.inc
includelib \MASM32\LIB\masm32.lib

.data
var1      real4 4.1f, 1.0f, 1.0f, 1.0f
var3      real4 1.0f, 1.0f, 1.0f, 1.0f
var2      INT64 0
mestitle   db "Bomz",0
form      db "0.%ldx10^%ld", 0
shell32      db 'shell32.dll',0
MessBox      MSGBOXPARAMS <sizeof MSGBOXPARAMS, 0, 0,\
      offset buffer, 0, MB_OK OR MB_USERICON, 48, 0, 0, 0>

.data?
buffer db 512 dup(?)

.code
start:
   invoke   LoadLibrary, addr shell32
   mov   MessBox.hInstance, eax

   lea   esi, var1
   lea   edi, var3

   movdqa   XMM0, [esi]
   movdqa   XMM1, [edi]
   ADDPS   XMM1, XMM0
   movdqa   [edi], XMM1
   finit
   fld   dword ptr[var3]
   fstp   var2
   invoke  FloatToStr2,var2,addr buffer
   invoke MessageBeep, MB_ICONASTERISK
   invoke   MessageBoxIndirect, addr MessBox
   invoke   ExitProcess,0
end start

jj2007

You got it! Here is the MB equivalent:

include \masm32\MasmBasic\MasmBasic.inc
.data
VAR1   REAL4 0.0, 0.0, 0.0, 0.0
VAR2   REAL4 1.0, 1.0, 1.0, 1.0
VAR3   REAL4 1.0, 1.0, 1.0, 1.0

   Init
   lea   esi, VAR2
   lea   edi, VAR1
   movdqa XMM0, [esi]
   movdqa XMM1, [esi+16]
   ADDPS XMM0, XMM1
   movdqa [edi], XMM0
   fld REAL4 PTR VAR1
   fld REAL4 PTR VAR1+4
   fld REAL4 PTR VAR1+8
   fld REAL4 PTR VAR1+12
   deb 1, "Result:", ST(0), ST(1), ST(2), ST(3)
   Exit
end start

bomz

I Turbo Basic know well. But now new language... But I like your examples.
I find Quick Sort in MASM32 help.

http://turbo-basic.narod.ru/index.html 
http://turbo-basic.narod.ru/TBDEMO-256-H101.rar

I find two errors in Turbo compiler - first it don't back right offset to symbols strings. But for assembler possible use numeric array with the same success. This was corrected only in Quick Basic
Second - it's not error but undocumented, 64 kb string may be cut from left, but cut from right you may only 32 kb string

jj2007

Porting your example should be very easy, see attachment.

bomz

It is possible to compile it with MASM?

DownLoadMaster have problem - and this prog I do cut file from the end to the first nonzero byte.

jj2007

Quote from: bomz on December 11, 2011, 10:34:48 PM
It is possible to compile it with MASM?

Sure, that's the whole point: MasmBasic is a library for ML.exe or JWasm.exe, and it works in parallel to the Masm32 installation, i.e. you can use both the Masm32 macros and library functions and the whole BASIC stuff.

bomz

INT64 SSE2 http://www.tommesani.com/SSE2MMX.html
Quote.386
.MMX
.XMM

.model flat, stdcall
option casemap :none

include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\user32.inc
include \MASM32\INCLUDE\kernel32.inc
includelib \MASM32\LIB\user32.lib
includelib \MASM32\LIB\kernel32.lib

.data
;   VAR1      dd   0,   1,   0,   0
;   VAR2      dd   1,   0,   0,   0
   VAR1      INT64   4294967295,   0
   VAR2      INT64   1,      0
.data?
   String      db 20 dup(?)
   RESULT      dt ?

.code
start:
   movdqa   XMM0, XMMWORD PTR[VAR1]
   movdqa   XMM1, XMMWORD PTR[VAR2]
   PADDQ   XMM1, XMM0
   movdqa   XMMWORD PTR[VAR2], XMM1

   finit
   fild qword ptr[VAR2]
   fbstp RESULT
   lea esi,String
   add esi, 18
   lea edi,RESULT
   xor edx, edx
   xor ebx, ebx
   mov ecx, 9
@@:
   dec esi
   dec esi
   mov bl, byte ptr [edi]
   shl ebx,4
   add bh, 48
   mov dl, bh
   xor bh, bh
   shr ebx, 4
   add bl, 48
   mov dh, bl
   mov word ptr [esi], dx
   inc edi
   loop @B
   invoke MessageBox,0,addr String,0,MB_ICONASTERISK
   invoke ExitProcess,0
end start

bomz

Quote.686
.xmm
CSEG segment use16
assume cs:CSEG, ds:CSEG, es:CSEG, ss:CSEG

   movaps  xmm0,xmmword ptr es:[esi]

programe hang than try to execute SSE command. it is impossible to use USE16 32bit address and SSE?

bomz

sory - it's Microsoft Virtual Machine SSE problem

*as always when try to formulate problem to another people good idea come