News:

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

can't assemble a simple instruction

Started by ramguru, June 16, 2009, 01:41:34 PM

Previous topic - Next topic

jorgon

On the question of MOVD and MOVQ ..

ramguru started the thread because when wanting to move 64-bits (a quadword) from the low part of an XMM register to a 64-bit general purpose register, he 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


        .intel

and

        .amd

directives ?
just a thought

jorgon

 
Quote       .intel

and

        .amd

Maybe, except that I have tried to avoid processor directives since they are another thing to get wrong or result in strange effects (and also rapidly get out of date).

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

ramguru

I don't mind if it stays as it is.
I've suspected that movd really worked as movq with 64bit registers.
Tried to modify the opcode (by hand) & couldn't make disassembler
interpret it as movq (so yeah most of disassemblers follows faulty AMD notation :/ )

dedndave

#19
well, the advantage of using the directives is, you can maintain backward compatibility in the future
i don't see ".amd" or ".intel" as any better or worse than ".586" or ".686"
in fact, it is slightly milder, as a program written with ".amd" may be run on an intel processor and one with ".intel" may be run on amd
keep in mind, that it only affects interpretation of a few instructions
it does not neccessarily change any generated code
pick the one you like the best and call it default - lol
in this case, i dislike amd's use of movd, so my vote for default would be .intel
however, as long as they are aware of the reprecussions, i say let the programmer choose
again, it's only food for thought

BlackVortex

Intel way is the right way, as always.   :bdg

Mark Jones

Not having to use ".386"  or other directives is one of the things I like about GoASM. :bg
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08