Which instruction involves moving the content of some memory location to another memory location?

Only one operand of "mov" can be a memory addsress, is it exist that move the content of some memory location to another memory location?
Posted on 2004-06-17 21:58:12 by bloggs
mov eax MemLocation1
mov MemLocation2 eax

or

push MemLocation1
pop MemLocation2
Posted on 2004-06-17 22:00:49 by JimmyClif
bloggs,

Jimmy is right, there is no opcode in x86 hardware to perform direct memory to memory copy, of the two options that Jimmy has shown you, the mov reg style is usually faster in an algorithm but it assumes you have a spare register to do it. If you don't have the register to do the copy, the stack method works fine but is not as fast.

Regards,
http://www.asmcommunity.net/board/cryptmail.php?tauntspiders=in.your.face@nomail.for.you&id=2f46ed9f24413347f14439b64bdc03fd
Posted on 2004-06-17 22:49:47 by hutch--
why do the cpu designer not allow that both of operands are memory address?
Posted on 2004-06-17 23:25:37 by bloggs
why do the cpu designer not allow that both of operands are memory address?

You'll need to ask Intel that question. :)

Mainframes have had mem-mem moves (and compares etc.) for decades. The old System/360 had 256 byte max MVC instruction. The S/370 introduced MVCL, an interruptable instruction, that can move up to 16 meg. New S/390s can move gigabytes with a single MVCLE op.

On the x86, another option is the "string" instruction MOVS, but you've got to set it up first...

:)
Posted on 2004-06-18 00:15:46 by S/390
yes,
it is very curious that intel don't add this instructor to the x86
Posted on 2004-06-18 15:36:14 by bloggs
Actually, both push/pop and movs are memory-to-memory instructions. The problem is just that their operands are fixed, and it is generally faster to just use two regular movs and a register.

Why are there no regular memory-to-memory instructions? Probably because they are two separate operations, a load and a store. Both need an address calculation aswell, and you can only do one address calculation per instruction. That's the way the CPU is designed. So the design simply doesn't allow you to do this in a single operation.

Why do push/pop and movs work then? Since they have fixed operands, there is no full address calculation required.
Mind you, on modern CPUs they are just implemented as macro-instructions. They are emulated by a set of regular instructions internally. Especially movs is slow because of that.

So it's not that strange that Intel didn't add it. Most other manufacturers didn't add it either. In fact, the x86 still has far more complex addressing modes than most other CPUs anyway.
The only CPU I know of that is more complex, is the Motorola 680x0. It actually does support memory-to-memory operations, and it also has some addressing modes that makes an x86 look silly. On the other hand, these addressing modes are so powerful that there are no separate push/pop instructions, or string operations. All these operations can be built with just regular instructions and clever use of the addressing modes.
I don't know how the memory-to-memory is implemented though. I suspect it still has only one address generation unit, and it probably splits it up into a load and store internally, much like movs does.
Posted on 2004-06-18 17:15:06 by Scali
well u could set ESI to thge source memory address, EDI to destination memory address and put ECX to 1 and execute a rep movsd, but that is a very bad idea especially for 1 transfer, you should only use rep movs for transferring larger blocks of data, To do this I would use the push/pop method or even the register method.
Posted on 2004-06-19 13:17:42 by x86asm

Actually, both push/pop and movs are memory-to-memory instructions. The problem is just that their operands are fixed, and it is generally faster to just use two regular movs and a register.

Why are there no regular memory-to-memory instructions? Probably because they are two separate operations, a load and a store. Both need an address calculation aswell, and you can only do one address calculation per instruction. That's the way the CPU is designed. So the design simply doesn't allow you to do this in a single operation.

Why do push/pop and movs work then? Since they have fixed operands, there is no full address calculation required.
Mind you, on modern CPUs they are just implemented as macro-instructions. They are emulated by a set of regular instructions internally. Especially movs is slow because of that.

So it's not that strange that Intel didn't add it. Most other manufacturers didn't add it either. In fact, the x86 still has far more complex addressing modes than most other CPUs anyway.
The only CPU I know of that is more complex, is the Motorola 680x0. It actually does support memory-to-memory operations, and it also has some addressing modes that makes an x86 look silly. On the other hand, these addressing modes are so powerful that there are no separate push/pop instructions, or string operations. All these operations can be built with just regular instructions and clever use of the addressing modes.
I don't know how the memory-to-memory is implemented though. I suspect it still has only one address generation unit, and it probably splits it up into a load and store internally, much like movs does.

Ya the 680x0 has some nice addressing modes, though I am writing an emulator for the chip,the addressing modes are quite a pain to emulate.
Posted on 2004-06-19 13:18:45 by x86asm
Ya the 680x0 has some nice addressing modes, though I am writing an emulator for the chip,the addressing modes are quite a pain to emulate.


There is a 68k JIT compiler that is used for WinUAE. It is very fast, and publicly available: http://www.winuae.net/
Perhaps you can use it for your emulator.
Posted on 2004-06-19 16:30:26 by Scali

bloggs,

Jimmy is right, there is no opcode in x86 hardware to perform direct memory to memory copy,


movs is direct memory to memory. memory pointed by esi to memory pointed by edi.

Push is also memory to memory. From mem pointed by to memory pointed by
Posted on 2004-06-19 16:47:11 by The Svin



There is a 68k JIT compiler that is used for WinUAE. It is very fast, and publicly available: http://www.winuae.net/
Perhaps you can use it for your emulator.

I would lol, but I like to try thisone on my own, just to learn how these things work (yes I know reinventing the wheel ):grin:
Posted on 2004-06-19 16:54:26 by x86asm