News:

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

MOVQ, MOVD or both?

Started by jorgon, June 30, 2009, 02:53:56 PM

Previous topic - Next topic

jorgon

On the question of MOVD and MOVQ ..

There has been some discussion in this thread in the GoAsm forum about moving 64-bits (a quadword) from the low part of an XMM register to a 64-bit general purpose register.  Ramguru found that the following instruction:-
MOVQ RCX,XMM1
returned the error "Invalid operand for this mnemonic" in Goasm

This accords with the AMD64 manual which specifies the following instruction instead
MOVD RCX,XMM1

GoAsm assembles the above instruction correctly so that it works with 64-bits, ie the REX byte is included in the output.

However, the Intel documentation for the EM64T processor says that the MOVQ instruction is valid. 

In other words, according to Intel,
MOVQ RCX,XMM1
will do what AMD says is done by
MOVD RCX,XMM1

I do not know why AMD did not suggest the use of MOVQ here, after all, this instruction does move a qword.

In the circumstances I would propose to amend GoAsm to add support for the MOVQ variant here.  GoAsm would therefore give the same output in both cases.  The only thing which would stop me doing this is the possibility that AMD might be planning to use MOVQ for some other purpose which would conflict with this use.  However, that seems unlikely now in the light of the Intel documentation.

Does anyone have any objections to this change?
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

dedndave

see remark in other thread

Mark Jones

...Any chance AMD could update their manual? I mean, their usage is the "odd" one.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

1rDirEctoALgran0

But we can find the answer for MOVQ in the AMD book #26568 page 187.  :toothy
MOVQ can only manage XMM registers.
MOVD can manage General purpose registers and XMM registers.

Patrick

dedndave

i know !
use neither one - lol
that way, you are compatible with both
and, as an added bonus, it greatly simplifies Jeremy's task
i think it would have to be a pretty special need for the programmer
to write a routine both ways (all 3 ways, if there are any processors
that support neither), then determine which CPU it is running under

or, at least, use them only in the ways that both instructions function the same, then use either mnemonic   :bg
(j/k Jeremy - i know you'll find the best solution)

Astro

I propose a new mnemonic, MOVQD, for processors with an identity crisis!!  :cheekygreen:

Best regards,
Astro.