The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
September 30, 2022, 12:41:24 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  Project Support Forums
| |-+  MASM32
| | |-+  XMMWORD initializers?
« previous next »
Pages: [1] Print
Author Topic: XMMWORD initializers?  (Read 13641 times)
redskull
Member
*****
Gender: Male
Posts: 837


It rubs the lotion on its skin...


XMMWORD initializers?
« on: January 13, 2011, 07:26:51 PM »

Does anyone know the appropriate syntax for getting MASM to accept initializing values for an XMMWORD?  It just seems to ignore any specified values you give it, and initializes everything to zero.

-r
Logged

Strange women, lying in ponds, distributing swords, is no basis for a system of government
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: XMMWORD initializers?
« Reply #1 on: January 13, 2011, 07:45:05 PM »

Works with Masm 8, 9 and JWasm:
Code:
include \masm32\include\masm32rt.inc
.xmm
.code
MyXmm OWORD 12345678
start:
movups xmm1, MyXmm
inkey "Done"
exit
end start
Logged

redskull
Member
*****
Gender: Male
Posts: 837


It rubs the lotion on its skin...


Re: XMMWORD initializers?
« Reply #2 on: January 13, 2011, 07:55:43 PM »

It can't accept four distinct floating point values?  E.G.

Code:
foo   XMMWORD  3.14, 2.73, 6.674, 1.234
Logged

Strange women, lying in ponds, distributing swords, is no basis for a system of government
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: XMMWORD initializers?
« Reply #3 on: January 13, 2011, 08:05:54 PM »

It's actually a lot more complicated...
Masm does not initialise the XMMWORD (but it does initialise the OWORD)
JWasm initialises both.

Code:
include \masm32\MasmBasic\MasmBasic.inc
.data
MyX XMMWORD 123456789.0123456789
MyO OWORD 1234567890123456789
foo XMMWORD 3.14, 2.73, 6.674, 1.234
fooR8 REAL8 3.14, 6.28

Init
movdqu xmm0, MyX
movups xmm1, MyO
movups xmm2, foo
movlps xmm3, fooR8
movlps xmm4, fooR8+8
Print Str$("MyX/x0\t%9f\n", xmm0)
Print Str$("Xmm1\t%9f\n", xmm1)
Print Str$("foo/x2\t%9f\n", xmm2)
Print Str$("Xmm3\t%9f\n", f:xmm3)
Inkey Str$("Xmm4\t%9f\n", f:xmm4)
Exit
end start

Output:
MyX/x0  0.0
Xmm1    1.23456789e+18
foo/x2  0.0
Xmm3    3.14000000
Xmm4    6.28000000
Logged

clive
Hardcore x86, ARM and MIPS toolsmith
Member
*****
Posts: 1230


Project Looking Glass. Following the white rabbit.


Re: XMMWORD initializers?
« Reply #4 on: January 13, 2011, 08:08:02 PM »

Guess you'd need to use

foo REAL4 3.14, 2.73, 6.674, 1.234

and override it.

So JJ how do you print a packed scalar in MasmBasic?
Logged

It could be a random act of randomness. Those happen a lot as well.
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: XMMWORD initializers?
« Reply #5 on: January 13, 2011, 08:21:02 PM »

So JJ how to you print a packed scalar in MasmBasic?

Good question. It's not yet foreseen, but if there is an urgent need for it...

Code:
fld fooR8
fld fooR8+8
Print Str$("Packed: %9f and ", ST(0)), Str$(ST(1)), CrLf$
fstp st
fstp st

Output:
Packed: 6.28000000 and 3.140000
Logged

redskull
Member
*****
Gender: Male
Posts: 837


It rubs the lotion on its skin...


Re: XMMWORD initializers?
« Reply #6 on: January 13, 2011, 08:29:20 PM »

Guess you'd need to use

foo REAL4 3.14, 2.73, 6.674, 1.234

and override it.


Is an XMMWORD the same byte ordering as four consequtive REAL4s?  I'm too rusty on the format to remember big vs little endian.

-r
Logged

Strange women, lying in ponds, distributing swords, is no basis for a system of government
dedndave
Member
*****
Posts: 12523


Re: XMMWORD initializers?
« Reply #7 on: January 13, 2011, 08:38:32 PM »

or...
Code:
foo     LABEL   OWORD
        REAL4 3.14, 2.73, 6.674, 1.234
Logged
clive
Hardcore x86, ARM and MIPS toolsmith
Member
*****
Posts: 1230


Project Looking Glass. Following the white rabbit.


Re: XMMWORD initializers?
« Reply #8 on: January 13, 2011, 08:42:07 PM »

Code:
        include \masm32\MasmBasic\MasmBasic.inc
        .data
foo     REAL4   3.14, 2.73, 6.674, 1.234
bar     REAL4   ?, ?, ?, ?
Init
        movups xmm2, foo

        movups bar, xmm2
        fld     bar[0]
        print Str$("Xmm2:0\t%9f\n", ST(0))
        fstp    st
        fld     bar[4]
        print Str$("Xmm2:1\t%9f\n", ST(0))
        fstp    st
        fld     bar[8]
        print Str$("Xmm2:2\t%9f\n", ST(0))
        fstp    st
        fld     bar[12]
        print Str$("Xmm2:3\t%9f\n", ST(0))
        fstp    st
        Inkey
Exit
        end     start

Code:
Xmm2:0  3.14000010
Xmm2:1  2.73000002
Xmm2:2  6.67399979
Xmm2:3  1.23399997
Logged

It could be a random act of randomness. Those happen a lot as well.
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: XMMWORD initializers?
« Reply #9 on: January 13, 2011, 08:44:05 PM »

Is an XMMWORD the same byte ordering as four consequtive REAL4s?  I'm too rusty on the format to remember big vs little endian.

I am not sure if it's a valid question. SSE2 can handle REAL4 and REAL8 but not REAL16.
If you use...
Code:
MyO OWORD 11111111
MyQ QWORD 11111111, 22222222
...
movups xmm1, MyO
movups xmm5, oword ptr MyQ
... you get this output. Looks little Endian somehow wink
MyO/x1  11111111.0
MyQ/x5  11111111.0
Logged

clive
Hardcore x86, ARM and MIPS toolsmith
Member
*****
Posts: 1230


Project Looking Glass. Following the white rabbit.


Re: XMMWORD initializers?
« Reply #10 on: January 13, 2011, 08:46:25 PM »

Is an XMMWORD the same byte ordering as four consequtive REAL4s?  I'm too rusty on the format to remember big vs little endian.

Haven't thought about it, always assumed they all fit together in the right fashion. Not like I'm jamming a MC68882 into the mix.

Code:
       include \masm32\MasmBasic\MasmBasic.inc
       .data
foo     REAL4   3.14, 2.73, 6.674, 1.234
bar     REAL4   ?, ?, ?, ?
Init
       movups  xmm2, foo
       addps   xmm2,xmm2

       movups  bar, xmm2
       fld     bar[0]
       print Str$("Xmm2:0\t%9f\n", ST(0))
       fstp    st
       fld     bar[4]
       print Str$("Xmm2:1\t%9f\n", ST(0))
       fstp    st
       fld     bar[8]
       print Str$("Xmm2:2\t%9f\n", ST(0))
       fstp    st
       fld     bar[12]
       print Str$("Xmm2:3\t%9f\n", ST(0))
       fstp    st
       Inkey
Exit
       end     start

Code:
Xmm2:0  6.28000021
Xmm2:1  5.46000004
Xmm2:2  13.3479996
Xmm2:3  2.46799994

Could try a multiply with different constants for giggles.
Logged

It could be a random act of randomness. Those happen a lot as well.
clive
Hardcore x86, ARM and MIPS toolsmith
Member
*****
Posts: 1230


Project Looking Glass. Following the white rabbit.


Re: XMMWORD initializers?
« Reply #11 on: January 13, 2011, 08:51:50 PM »

Code:
        include \masm32\MasmBasic\MasmBasic.inc
        .data
foo     REAL4   3.14, 2.73, 6.674, 1.234
oof     REAL4   1.00, 2.00, 3.00,  4.00

bar     REAL4   ?, ?, ?, ?

Init
        movups  xmm2, foo
        movups  xmm5, oof
        mulps   xmm2,xmm5

        movups  bar, xmm2
        fld     bar[0]
        print Str$("Xmm2:0\t%9f\n", ST(0))
        fstp    st
        fld     bar[4]
        print Str$("Xmm2:1\t%9f\n", ST(0))
        fstp    st
        fld     bar[8]
        print Str$("Xmm2:2\t%9f\n", ST(0))
        fstp    st
        fld     bar[12]
        print Str$("Xmm2:3\t%9f\n", ST(0))
        fstp    st
        Inkey   "Press any key", 10, 13
Exit
        end     start

Code:
Xmm2:0  3.14000010
Xmm2:1  5.46000004
Xmm2:2  20.0219994
Xmm2:3  4.93599987
Press any key
Logged

It could be a random act of randomness. Those happen a lot as well.
clive
Hardcore x86, ARM and MIPS toolsmith
Member
*****
Posts: 1230


Project Looking Glass. Following the white rabbit.


Re: XMMWORD initializers?
« Reply #12 on: January 13, 2011, 08:57:19 PM »

Quote from: jj2007
It's not yet foreseen, but if there is an urgent need for it...

About the second thing I thought of, most any case of vector math you'd likely want to see all the values. Not that I'm trying to make work for you.
Logged

It could be a random act of randomness. Those happen a lot as well.
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: XMMWORD initializers?
« Reply #13 on: January 13, 2011, 09:18:07 PM »

Even with the current version it is not that difficult:

Code:
.data
MyP4 dd 12, 34, 56, 78
xxl0 dd ?
xxl1 dd ?
xxl2 dd ?
xxl3 dd ?
.code
movups xmm1, MyP4
movups xxl0, xmm1
PrintLine Str$("Packed 4: %i", xxl0), ", ", Str$(xxl1), ", ", Str$(xxl2), ", ", Str$(xxl3)

Note that JWasm requires two oword ptr qualifiers:
Code:
movups xmm1, oword ptr MyP4
movups oword ptr xxl0, xmm1

Output:
Packed 4: 12, 34, 56, 78
Logged

Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!