The enclosed code is created by PC rel. 7 for memmove.
Irritatingly I get sporadic wrong results with overlapping moves, i.e. the move-direction seems wrong.
I am now guessing in the wild that it might depend on the actual varying address location, i.e. higher addresses may be treated as negative. Compiled with gcc or msvc I have no problems.
My guess is that the b.m. jle at [00401112] should be an unsigned jbe instead. Any other ideas???
Greetings
Akko
[004010E0] 56 push esi
[004010E1] 57 push edi
[004010E2] 8B7C240C mov edi,dword ptr [esp+C]
[004010E6] 8B742410 mov esi,dword ptr [esp+10]
[004010EA] 8B4C2414 mov ecx,dword ptr [esp+14]
[004010EE] 89C8 mov eax,ecx
[004010F0] 01F0 add eax,esi
[004010F2] 39F7 cmp edi,esi
[004010F4] 7604 jbe 004010FA
[004010F6] 39C7 cmp edi,eax
[004010F8] 720A jb 00401104
[004010FA] 5F pop edi
[004010FB] 5E pop esi
[004010FC] E9FF010000 jmp 00401300
[00401101] 8D7F00 lea edi,[edi+0]
[00401104] FD std
[00401105] 01CE add esi,ecx
[00401107] 01CF add edi,ecx
[00401109] 89C8 mov eax,ecx
[0040110B] 89F9 mov ecx,edi
[0040110D] 83E103 and ecx,3
[00401110] 29C8 sub eax,ecx
[00401112] 7E1E jle 00401132 ; <--- ? not jbe?
[00401114] 83EE01 sub esi,1
[00401117] 83EF01 sub edi,1
[0040111A] F3A4 rep movsb
[0040111C] 83EE03 sub esi,3
[0040111F] 83EF03 sub edi,3
[00401122] 89C1 mov ecx,eax
[00401124] 83E003 and eax,3
[00401127] C1E902 shr ecx,2
[0040112A] F3A5 rep movsd
[0040112C] 83C603 add esi,3
[0040112F] 83C703 add edi,3
[00401132] 01C1 add ecx,eax
[00401134] F3A4 rep movsb
[00401136] FC cld
[00401137] 8B44240C mov eax,dword ptr [esp+C]
[0040113B] 5F pop edi
[0040113C] 5E pop esi
[0040113D] C3 ret