Jump to content

Moving multiple bytes at the same time


cppman
 Share

Recommended Posts

I'm curious how to move multiple bytes at the same time in C, C++, or even just simply ASM - I can inline it.

I've all ready checked out the source to memcpy and of course, it just does it one byte at a time.

while(n--) { ... *++dest = *++src; } ....

So is there any way to do it more than one byte at a time?

Thanks.

Link to comment
Share on other sites

  • 3 weeks later...

I'm curious how to move multiple bytes at the same time in C, C++, or even just simply ASM - I can inline it.

I've all ready checked out the source to memcpy and of course, it just does it one byte at a time.

while(n--) { ... *++dest = *++src; } ....

So is there any way to do it more than one byte at a time?

Thanks.

You could look for information on using the DMA (Direct Memory Access). If you have several bytes (in excess of about 128 bytes), this is often quite a bit faster than copying bytes or even words (2 or 4 byte groups). Unfortunately, I do not have any documentation on setting the DMA.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

Thanks for the reply. However, I figured out a way to copy up to 8 bytes at a time all ready; however, it is slower than copying 1 byte at a time(but faster than copying only 4 bytes at a time) for some reason.

//copy 4 bytes from src and place in dst
*(DWORD *)++dst = *(DWORD *)++src;

// copy remaining bytes....

Also, I'm not quite sure if having DMA would help any. You still have the problem of placing the bytes into memory (either one at a time, or N at a time - if it can be done). I also think that DMA would probably be disabled for software(not even sure if it could be used in software, in the first place) once the CPU goes into protected mode.

Edited by cppman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...