#include #include #include BYTE src1[640*480]; BYTE src2[640*480]; BYTE dst1[640*480]; BYTE dst2[640*480]; void main(void) { int i, j; srand(timeGetTime( )); for(i = 0; i < 640*480/4; i ++) { int t = rand( ) & 0x0f; DWORD masktmp[16] = { 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff, 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff }; DWORD tmp = rand( ); tmp &= masktmp[t]; for(j = 0; j < 4; j ++) { dst1[i*4+j] = src1[i*4+j] = (BYTE)(tmp & 0xff); tmp >>= 8; } } for(i = 0; i < 640*480; i ++) src2[i] = (BYTE)(rand( ) & 0xff); for(i = 0; i < 640*480; i ++) dst2[i] = (src1[i] == 0) ? src2[i] : src1[i]; DWORD srcAddress = (DWORD)src1; DWORD dstAddress = (DWORD)dst1; DWORD spr = (DWORD)dst1; DWORD bak = (DWORD)src2; _asm { mov ecx, 640*480/4 mov edx, spr mov ebx, bak shr ecx, 1 sub edx, 8 LP: mov eax, [edx + 8] add edx, 8 // 2 mov edi, [edx + 4] and eax, 0x7f7f7f7f // 3 and edi, 0x7f7f7f7f add eax, 0x7f7f7f7f // 4 add edi, 0x7f7f7f7f mov esi, [edx] // 5 or eax, esi mov esi, [edx + 4] // 6 or edi, esi and eax, 0x80808080 // 7 shr eax, 7 and edi, 0x80808080 // 8 shr edi, 7 add eax, 0x7f7f7f7f // 9 xor eax, 0x80808080 mov esi, [ebx] // 10 and eax, esi mov esi, [edx] // 11 or eax, esi add edi, 0x7f7f7f7f // 12 xor edi, 0x80808080 mov esi, [ebx+4] // 13 and edi, esi mov esi, [edx+4] // 14 or edi, esi mov [edx], eax // 15 mov [edx+4], edi add ebx, 8 // 16 dec ecx jnz short LP } DWORD *pt1 = (DWORD*)src1; DWORD *pt2 = (DWORD*)src2; DWORD *pt3 = (DWORD*)dst1; DWORD *pt4 = (DWORD*)dst2; for(i = 0; i < 640*480/4; i ++) { if(*pt3 != *pt4) printf("%8x:%8x -> %8x %8x\n", *pt1, *pt2, *pt3, *pt4); pt1 ++; pt2 ++; pt3 ++; pt4 ++; } }