Hi there,
I am back with these macros and this time with the vengeance
this time I can assure you that they work as expected
take a look at this:
xmemcpy PROC USES edi esi dest:DWORD,src:DWORD,count:DWORD
mov eax,dest
.if (src != eax)
.if (count)
.for (esi=src,edi=dest,ecx=count:ecx:al=[esi],[edi]=al,esi++,edi++,ecx--)
.endfor
.endif
.endif
mov eax,dest
ret
xmemcpy ENDP
;--------------------------------------------------
xmemcpy:
004011ee 55 push ebp
004011ef 8bec mov ebp,esp
004011f1 57 push edi
004011f2 56 push esi
004011f3 8b4508 mov eax,dword ptr [ebp+8]
004011f6 39450c cmp dword ptr [ebp+0Ch],eax
004011f9 7424 je xmemcpy+0x31 (0040121f)
004011fb 837d1000 cmp dword ptr [ebp+10h],0
004011ff 741e je xmemcpy+0x31 (0040121f)
00401201 8b750c mov esi,dword ptr [ebp+0Ch]
00401204 8b7d08 mov edi,dword ptr [ebp+8]
00401207 8b4d10 mov ecx,dword ptr [ebp+10h]
0040120a eb0d jmp xmemcpy+0x2b (00401219)
0040120c 8a06 mov al,byte ptr [esi]
0040120e 8807 mov byte ptr [edi],al
00401210 83c601 add esi,1
00401213 83c701 add edi,1
00401216 83e901 sub ecx,1
00401219 23c9 and ecx,ecx
0040121b 7402 je xmemcpy+0x31 (0040121f)
0040121d ebed jmp xmemcpy+0x1e (0040120c)
0040121f 8b4508 mov eax,dword ptr [ebp+8]
00401222 5e pop esi
00401223 5f pop edi
00401224 c9 leave
00401225 c20c00 ret 0Ch
;--------------------------------------------------
;and this would be in x64:
xmemcpy PROC FRAME dest:QWORD,src :QWORD, count:UINT_PTR
.if (rcx != rdx)
.if (r8)
.for (:r8:al=[rdx],[rcx]=al,rcx++,rdx++,r8--)
.endfor
.endif
.endif
mov rax,dest
ret
xmemcpy ENDP
;--------------------------------------------------
xmemcpy PROC FRAME dest:QWORD,src :QWORD, count:UINT_PTR
0000000000493496 mov qword ptr [rsp+8],rcx
000000000049349B push rbp
000000000049349C mov rbp,rsp
000000000049349F cmp rcx,rdx
00000000004934A2 je xmemcpy+25h (4934BBh)
00000000004934A4 and r8,r8
00000000004934A7 je xmemcpy+25h (4934BBh)
00000000004934A9 mov al,byte ptr [rdx]
00000000004934AB mov byte ptr [rcx],al
00000000004934AD add rcx,1
00000000004934B1 add rdx,1
00000000004934B5 sub r8,1
00000000004934B9 jmp xmemcpy+13h (4934A9h)
00000000004934BB mov rax,qword ptr [rbp+10h]
00000000004934BF add rsp,0
00000000004934C3 pop rbp
00000000004934C4 ret
xmemcpy ENDP
;--------------------------------------------------
and this time I don't care if you like it or not because I am happy with it