The MASM Forum Archive 2004 to 2012

Project Support Forums => 64 Bit Assembler => Topic started by: jorgon on June 30, 2009, 02:53:56 PM

Title: MOVQ, MOVD or both?
Post by: jorgon on June 30, 2009, 02:53:56 PM
On the question of MOVD and MOVQ ..

There has been some discussion in this thread (http://www.masm32.com/board/index.php?topic=11674.0) 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?
Title: Re: MOVQ, MOVD or both?
Post by: dedndave on June 30, 2009, 04:02:00 PM
see remark in other thread
Title: Re: MOVQ, MOVD or both?
Post by: Mark Jones on July 01, 2009, 09:21:12 PM
...Any chance AMD could update their manual? I mean, their usage is the "odd" one.
Title: Re: MOVQ, MOVD or both?
Post by: 1rDirEctoALgran0 on July 03, 2009, 08:21:10 PM
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
Title: Re: MOVQ, MOVD or both?
Post by: dedndave on July 03, 2009, 08:48:26 PM
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)
Title: Re: MOVQ, MOVD or both?
Post by: Astro on August 04, 2009, 01:48:42 PM
I propose a new mnemonic, MOVQD, for processors with an identity crisis!!  :cheekygreen:

Best regards,
Astro.