Width *= 3;
register const int ld = iLineAdd + Width;
Width >>= 1;
Width--;
for (register int i = Height - 1; i >= 0; i--)
{
register unsigned short int *ptr = (unsigned short int *)ptrBuffer;
for (register int j = Width; j >= 0; j--)
{
*ptr = ~*ptr;
ptr++;
}
ptrBuffer += ld;
}
汇编代码
:00425E95 8D1C52 lea ebx, dword ptr [edx+2*edx] ; edx = Width
:00425E98 89DA mov edx, ebx
;:00425E9A 81EA23010000 sub edx, 00000123
:00425EA0 8B5D0C mov ebx, dword ptr [ebp+0C]
:00425EA3 03DA add ebx, edx
:00425EA5 D1FA sar edx, 1
:00425EA7 895DFC mov dword ptr [ebp-04], ebx ; [ebp-04] = ld
:00425EAA 4A dec edx
:00425EAB 49 dec ecx
:00425EAC 894DF8 mov dword ptr [ebp-08], ecx ; [ebp-08] = i
:00425EAF 837DF800 cmp dword ptr [ebp-08], 00000000
:00425EB3 7C50 jl 00425F05
:00425EB5 8BC8 mov ecx, eax ; eax = ptrBuffer
:00425EB7 8BDA mov ebx, edx ; ebx = j
:00425EB9 85DB test ebx, ebx
:00425EBB 7C0B jl 00425EC8
:00425EBD 66F711 not word ptr [ecx] ; *ptr = ~*ptr
:00425EC0 83C102 add ecx, 00000002 ; ptr++
:00425EC3 4B dec ebx ; j--
:00425EC4 85DB test ebx, ebx
:00425EC6 7DF5 jge 00425EBD
:00425EC8 0345FC add eax, dword ptr [ebp-04]
:00425ECB FF4DF8 dec [ebp-08]
:00425ECE 837DF800 cmp dword ptr [ebp-08], 00000000
:00425ED2 7DE1 jge 00425EB5
Width--;
#ifdef _using_color_rgb_struct_
register color_rgb *pDest;
register const int ld = iPixelAdd + 3;
for (register int i = Height - 1; i >= 0; i--)
{
for (register int j = Width; j >= 0; j--)
{
pDest = (color_rgb *)ptrDest;
*((unsigned short int *)ptrDest) = ~*((unsigned short int *)ptrDest);
pDest->r = ~pDest->r;
ptrDest += ld;
}
ptrDest += iLineAdd;
}
#else
汇编代码
:00425ED6 4A dec edx ; Width--
:00425ED7 8D7B03 lea edi, dword ptr [ebx+03] ; edi = ld
:00425EDA 49 dec ecx
:00425EDB 894DF4 mov dword ptr [ebp-0C], ecx ; [ebp-0C] = i
:00425EDE 837DF400 cmp dword ptr [ebp-0C], 00000000
:00425EE2 7C21 jl 00425F05
:00425EE4 8BF2 mov esi, edx ; j = Width
:00425EE6 85F6 test esi, esi ; esi = j
:00425EE8 7C0F jl 00425EF9
:00425EEA 8BC8 mov ecx, eax ; ecx = pDest 多浪费一步
:00425EEC 66F710 not word ptr [eax]
:00425EEF F65102 not [ecx+02]
:00425EF2 03C7 add eax, edi ; ptrDest += ld
:00425EF4 4E dec esi
:00425EF5 85F6 test esi, esi
:00425EF7 7DF1 jge 00425EEA
:00425EF9 03450C add eax, dword ptr [ebp+0C] ; ptrDest += iLineAdd
:00425EFC FF4DF4 dec [ebp-0C] ; i--
:00425EFF 837DF400 cmp dword ptr [ebp-0C], 00000000
:00425F03 7DDF jge 00425EE4
Width--;
#ifdef _using_short_int_
register const int ld = iPixelAdd + 2;
for (register int i = Height - 1; i >= 0; i--)
{
for (register int j = Width; j >= 0; j--)
{
*ptrDest = ~*ptrDest;
ptrDest++;
*((unsigned short int *)ptrDest) = ~*((unsigned short int *)ptrDest);
ptrDest += ld;
}
ptrDest += iLineAdd;
}
汇编代码
:00425EC8 4A dec edx ; Width--
:00425EC9 8D7302 lea esi, dword ptr [ebx+02] ; ld = iPixelAdd + 2
:00425ECC 81C223010000 add edx, 00000123
:00425ED2 8D79FF lea edi, dword ptr [ecx-01] ; i = Height - 1
:00425ED5 85FF test edi, edi
:00425ED7 7C1B jl 00425EF4
:00425ED9 8BCA mov ecx, edx
:00425EDB 85C9 test ecx, ecx
:00425EDD 7C0D jl 00425EEC
:00425EDF F610 not byte ptr [eax] ; *ptrDest = ~*ptrDest
:00425EE1 40 inc eax ; ptrDest++
:00425EE2 66F710 not word ptr [eax] ; *((unsigned short int *)ptrDest) = ~*((unsigned short int *)ptrDest)
:00425EE5 03C6 add eax, esi ; ptrDest += ld
:00425EE7 49 dec ecx ; j--
:00425EE8 85C9 test ecx, ecx
:00425EEA 7DF3 jge 00425EDF
:00425EEC 03450C add eax, dword ptr [ebp+0C] ; ptrDest += iLineAdd
:00425EEF 4F dec edi ; i--
:00425EF0 85FF test edi, edi
:00425EF2 7DE5 jge 00425ED9
内循环do...while
Width--;
#ifdef _using_short_int_
register const int ld = iPixelAdd + 2;
for (register int i = Height - 1; i >= 0; i--)
{
register int j = Width;
do
{
*ptrDest = ~*ptrDest;
ptrDest++;
*((unsigned short int *)ptrDest) = ~*((unsigned short int *)ptrDest);
ptrDest += ld;
j--;
}while(j >= 0);
ptrDest += iLineAdd;
}
汇编代码
:00425E98 4A dec edx ; Width--
:00425E99 8D7B02 lea edi, dword ptr [ebx+02]
:00425E9C 81C223010000 add edx, 00000123
:00425EA2 8D71FF lea esi, dword ptr [ecx-01]
:00425EA5 85F6 test esi, esi ; esi = i
:00425EA7 7C17 jl 00425EC0
:00425EA9 8BCA mov ecx, edx ; j = Width
:00425EAB F610 not byte ptr [eax] ; *ptrDest = ~*ptrDest
:00425EAD 40 inc eax ; ptrDest++
:00425EAE 66F710 not word ptr [eax]
:00425EB1 03C7 add eax, edi ; ptrDest += ld
:00425EB3 49 dec ecx ; j--
:00425EB4 85C9 test ecx, ecx
:00425EB6 7DF3 jge 00425EAB
:00425EB8 03450C add eax, dword ptr [ebp+0C] ; ptrDest += iLineAdd
:00425EBB 4E dec esi ; i--
:00425EBC 85F6 test esi, esi
:00425EBE 7DE9 jge 00425EA9