Hi, does anyone know the syntax for MASM's CMPSD and MOVSD instructions (the SSE variety, not the string instructions)?

Cheers,
Randy Hyde
Posted on 2003-06-10 10:35:48 by rhyde
movsd
Moves a scalar double-precision floating-point value from the source operand (second operand)
to the destination operand (first operand). The source and destination operands can be XMM
registers or 64-bit memory locations. This instruction can be used to move a double-precision
floating-point value to and from the low quadword of an XMM register and a 64-bit memory
location, or to move a double-precision floating-point value between the low quadwords of two
XMM registers. The instruction cannot be used to transfer data between memory locations.
When the source and destination operands are XMM registers, the high quadword of the desti-
nation operand remains unchanged. When the source operand is a memory location and desti-
nation operand is an XMM registers, the high quadword of the destination operand is cleared to
all 0s.
compsd

Compares the low double-precision floating-point values in the source operand (second
operand) and the destination operand (first operand) and returns the results of the comparison to
the destination operand. The comparison predicate operand (third operand) specifies the type of
comparison performed. The comparison result is a quadword mask of all 1s (comparison true)
or all 0s (comparison false). The source operand can be an XMM register or a 64-bit memory
location. The destination operand is an XMM register. The result is stored in the low quadword
of the destination operand; the high quadword remains unchanged. The comparison predicate
operand is an 8-bit immediate the first 3 bits of which define the type of comparison to be made
Posted on 2003-06-17 09:16:36 by feizhongshvi
I think it is

MOVSD?Move Scalar Double-Precision Floating-Point Values
F2 0F 10 /r MOVSD xmm1, xmm2/m64 Move scalar double-precision floating-point value from xmm2/m64 to xmm1 register.
F2 0F 11 /r MOVSD xmm2/m64, xmm Move scalar double-precision floating-point value from xmm1 register to xmm2/m64.

CMPSD?Compare Scalar Double-Precision Floating-Point Values
0F C2 /r ib CMPPS xmm1, xmm2/m128, imm8 Compare packed single-precision floating-point values in xmm2/mem and xmm1 using imm8 as comparison predicate.
Posted on 2003-06-17 09:23:20 by roticv
The following code generates "invalid instruction operands" errors:



.686p
.mmx
.xmm
.model flat, syscall
option noscoped

.code



Main proc near32

cmpsd xmm1, xmm2
movsd xmm1, xmm2

Main endp

end


This is the problem I'm trying to track down. How do I specify these instructions in MASM? I already know what they're supposed to do (and even how to encode them in binary). What I don't know is the assembly syntax for these instructions in MASM. It appears as though MASM is confusing these instructions with the string instructions of the same name.
Cheers,
Randy Hyde
Posted on 2003-06-17 12:42:45 by rhyde
maybe you should set value in xmm1 and xmm2 before you use the instruction
Posted on 2003-06-22 09:06:22 by feizhongshvi

The following code generates "invalid instruction operands" errors:
	cmpsd  xmm1, xmm2

movsd xmm1, xmm2



because the SSE2 cmpsd instruction takes 3 operands, as roticv said..

Originally posted by roticv
CMPSD?Compare Scalar Double-Precision Floating-Point Values
0F C2 /r ib CMPPS xmm1, xmm2/m128, imm8 Compare packed single-precision floating-point values in xmm2/mem and xmm1 using imm8 as comparison predicate.


but this is a mistake from gorilla coder's quickref where gorillacoder has copied cmpps for some reason. Here it is from the intel manuals.


Opcode Instruction Description
F2 0F C2 /r ib CMPSD xmm1, xmm2/m64, imm8 Compare low double-precision floating-point
value in xmm2/m64 and xmm1 using imm8 as
comparison predicate.


but, as the intel manual volume 2 says, assemblers may implement "two-operand pseudo-ops" as follows:



+-----------------------+--------------------+
| pseudo-op | implementation |
+-----------------------+--------------------+
| CMPEQSD xmm1, xmm2 | CMPSD xmm1,xmm2, 0 |
| CMPLTSD xmm1, xmm2 | CMPSD xmm1,xmm2, 1 |
| CMPLESD xmm1, xmm2 | CMPSD xmm1,xmm2, 2 |
| CMPUNORDSD xmm1, xmm2 | CMPSD xmm1,xmm2, 3 |
| CMPNEQSD xmm1, xmm2 | CMPSD xmm1,xmm2, 4 |
| CMPNLTSD xmm1, xmm2 | CMPSD xmm1,xmm2, 5 |
| CMPNLESD xmm1, xmm2 | CMPSD xmm1,xmm2, 6 |
| CMPORDSD xmm1, xmm2 | CMPSD xmm1,xmm2, 7 |
+--------------------------------------------+


unfortunatly, the ml.exe i have (version 7.10.2179) doesn't seem to support those pseudo ops :( so you'd have to use the three operand version or make macros. e.g. "cmpeqss xmm0,xmm1" assembles ok but "cmpeqsd xmm0,xmm1" doesn't.

hope this helps :)

-stormix
Posted on 2003-06-28 06:51:35 by stormix
Any ideas on MOVSD?
Cheers,
Randy Hyde
Posted on 2003-06-30 16:27:48 by rhyde
Ooops!

Fasm doesn't affected :)
Posted on 2003-06-30 22:25:08 by Bi_Dark
apologies for the long delay, i tried:



.686
.xmm
.model flat,stdcall
OPTION CASEMAP:NONE

.data
aDouble dq 3.1

.code

start:
movsd xmm0,xmm1
movsd xmm1,aDouble
movsd aDouble,xmm0

end start


and it compiled ok, i checked the opcodes it made and they were OK.

this is ml 7.10.2179 from the xp ddk.
Posted on 2003-07-07 15:59:56 by stormix