| 1 | int sub_test() |
| 2 | { |
| 3 | u32 eax; |
| 4 | u32 ebx; |
| 5 | u32 ecx; |
| 6 | u32 edx; |
| 7 | u32 esi; |
| 8 | u32 edi; |
| 9 | u32 cond_z; |
| 10 | |
| 11 | ebx = 0x10000; |
| 12 | esi = 0x20000; |
| 13 | edi = 0x30000; |
| 14 | ecx = 0x0a; |
| 15 | |
| 16 | loop: |
| 17 | LOBYTE(eax) = *(u8 *)esi; esi += 1; // lods |
| 18 | LOBYTE(eax) = *(u8 *)(ebx + LOBYTE(eax)); // xlat |
| 19 | *(u8 *)edi = eax; edi += 1; // stos |
| 20 | LOWORD(eax) = *(u16 *)esi; esi += 2; // lods |
| 21 | LOWORD(eax) = -(s16)(u16)eax; |
| 22 | *(u16 *)edi = eax; edi += 2; // stos |
| 23 | eax = *(u32 *)esi; esi += 4; // lods |
| 24 | *(u32 *)edi = eax; edi += 4; // stos |
| 25 | *(u8 *)edi = *(u8 *)esi; edi += 1; esi += 1; // movs |
| 26 | cond_z = (*(u16 *)esi == *(u16 *)edi); esi += 2; edi += 2; // cmps |
| 27 | cond_z = ((u8)eax == *(u8 *)edi); edi += 1; // scas |
| 28 | if (--ecx != 0) |
| 29 | goto loop; // loop |
| 30 | *(u8 *)edi = eax; edi -= 1; // stos |
| 31 | *(u16 *)edi = eax; edi -= 2; // stos |
| 32 | *(u32 *)edi = eax; edi -= 4; // stos |
| 33 | edx = (s32)eax >> 31; // cdq |
| 34 | eax = ecx ? __builtin_ffs(ecx) - 1 : 0; // bsf |
| 35 | eax = 1; |
| 36 | return eax; |
| 37 | } |
| 38 | |