Advertisement

Where can I get an assembly memcpy for...

Started by April 02, 2001 11:38 AM
10 comments, last by Dark Star 23 years, 10 months ago
DJGPP . That''s all thanks Dark Star
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
?? how is assembly language different for djgpp than for anything else? assembly languages are processor instructions, not compiler dependent, so i dont get it?
Advertisement
Well, he could be referring to the fact that DJGPP uses AT&T syntax, as opposed to Intel syntax.

~~~~~~~~~~
Martee
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
If you don''t like the AT&T syntax that DJGPP uses, then just use an external assembler like NASM (or even MASM). You can compile the assembler files to COFF object files and then link them with your DJGPP program.
Why do you want another memcpy()? I bet the existing one is basically a "rep movsd" with some code in the beginning and end to cope with non-dword aligned addresses and sizes... You don''t get much better than that. But then again I''ve never used djgpp so I''m not sure that memcpy is implemented like that in djgpp.
REP MOVSD is not optimal.

It is slower than a loop containing
MOV [EDI], EAX
INC EDI

on modern processors.

Also, i think the memcpy in DJGPP used to only use REP MOVSB, so this obviously isn''t the fastest it could be although it has probably been changed since then.

If you write your own, and you are a speed freak, you can make sure it''s all pipelined properly. Hell, you can even use the FPU if you really feel like it!
Advertisement
Hmm, you''re probably right, haven''t been coding asm (seriously) since the original Pentium... and now that you mention it, your way would probably be faster on a Pentium (1) as well.
However if you write your own, you are more likely than not to make it slower than the standard version if you are an asm-beginner (which seems to be the case here, or he would have written his own already).
I have actually looked at the memcpy() and memset() codes and it is not written in assembler but pure C. It copies from pointer to pointer n amount of times (n being the size you send). That''s the DJGPP version and that''s definatley not assembler to me. I have noticed in my games when I use it to copy buffers I get a slow frame rate because I am copying 64000 bytes of data from one to the other.

Help.... I hate slow games


Dark Star

---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Well, look what a simple google-search gave me:
http://www.rt.e-technik.tu-darmstadt.de/~georg/djgpp/djgpp_asm.html

It''s all there, a rep stosd memcpy() and all.
If you''re copying the entire screen every frame, then it''s unlikely that your problem is a slow memcpy(), it''s more likely that your algorithms is rather badly designed. I don''t think you''d get that much of a speed increase from switching to an assembly memcpy anyway.

This topic is closed to new replies.

Advertisement