CopyMemory() only in ASM without API possible ?

Just starting out? Need help? Post your questions and find answers here.
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

CopyMemory() only in ASM without API possible ?

Post by newbie »

Hello,

Just out of curiosity, I've looked at the /COMMENTED ASM output, and noticed the following :
; CopyMemory(*Fromaddr, *Toaddr, 5)
PUSH dword 5
PUSH dword [esp+PS28+4]
PUSH dword [esp+PS28+12]
CALL _PB_CopyMemory@12
Isn't it possible to copy directly the memory in pure ASM ?
MOV eax, Fromaddr
MOV Toaddr, eax

I'm sure it's not that simple, it would have already been implemented if it was ;) Just wondering if it's possible to do it only in ASM, and if yes (and how) is there any speed gain ?
I found on the forum a post about an optimised CopyMemory for AMD processors, but it was rather complex.

Nothing urgent, but if you know the answer... thanks you in advance ;)
- Registered PB user -

Using PB 4.00
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Re: CopyMemory() only in ASM without API possible ?

Post by Rescator »

newbie wrote:Hello,

Just out of curiosity, I've looked at the /COMMENTED ASM output, and noticed the following :
; CopyMemory(*Fromaddr, *Toaddr, 5)
PUSH dword 5
PUSH dword [esp+PS28+4]
PUSH dword [esp+PS28+12]
CALL _PB_CopyMemory@12
Not sure how PB's code is, but I assume Fred made his own code for it.
newbie wrote:Isn't it possible to copy directly the memory in pure ASM ?
MOV eax, Fromaddr
MOV Toaddr, eax
That would just copy the pointers.
newbie wrote:I'm sure it's not that simple, it would have already been implemented if it was ;) Just wondering if it's possible to do it only in ASM, and if yes (and how) is there any speed gain ?
I found on the forum a post about an optimised CopyMemory for AMD processors, but it was rather complex.

Nothing urgent, but if you know the answer... thanks you in advance ;)
Your own asm copymem if it was to work on any x86 cpu would be limited to 4 bytes (32bit) and would be a asm loop somewhat similar to the above.
One can get a larger speedup using asm and mmx registers though.
I'm not sure if PB has a mmx optimized routine or not available. (cpu choice in compile options) though...
Post Reply