I'm copying elements from one array to another in C++. I found the rep movs
instruction in x86 that seems to copy an array at ESI to an array at EDI of size ECX. However, neither the for
nor while
loops I tried compiled to a rep movs
instruction in VS 2008 (on an Intel Xeon x64 processor). How can I write code that will get compiled to this instruction?
If you need exactly that instruction - use built-in assembler and write that instruction manually. You can't rely on the compiler to produce any specific machine code - even if it emits it in one compilation it can decide to emit some other equivalent during next compilation.