| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | memcpy |
Answering msg from Paul Edwards to Frank Malcolm,
on Monday January 08 1996 at 23:48
Hi Paul, a couple of optimizations and suggestions.
PE> public memcpy
PE> memcpy proc
PE> push ebp
PE> mov ebp, esp
PE> pushf
PE> push edi
PE> push esi
PE> push ecx
PE> mov edi, [ebp+8]
mov eax,edi ; used for return value
PE> mov esi, [ebp+12]
PE> mov ecx, [ebp+16]
PE> cld
PE> shr ecx, 2
PE> rep movsd
----
PE> mov ecx, [ebp+16]
PE> and ecx, 00000003H
----
; Try replacing the above two lines with this.
; It may or may not be faster, time it and see. (Would be a small
; difference only)
mov cl,byte ptr [ebp+16] ; ECX=0 so we can safely manipulate
and cl,3 ; the bottom byte only
PE> rep movsb
PE> mov eax, [ebp+8]
; remove above line, eax is set above
PE> pop ecx
PE> pop esi
PE> pop edi
PE> popf
PE> pop ebp
PE> ret
PE> memcpy endp
In certain cases, it can be faster to move memory with
"primitives" rather than the MOVSx commands, such as:
mov eax,[esi] ; staggered to avoid AGI
mov ebx,[esi+4]
mov ecx,[esi+8]
mov [edi],eax
mov [edi+4],ebx
mov [edi+8],ecx
add si,12
loop ...
This is entirely off the top of my head, but you get the idea. This will be
most efficient for 486+ processors.
---
* Origin: Jelly-Bean software development, Melbourne AUST. (3:635/727.1)SEEN-BY: 50/99 632/103 348 998 633/371 634/384 635/402 503 544 727 638/102 SEEN-BY: 639/252 640/230 690/718 711/401 410 413 430 808 809 934 713/888 SEEN-BY: 800/1 7877/2809 @PATH: 635/727 632/348 635/503 50/99 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.