minor fixes
[ia32rtools.git] / tests / ops.expect.c
CommitLineData
3947cf24 1int sub_test()
2{
3 u32 eax;
4 u32 ebx;
5 u32 ecx;
6 u32 edx;
7 u32 esi;
8 u32 edi;
7f20f633 9 u32 cond_c;
3947cf24 10 u32 cond_z;
622eb2ef 11 u64 tmp64;
3947cf24 12
13 ebx = 0x10000;
14 esi = 0x20000;
15 edi = 0x30000;
16 ecx = 0x0a;
17
18loop:
19 LOBYTE(eax) = *(u8 *)esi; esi += 1; // lods
20 LOBYTE(eax) = *(u8 *)(ebx + LOBYTE(eax)); // xlat
21 *(u8 *)edi = eax; edi += 1; // stos
22 LOWORD(eax) = *(u16 *)esi; esi += 2; // lods
23 LOWORD(eax) = -(s16)(u16)eax;
24 *(u16 *)edi = eax; edi += 2; // stos
25 eax = *(u32 *)esi; esi += 4; // lods
26 *(u32 *)edi = eax; edi += 4; // stos
27 *(u8 *)edi = *(u8 *)esi; edi += 1; esi += 1; // movs
28 cond_z = (*(u16 *)esi == *(u16 *)edi); esi += 2; edi += 2; // cmps
29 cond_z = ((u8)eax == *(u8 *)edi); edi += 1; // scas
30 if (--ecx != 0)
31 goto loop; // loop
32 *(u8 *)edi = eax; edi -= 1; // stos
33 *(u16 *)edi = eax; edi -= 2; // stos
34 *(u32 *)edi = eax; edi -= 4; // stos
35 edx = (s32)eax >> 31; // cdq
f9327ad4 36 if (ecx) eax = __builtin_ffs(ecx) - 1; // bsf
622eb2ef 37 tmp64 = ((u64)edx << 32) | eax;
8c83cc48 38 tmp64 = (s64)tmp64 << LOBYTE(ecx);
622eb2ef 39 edx = tmp64 >> 32; eax = tmp64; // allshl
7f20f633 40 edi = eax;
622eb2ef 41 tmp64 = ((u64)edx << 32) | eax;
8c83cc48 42 tmp64 = (s64)tmp64 >> LOBYTE(ecx);
622eb2ef 43 edx = tmp64 >> 32; eax = tmp64; // allshr
44 eax = __builtin_bswap32(eax);
7f20f633 45 ecx ^= eax;
46 tmp64 = (u64)eax + ecx;
47 cond_c = tmp64 >> 32;
48 eax = (u32)tmp64;
49 cond_z = (eax == 0); // add64
50 while (ecx != 0) {
51 cond_c = *(u8 *)esi < *(u8 *)edi;
52 cond_z = (*(u8 *)esi == *(u8 *)edi); esi += 1, edi += 1;
53 ecx--;
54 if (cond_z != 0) break;
55 } // repne cmps
56 LOBYTE(ecx) = (!cond_z);
57 LOBYTE(ecx) += (u8)ecx + cond_c;
3947cf24 58 eax = 1;
59 return eax;
60}
61