0

Why it is not right to use two memory operand in instruction movx in x86? Is there any hardware problem?

2 Answers2

2

The hardware problem is that the instruction set does not have such instructions.

The CPU could certainly be extended with instructions allowing two memory operands, but Intel has not done that, because there really wouldn't be much benefit to it. Why would they?

jalf
  • 243,077
  • 51
  • 345
  • 550
1

memory is just memory. It doesn't know how to move around stuff - that's what a CPU does, so you 1) copy from memory to the CPU, and 2) from the CPU back to memory. The mov instruction does that.

Wiring up the mov instruction inside the CPU to be more complex so it could implicitly do both those things would likely not provide any benefit.

The more specialized MOVS instruction can move between two memory instructions, though it requires 2 registers, so it is often not of benefit if you need to save those registers.

There are other devices, such as a DMA engine, that can offload the burden from the CPU.

nos
  • 223,662
  • 58
  • 417
  • 506
  • 1
    Just for completeness, the PUSH and POP instructions may also be used to copy from memory to memory. – Sparky Nov 18 '13 at 01:28