Some fixes to PCMP[E/I]STRM opcodes

This commit is contained in:
ptitSeb 2024-05-19 17:57:35 +02:00
parent 4f21d83e62
commit fb1dbb3821
2 changed files with 16 additions and 9 deletions

View File

@ -81,8 +81,15 @@ uint32_t sse42_compare_string_explicit_len(x86emu_t* emu, sse_regs_t* mem, int l
intres1 = (1<<n_packed)-1;
for(int j=0; j<n_packed; ++j)
for(int i=0; i<n_packed-j; ++i) {
#if 1
if(!overrideIfDataInvalid(mem, lmem, reg, lreg, i+j, i, imm8)) {
intres1 &= ~(1<<j);
break;
}
#else
int k = i+j;
intres1 &= (((1<<n_packed)-1)^(1<<j)) | overrideIfDataInvalid(mem, lmem, reg, lreg, k, i, imm8)<<j;
#endif
}
break;
}
@ -98,7 +105,7 @@ uint32_t sse42_compare_string_explicit_len(x86emu_t* emu, sse_regs_t* mem, int l
CONDITIONAL_SET_FLAG(lmem<n_packed, F_ZF);
CONDITIONAL_SET_FLAG(lreg<n_packed, F_SF);
CONDITIONAL_SET_FLAG(intres2&1, F_OF);
CLEAR_FLAG(F_AF);
CONDITIONAL_SET_FLAG(((!intres2) && (lmem==n_packed)), F_AF);
CLEAR_FLAG(F_PF);
return intres2;

View File

@ -1101,12 +1101,12 @@ uintptr_t Run660F(x86emu_t *emu, uintptr_t addr)
tmp32u = sse42_compare_string_explicit_len(emu, EX, R_EDX, &GX, R_EAX, tmp8u);
if(tmp8u&0b1000000) {
switch(tmp8u&1) {
case 0: for(int i=0; i<16; ++i) GX.ub[i] = ((tmp32u>>i)&1)?0xff:0x00; break;
case 1: for(int i=0; i<8; ++i) GX.uw[i] = ((tmp32u>>i)&1)?0xffff:0x0000; break;
case 0: for(int i=0; i<16; ++i) emu->xmm[0].ub[i] = ((tmp32u>>i)&1)?0xff:0x00; break;
case 1: for(int i=0; i<8; ++i) emu->xmm[0].uw[i] = ((tmp32u>>i)&1)?0xffff:0x0000; break;
}
} else {
GX.q[1] = GX.q[0] = 0;
GX.uw[0] = tmp32u;
emu->xmm[0].q[1] = emu->xmm[0].q[0] = 0;
emu->xmm[0].uw[0] = tmp32u;
}
break;
case 0x61: /* PCMPESTRI */
@ -1128,12 +1128,12 @@ uintptr_t Run660F(x86emu_t *emu, uintptr_t addr)
tmp32u = sse42_compare_string_implicit_len(emu, EX, &GX, tmp8u);
if(tmp8u&0b1000000) {
switch(tmp8u&1) {
case 0: for(int i=0; i<16; ++i) GX.ub[i] = ((tmp32u>>i)&1)?0xff:0x00; break;
case 1: for(int i=0; i<8; ++i) GX.uw[i] = ((tmp32u>>i)&1)?0xffff:0x0000; break;
case 0: for(int i=0; i<16; ++i) emu->xmm[0].ub[i] = ((tmp32u>>i)&1)?0xff:0x00; break;
case 1: for(int i=0; i<8; ++i) emu->xmm[0].uw[i] = ((tmp32u>>i)&1)?0xffff:0x0000; break;
}
} else {
GX.q[1] = GX.q[0] = 0;
GX.uw[0] = tmp32u;
emu->xmm[0].q[1] = emu->xmm[0].q[0] = 0;
emu->xmm[0].uw[0] = tmp32u;
}
break;
case 0x63: /* PCMPISTRI */