diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-06-05 08:58:51 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-06-05 10:23:38 +0200 |
| commit | 42670c0130172da006357ba0f455a2a209bdebf8 (patch) | |
| tree | 111b87553a9f4648e47115ef8142c6721ca61b1a /src/emu | |
| parent | f4c15979db68706b96380b2e827210b3d178a702 (diff) | |
| download | box64-42670c0130172da006357ba0f455a2a209bdebf8.tar.gz box64-42670c0130172da006357ba0f455a2a209bdebf8.zip | |
Fixed BT/BTC/BTR/BTS opcodes ([DYNAREC] too)
Diffstat (limited to 'src/emu')
| -rw-r--r-- | src/emu/x64run0f.c | 43 | ||||
| -rw-r--r-- | src/emu/x64run660f.c | 66 |
2 files changed, 67 insertions, 42 deletions
diff --git a/src/emu/x64run0f.c b/src/emu/x64run0f.c index 887ca31c..30c89c0b 100644 --- a/src/emu/x64run0f.c +++ b/src/emu/x64run0f.c @@ -712,19 +712,19 @@ int Run0F(x64emu_t *emu, rex_t rex) nextop = F8; GETED(0); GETGD; - tmp8u = GD->byte[0]; + tmp32s = GD->sdword[0]; + tmp8u=tmp32s&(rex.w?63:31); + tmp32s >>= (rex.w?6:5); if(!MODREG) { - ED=(reg64_t*)(((uint32_t*)(ED))+(tmp8u>>5)); + ED=(reg64_t*)(((uintptr_t)(ED))+(tmp32s<<(rex.w?3:2))); } if(rex.w) { - tmp8u&=63; if(ED->q[0] & (1LL<<tmp8u)) SET_FLAG(F_CF); else CLEAR_FLAG(F_CF); } else { - tmp8u&=31; if(ED->dword[0] & (1<<tmp8u)) SET_FLAG(F_CF); else @@ -755,13 +755,14 @@ int Run0F(x64emu_t *emu, rex_t rex) nextop = F8; GETED(0); GETGD; - tmp8u = GD->byte[0]; + tmp32s = GD->sdword[0]; + tmp8u=tmp32s&(rex.w?63:31); + tmp32s >>= (rex.w?6:5); if(!MODREG) { - ED=(reg64_t*)(((uint32_t*)(ED))+(tmp8u>>5)); + ED=(reg64_t*)(((uintptr_t)(ED))+(tmp32s<<(rex.w?3:2))); } if(rex.w) { - tmp8u&=63; if(ED->q[0] & (1LL<<tmp8u)) SET_FLAG(F_CF); else { @@ -769,7 +770,6 @@ int Run0F(x64emu_t *emu, rex_t rex) CLEAR_FLAG(F_CF); } } else { - tmp8u&=31; if(ED->dword[0] & (1<<tmp8u)) SET_FLAG(F_CF); else { @@ -882,20 +882,20 @@ int Run0F(x64emu_t *emu, rex_t rex) nextop = F8; GETED(0); GETGD; - tmp8u = GD->byte[0]; + tmp32s = GD->sdword[0]; + tmp8u=tmp32s&(rex.w?63:31); + tmp32s >>= (rex.w?6:5); if(!MODREG) { - ED=(reg64_t*)(((uint32_t*)(ED))+(tmp8u>>5)); + ED=(reg64_t*)(((uintptr_t)(ED))+(tmp32s<<(rex.w?3:2))); } if(rex.w) { - tmp8u&=63; if(ED->q[0] & (1LL<<tmp8u)) { SET_FLAG(F_CF); ED->q[0] ^= (1LL<<tmp8u); } else CLEAR_FLAG(F_CF); } else { - tmp8u&=31; if(ED->dword[0] & (1<<tmp8u)) { SET_FLAG(F_CF); ED->dword[0] ^= (1<<tmp8u); @@ -926,8 +926,6 @@ int Run0F(x64emu_t *emu, rex_t rex) CHECK_FLAGS(emu); GETED(1); tmp8u = F8; - if(!MODREG) - ED=(reg64_t*)(((uintptr_t*)(ED))+(tmp8u>>5)); if(rex.w) { tmp8u&=63; if(ED->q[0] & (1LL<<tmp8u)) @@ -946,8 +944,6 @@ int Run0F(x64emu_t *emu, rex_t rex) CHECK_FLAGS(emu); GETED(1); tmp8u = F8; - if(!MODREG) - ED=(reg64_t*)(((uintptr_t*)(ED))+(tmp8u>>5)); if(rex.w) { tmp8u&=63; if(ED->q[0] & (1LL<<tmp8u)) { @@ -970,8 +966,6 @@ int Run0F(x64emu_t *emu, rex_t rex) CHECK_FLAGS(emu); GETED(1); tmp8u = F8; - if(!MODREG) - ED=(reg64_t*)(((uintptr_t*)(ED))+(tmp8u>>5)); if(rex.w) { tmp8u&=63; if(ED->q[0] & (1LL<<tmp8u)) { @@ -992,8 +986,6 @@ int Run0F(x64emu_t *emu, rex_t rex) CHECK_FLAGS(emu); GETED(1); tmp8u = F8; - if(!MODREG) - ED=(reg64_t*)(((uintptr_t*)(ED))+(tmp8u>>5)); if(rex.w) { tmp8u&=63; if(ED->q[0] & (1LL<<tmp8u)) @@ -1020,23 +1012,20 @@ int Run0F(x64emu_t *emu, rex_t rex) nextop = F8; GETED(0); GETGD; - tmp8u = GD->byte[0]; + tmp32s = GD->sdword[0]; + tmp8u=tmp32s&(rex.w?63:31); + tmp32s >>= (rex.w?6:5); if(!MODREG) { - if(rex.w) - ED=(reg64_t*)(((uint64_t*)(ED))+(tmp8u>>6)); - else - ED=(reg64_t*)(((uint32_t*)(ED))+(tmp8u>>5)); + ED=(reg64_t*)(((uintptr_t)(ED))+(tmp32s<<(rex.w?3:2))); } if(rex.w) { - tmp8u&=63; if(ED->q[0] & (1LL<<tmp8u)) SET_FLAG(F_CF); else CLEAR_FLAG(F_CF); ED->q[0] ^= (1LL<<tmp8u); } else { - tmp8u&=31; if(ED->dword[0] & (1<<tmp8u)) SET_FLAG(F_CF); else diff --git a/src/emu/x64run660f.c b/src/emu/x64run660f.c index 9b23c1f2..be9b29ca 100644 --- a/src/emu/x64run660f.c +++ b/src/emu/x64run660f.c @@ -756,13 +756,20 @@ int Run660F(x64emu_t *emu, rex_t rex) nextop = F8; GETEW(0); GETGW; + tmp32s = rex.w?GW->sdword[0]:GW->sword[0]; + tmp8u=tmp32s&(rex.w?63:15); + tmp32s >>= (rex.w?6:4); + if(!MODREG) + { + EW=(reg64_t*)(((uintptr_t)(EW))+(tmp32s<<(rex.w?3:1))); + } if(rex.w) { - if(EW->q[0] & (1LL<<(GW->q[0]&63))) + if(EW->q[0] & (1LL<<tmp8u)) SET_FLAG(F_CF); else CLEAR_FLAG(F_CF); } else { - if(EW->word[0] & (1<<(GW->word[0]&15))) + if(EW->word[0] & (1<<tmp8u)) SET_FLAG(F_CF); else CLEAR_FLAG(F_CF); @@ -788,18 +795,25 @@ int Run660F(x64emu_t *emu, rex_t rex) nextop = F8; GETEW(0); GETGW; + tmp32s = rex.w?GW->sdword[0]:GW->sword[0]; + tmp8u=tmp32s&(rex.w?63:15); + tmp32s >>= (rex.w?6:4); + if(!MODREG) + { + EW=(reg64_t*)(((uintptr_t)(EW))+(tmp32s<<(rex.w?3:1))); + } if(rex.w) { - if(EW->q[0] & (1LL<<(GW->q[0]&63))) + if(EW->q[0] & (1LL<<tmp8u)) SET_FLAG(F_CF); else { - EW->q[0] |= (1LL<<(GW->q[0]&63)); + EW->q[0] |= (1LL<<tmp8u); CLEAR_FLAG(F_CF); } } else { - if(EW->word[0] & (1<<(GW->word[0]&15))) + if(EW->word[0] & (1<<tmp8u)) SET_FLAG(F_CF); else { - EW->word[0] |= (1<<(GW->word[0]&15)); + EW->word[0] |= (1<<tmp8u); CLEAR_FLAG(F_CF); } } @@ -855,16 +869,23 @@ int Run660F(x64emu_t *emu, rex_t rex) nextop = F8; GETEW(0); GETGW; + tmp32s = rex.w?GW->sdword[0]:GW->sword[0]; + tmp8u=tmp32s&(rex.w?63:15); + tmp32s >>= (rex.w?6:4); + if(!MODREG) + { + EW=(reg64_t*)(((uintptr_t)(EW))+(tmp32s<<(rex.w?3:1))); + } if(rex.w) { - if(EW->q[0] & (1LL<<(GW->q[0]&63))) { + if(EW->q[0] & (1LL<<tmp8u)) { SET_FLAG(F_CF); - EW->q[0] ^= (1LL<<(GW->q[0]&63)); + EW->q[0] ^= (1LL<<tmp8u); } else CLEAR_FLAG(F_CF); } else { - if(EW->word[0] & (1<<(GW->word[0]&15))) { + if(EW->word[0] & (1<<tmp8u)) { SET_FLAG(F_CF); - EW->word[0] ^= (1<<(GW->word[0]&15)); + EW->word[0] ^= (1<<tmp8u); } else CLEAR_FLAG(F_CF); } @@ -882,11 +903,26 @@ int Run660F(x64emu_t *emu, rex_t rex) nextop = F8; GETEW(0); GETGW; - if(EW->word[0] & (1<<(GW->word[0]&15))) - SET_FLAG(F_CF); - else - CLEAR_FLAG(F_CF); - EW->word[0] ^= (1<<(GW->word[0]&15)); + tmp32s = rex.w?GW->sdword[0]:GW->sword[0]; + tmp8u=tmp32s&(rex.w?63:15); + tmp32s >>= (rex.w?6:4); + if(!MODREG) + { + EW=(reg64_t*)(((uintptr_t)(EW))+(tmp32s<<(rex.w?3:1))); + } + if(rex.w) { + if(EW->q[0] & (1LL<<tmp8u)) + SET_FLAG(F_CF); + else + CLEAR_FLAG(F_CF); + EW->q[0] ^= (1LL<<tmp8u); + } else { + if(EW->word[0] & (1<<tmp8u)) + SET_FLAG(F_CF); + else + CLEAR_FLAG(F_CF); + EW->word[0] ^= (1<<tmp8u); + } break; case 0xBC: /* BSF Ew,Gw */ CHECK_FLAGS(emu); |