8000 [LA64_DYNAREC] Added more opcodes and some fixes too by ksco · Pull Request #1528 · ptitSeb/box64 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[LA64_DYNAREC] Added more opcodes and some fixes too #1528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files. 8000
Loading
Diff view
Diff view
54 changes: 49 additions & 5 deletions src/dynarec/la64/dynarec_la64_00.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
DEFAULT;
}
break;
case 0x18:
INST_NAME("SBB Eb, Gb");
READFLAGS(X_CF);
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETEB(x1, 0);
GETGB(x2);
emit_sbb8(dyn, ninst, x1, x2, x4, x5, x6);
EBBACK();
break;
case 0x19:
INST_NAME("SBB Ed, Gd");
READFLAGS(X_CF);
Expand Down Expand Up @@ -321,6 +331,14 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
GETED(0);
emit_xor32(dyn, ninst, rex, gd, ed, x3, x4);
break;
case 0x34:
INST_NAME("XOR AL, Ib");
SETFLAGS(X_ALL, SF_SET_PENDING);
u8 = F8;
ANDI(x1, xRAX, 0xff);
emit_xor8c(dyn, ninst, x1, u8, x3, x4);
BSTRINS_D(xRAX, x1, 7, 0);
break;
case 0x35:
INST_NAME("XOR EAX, Id");
SETFLAGS(X_ALL, SF_SET_PENDING);
Expand Down Expand Up @@ -2052,6 +2070,35 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
DEFAULT;
}
break;
case 0xFC:
INST_NAME("CLD");
BSTRINS_D(xFlags, xZR, F_DF, F_DF);
break;
case 0xFD:
INST_NAME("STD");
ORI(xFlags, xFlags, 1 << F_DF);
break;
case 0xFE:
nextop = F8;
switch ((nextop >> 3) & 7) {
case 0:
INST_NAME("INC Eb");
SETFLAGS(X_ALL & ~X_CF, SF_SUBSET_PENDING);
GETEB(x1, 0);
emit_inc8(dyn, ninst, ed, x2, x4, x5);
EBBACK();
break;
case 1:
INST_NAME("DEC Eb");
SETFLAGS(X_ALL & ~X_CF, SF_SUBSET_PENDING);
GETEB(x1, 0);
emit_dec8(dyn, ninst, ed, x2, x4, x5);
EBBACK();
break;
default:
DEFAULT;
}
break;
case 0xFF:
nextop = F8;
switch ((nextop >> 3) & 7) {
Expand All @@ -2071,12 +2118,9 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
break;
case 2:
INST_NAME("CALL Ed");
PASS2IF((box64_dynarec_safeflags > 1) || ((ninst && dyn->insts[ninst - 1].x64.set_flags) || ((ninst > 1) && dyn->insts[ninst - 2].x64.set_flags)), 1)
{
PASS2IF ((box64_dynarec_safeflags > 1) || ((ninst && dyn->insts[ninst - 1].x64.set_flags) || ((ninst > 1) && dyn->insts[ninst - 2].x64.set_flags)), 1) {
READFLAGS(X_PEND); // that's suspicious
}
else
{
} else {
SETFLAGS(X_ALL, SF_SET); // Hack to put flag in "don't care" state
}
GETEDz(0);
Expand Down
31 changes: 31 additions & 0 deletions src/dynarec/la64/dynarec_la64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,27 @@ uintptr_t dynarec64_0F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
GETGX(q1, 1);
VFCVTL_D_S(q1, q0);
break;
case 0x5B:
INST_NAME("CVTDQ2PS Gx, Ex");
nextop = F8;
GETEX(q0, 0, 0);
GETGX_empty(q1);
VFFINT_S_W(q1, q0);
break;
case 0x5C:
INST_NAME("SUBPS Gx, Ex");
nextop = F8;
GETEX(q0, 0, 0);
GETGX(v0, 1);
VFSUB_S(v0, v0, q0);
break;
case 0x5E:
INST_NAME("DIVPS Gx, Ex");
nextop = F8;
GETEX(q0, 0, 0);
GETGX(v0, 1);
VFDIV_S(v0, v0, q0);
break;

#define GO(GETFLAGS, NO, YES, F, I) \
if (box64_dynarec_test == 2) { NOTEST(x1); } \
Expand Down Expand Up @@ -791,6 +805,23 @@ uintptr_t dynarec64_0F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
}
if (!rex.w) ZEROUP(gd);
break;
case 0xC2:
INST_NAME("CMPPS Gx, Ex, Ib");
nextop = F8;
GETGX(v0, 1);
GETEX(v1, 0, 1);
u8 = F8;
switch (u8 & 7) {
8000 case 0: VFCMP_D(v0, v0, v1, cEQ); break; // Equal
case 1: VFCMP_D(v0, v0, v1, cLT); break; // Less than
case 2: VFCMP_D(v0, v0, v1, cLE); break; // Less or equal
case 3: VFCMP_D(v0, v0, v1, cUN); break; // NaN
case 4: VFCMP_D(v0, v0, v1, cUNE); break; // Not Equal or unordered
case 5: VFCMP_D(v0, v1, v0, cULE); break; // Greater or equal or unordered
case 6: VFCMP_D(v0, v1, v0, cULT); break; // Greater or unordered, test inverted, N!=V so unordered or less than (inverted)
case 7: VFCMP_D(v0, v0, v1, cOR); break; // not NaN
}
break;
case 0xC6:
INST_NAME("SHUFPS Gx, Ex, Ib");
nextop = F8;
Expand Down
37 changes: 37 additions & 0 deletions src/dynarec/la64/dynarec_la64_66.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,22 @@ uintptr_t dynarec64_66(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
SMWRITELOCK(lock);
}
break;
case 0x8B:
INST_NAME("MOV Gw, Ew");
nextop = F8;
GETGD;
if (MODREG) {
ed = TO_LA64((nextop & 7) + (rex.b << 3));
if (ed != gd) {
BSTRINS_D(gd, ed, 15, 0);
}
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x2, x1, &fixedaddress, rex, &lock, 1, 0);
SMREADLOCK(lock);
LD_HU(x1, ed, fixedaddress);
BSTRINS_D(gd, x1, 15, 0);
}
break;
case 0x90:
case 0x91:
case 0x92:
Expand Down Expand Up @@ -528,6 +544,27 @@ uintptr_t dynarec64_66(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
DEFAULT;
}
break;
case 0xFF:
nextop = F8;
switch ((nextop >> 3) & 7) {
case 0:
INST_NAME("INC Ew");
SETFLAGS(X_ALL & ~X_CF, SF_SUBSET_PENDING);
GETEW(x1, 0);
emit_inc16(dyn, ninst, x1, x2, x4, x5);
EWBACK;
break;
case 1:
INST_NAME("DEC Ew");
SETFLAGS(X_ALL & ~X_CF, SF_SUBSET_PENDING);
GETEW(x1, 0);
emit_dec16(dyn, ninst, x1, x2, x4, x5, x6);
EWBACK;
break;
default:
DEFAULT;
}
break;
default:
DEFAULT;
}
Expand Down
45 changes: 45 additions & 0 deletions src/dynarec/la64/dynarec_la64_660f.c
5D39
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ uintptr_t dynarec64_660F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int
MAYUSE(j64);

switch (opcode) {
case 0x12:
INST_NAME("MOVLPD Gx, Eq");
nextop = F8;
GETGX(v0, 1);
if (MODREG) {
DEFAULT;
return addr;
}
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x2, x3, &fixedaddress, rex, NULL, 1, 0);
v1 = fpu_get_scratch(dyn);
FLD_D(v1, wback, fixedaddress);
VEXTRINS_D(v0, v1, 0);
break;
case 0x14:
INST_NAME("UNPCKLPD Gx, Ex");
nextop = F8;
Expand Down Expand Up @@ -86,6 +100,21 @@ uintptr_t dynarec64_660F(dynarec_la64_t* dyn, uintptr AE8F _t addr, uintptr_t ip, int
VLD(v0, ed, fixedaddress);
}
break;
case 0x29:
INST_NAME("MOVAPD Ex,Gx");
nextop = F8;
GETG;
v0 = sse_get_reg(dyn, ninst, x1, gd, 0);
if (MODREG) {
ed = (nextop & 7) + (rex.b << 3);
v1 = sse_get_reg_empty(dyn, ninst, x1, ed);
VOR_V(v1, v0, v0);
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x2, x3, &fixedaddress, rex, NULL, 1, 0);
VST(v0, ed, fixedaddress);
SMWRITE2();
}
break;
case 0x2E:
// no special check...
case 0x2F:
Expand Down Expand Up @@ -283,6 +312,14 @@ uintptr_t dynarec64_660F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int
VXOR_V(q0, q0, q1);
}
break;
case 0x58:
INST_NAME("ADDPD Gx, Ex");
nextop = F8;
GETEX(q0, 0, 0);
GETGX(q1, 1);
// TODO: fastnan handling
VFADD_D(q1, q1, q0);
break;
case 0x5A:
INST_NAME("CVTPD2PS Gx, Ex");
nextop = F8;
Expand All @@ -294,6 +331,14 @@ uintptr_t dynarec64_660F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int
VXOR_V(v0, v0, v0);
VEXTRINS_D(v0, q0, 0);
break;
case 0x5C:
INST_NAME("SUBPD Gx, Ex");
nextop = F8;
GETEX(q0, 0, 0);
GETGX(q1, 1);
// TODO: fastnan handling
VFSUB_D(q1, q1, q0);
break;
case 0x60:
INST_NAME("PUNPCKLBW Gx,Ex");
nextop = F8;
Expand Down
Loading
0