1

When i was 13 i started programming MSX computer which ended in writting assembler code to perform some things. One of the powerfull command the MSX had was a single command to move a datablok. This was often used to do fast screen moves.

Now that i work with a fast linescan camera, i am in need of such a fast command again. So that i could move part of a bitmap down, and fill the first row with new linescan data.

I have never programmed assembler on todays pentium computers. So I am wondered do these days pentium computers too have such assembler instructions ? I could also do it in some c++ / c# for next loop, but a single assembler instruction would be a lot faster for this i know.

user613326
  • 2,140
  • 9
  • 34
  • 63
  • Sure, x86 has `rep movsd`, but it's not recommended to use it because it's sub-optimal these days. The `memcpy` function in libc is usually quite optimized to use the fastest way of copying the data on the target platform. – Michael Oct 15 '13 at 12:20
  • While looking at libc i noted there is also a memmove verb see http://www.delorie.com/djgpp/doc/libc/libc_568.html Does it mean that that command is optimized too ? – user613326 Oct 15 '13 at 13:05
  • @user613326 See http://stackoverflow.com/questions/1201319 for memmove vs memcpy. If you don't have overlapping addresses, memcpy may even be *faster* because it isn't constrained in how it copies the data. – us2012 Oct 15 '13 at 13:16
  • 1
    @Michael - No, it is not. `rep movsd` is still the fastest way to move the data from one place to another. It is another talk, that sometimes it is impossible to be used, because you have to make some checks in the copy cycle. – johnfound Oct 15 '13 at 13:42
  • @johnfound: Intel say in their optimization manual that AVX is faster for chunks larger than about 2kB. Starting with Ivy Bridge they added "Enhanced REP MOVSB", which is supposed to be faster than a combination of REP MOVSD and REP MOVSB, but it's still outperformed by AVX unless you're copying small amounts of data. In the end it's unlikely that you'll beat `memcpy` except for very specific applications. – Michael Oct 15 '13 at 13:56
  • @Michael - Well, I was talking about the plain x86. Using all these extensions usually leads to big compatibility issues. But yes, you are right generally speaking. – johnfound Oct 15 '13 at 14:00

0 Answers0