cppman Posted July 20, 2008 Share Posted July 20, 2008 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. Miva OS Project Link to comment Share on other sites More sharing options...
Nutster Posted August 4, 2008 Share Posted August 4, 2008 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 NuttallNuttall 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 More sharing options...
cppman Posted August 9, 2008 Author Share Posted August 9, 2008 (edited) 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 August 9, 2008 by cppman Miva OS Project Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now