From 30f0f3a5a17a68a2b294cb998bd8ee5582f5cf58 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 6 Jun 2021 11:27:49 +0200 Subject: Small fixes to interpretor --- src/dynarec/arm64_lock.S | 3 --- src/emu/x64primop.h | 2 +- src/emu/x64run.c | 25 +++++++++++-------------- src/emu/x64runf0.c | 11 +++++++++-- 4 files changed, 21 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/dynarec/arm64_lock.S b/src/dynarec/arm64_lock.S index 72a15f48..0e2e2958 100755 --- a/src/dynarec/arm64_lock.S +++ b/src/dynarec/arm64_lock.S @@ -45,15 +45,12 @@ arm64_lock_write_h: arm64_lock_read_d: // address is x0, return is x0 ldaxr w0, [x0] - #ldx w0,[x0] ret arm64_lock_write_d: // address is x0, value is w1, return is x0 mov x2, x0 stlxr w0, w1, [x2] - #str w1, [x2] - mov w0, 0 ret arm64_lock_read_dd: diff --git a/src/emu/x64primop.h b/src/emu/x64primop.h index ae2f9a02..f8152277 100755 --- a/src/emu/x64primop.h +++ b/src/emu/x64primop.h @@ -592,7 +592,7 @@ static inline void mul32_eax(x64emu_t *emu, uint32_t s) static inline void mul64_rax(x64emu_t *emu, uint64_t s) { emu->df = d_mul64; - __int128 res = (__int128)R_RAX * s; + unsigned __int128 res = (unsigned __int128)R_RAX * s; emu->res.u64 = R_RAX = (uint64_t)res; emu->op1.u64 = R_RDX = (uint64_t)(res >> 64); } diff --git a/src/emu/x64run.c b/src/emu/x64run.c index 1ff55ec0..d56b3aa2 100755 --- a/src/emu/x64run.c +++ b/src/emu/x64run.c @@ -236,7 +236,7 @@ x64emurun: GD->sq[0] = ED->sdword[0]; else if(MODREG) - GD->q[0] = ED->sdword[0]; + GD->q[0] = ED->dword[0]; // not really a sign extension else GD->sdword[0] = ED->sdword[0]; // meh? break; @@ -276,10 +276,7 @@ x64emurun: if(rex.w) GD->q[0] = imul64(emu, ED->q[0], tmp64u); else - if((nextop&0xC0)==0xC0) - GD->q[0] = imul32(emu, ED->dword[0], tmp64u); - else - GD->dword[0] = imul32(emu, ED->dword[0], tmp64u); + GD->q[0] = imul32(emu, ED->dword[0], tmp64u); break; case 0x6A: /* Push Ib */ tmp64s = F8S; @@ -385,7 +382,7 @@ x64emurun: #ifdef DYNAREC GETEB(0); GETGB; - if((nextop&0xC0)==0xC0) { // reg / reg: no lock + if(MODREG) { // reg / reg: no lock tmp8u = GB; GB = EB->byte[0]; EB->byte[0] = tmp8u; @@ -399,12 +396,12 @@ x64emurun: #else GETEB(0); GETGB; - if((nextop&0xC0)!=0xC0) + if(!MODREG) pthread_mutex_lock(&emu->context->mutex_lock); // XCHG always LOCK (but when accessing memory only) tmp8u = GB; GB = EB->byte[0]; EB->byte[0] = tmp8u; - if((nextop&0xC0)!=0xC0) + if(!MODREG) pthread_mutex_unlock(&emu->context->mutex_lock); #endif break; @@ -413,7 +410,7 @@ x64emurun: #ifdef DYNAREC GETED(0); GETGD; - if((nextop&0xC0)==0xC0) { + if(MODREG) { if(rex.w) { tmp64u = GD->q[0]; GD->q[0] = ED->q[0]; @@ -560,6 +557,7 @@ x64emurun: RESET_FLAGS(emu); break; case 0x9E: /* SAHF */ + CHECK_FLAGS(emu); tmp8u = emu->regs[_AX].byte[1]; CONDITIONAL_SET_FLAG(tmp8u&0x01, F_CF); CONDITIONAL_SET_FLAG(tmp8u&0x04, F_PF); @@ -1317,13 +1315,13 @@ x64emurun: break; case 6: /* DIV Ed */ div32(emu, ED->dword[0]); - emu->regs[_AX].dword[1] = 0; - emu->regs[_DX].dword[1] = 0; + //emu->regs[_AX].dword[1] = 0; // already put high regs to 0 + //emu->regs[_DX].dword[1] = 0; break; case 7: /* IDIV Ed */ idiv32(emu, ED->dword[0]); - emu->regs[_AX].dword[1] = 0; - emu->regs[_DX].dword[1] = 0; + //emu->regs[_AX].dword[1] = 0; + //emu->regs[_DX].dword[1] = 0; break; } } @@ -1422,7 +1420,6 @@ x64emurun: } else { R_RIP = ED->q[0]; R_CS = (ED+1)->word[0]; - STEP goto fini; // exit loop to recompute CS... } break; diff --git a/src/emu/x64runf0.c b/src/emu/x64runf0.c index 34b73da9..4a3a4763 100644 --- a/src/emu/x64runf0.c +++ b/src/emu/x64runf0.c @@ -313,11 +313,13 @@ int RunF0(x64emu_t *emu, rex_t rex) if(ACCESS_FLAG(F_ZF)) { tmp32s = arm64_lock_write_d(ED, GD->dword[0]); } else { - R_RAX = tmp32u; + R_EAX = tmp32u; tmp32s = 0; } } while(tmp32s); emu->regs[_AX].dword[1] = 0; + if(MODREG) + ED->dword[1] = 0; } #else pthread_mutex_lock(&emu->context->mutex_lock); @@ -336,6 +338,8 @@ int RunF0(x64emu_t *emu, rex_t rex) R_EAX = ED->dword[0]; } emu->regs[_AX].dword[1] = 0; + if(MODREG) + ED->dword[1] = 0; } pthread_mutex_unlock(&emu->context->mutex_lock); #endif @@ -365,7 +369,7 @@ int RunF0(x64emu_t *emu, rex_t rex) tmp32s = 0; } } while(tmp32s); - else + else { do { tmp32u = arm64_lock_read_d(ED); if(tmp32u & (1<dword[1] = 0; + } #else pthread_mutex_lock(&emu->context->mutex_lock); if(rex.w) { -- cgit 1.4.1