diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-04-04 11:28:21 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-04-04 11:28:21 +0200 |
| commit | 998a114172569ab441a3aa833f9164bb64244bff (patch) | |
| tree | 28f4be48fda74a43b6603b3247ace82d6d336579 /src | |
| parent | 29f65bb6beff6457db6f00315c1395f944ec93ed (diff) | |
| download | box64-998a114172569ab441a3aa833f9164bb64244bff.tar.gz box64-998a114172569ab441a3aa833f9164bb64244bff.zip | |
Added some more 67 opcodes (may need to find a better solution for this)
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/modrm.h | 1 | ||||
| -rw-r--r-- | src/emu/x64run67.c | 67 | ||||
| -rwxr-xr-x | src/emu/x64run_private.c | 13 | ||||
| -rwxr-xr-x | src/emu/x64run_private.h | 1 |
4 files changed, 81 insertions, 1 deletions
diff --git a/src/emu/modrm.h b/src/emu/modrm.h index cf4a2039..f2a5029e 100644 --- a/src/emu/modrm.h +++ b/src/emu/modrm.h @@ -18,6 +18,7 @@ #define GETED_OFFS(D, O) oped=GetEdO(emu, rex, nextop, D, O) #define GETGD opgd=GetGd(emu, rex, nextop) #define GETEB(D) oped=GetEb(emu, rex, nextop, D) +#define GETEB32(D) oped=GetEb32O(emu, rex, nextop, D, 0) #define GETEB_OFFS(D, O) oped=GetEbO(emu, rex, nextop, D, O) #define GETGB opgd=GetGb(emu, rex, nextop) #define GETEW(D) oped=GetEw(emu, rex, nextop, D) diff --git a/src/emu/x64run67.c b/src/emu/x64run67.c index c5a1f221..10af9a5b 100644 --- a/src/emu/x64run67.c +++ b/src/emu/x64run67.c @@ -42,7 +42,66 @@ int Run67(x64emu_t *emu, rex_t rex) } switch(opcode) { + #define GO(B, OP) \ + case B+0: \ + nextop = F8; \ + GETEB32(0); \ + GETGB; \ + EB->byte[0] = OP##8(emu, EB->byte[0], GB); \ + break; \ + case B+1: \ + nextop = F8; \ + GETED32(0); \ + GETGD; \ + if(rex.w) \ + ED->q[0] = OP##64(emu, ED->q[0], GD->q[0]); \ + else { \ + if(MODREG) \ + ED->q[0] = OP##32(emu, ED->dword[0], GD->dword[0]); \ + else \ + ED->dword[0] = OP##32(emu, ED->dword[0], GD->dword[0]); \ + } \ + break; \ + case B+2: \ + nextop = F8; \ + GETEB32(0); \ + GETGB; \ + GB = OP##8(emu, GB, EB->byte[0]); \ + break; \ + case B+3: \ + nextop = F8; \ + GETED32(0); \ + GETGD; \ + if(rex.w) \ + GD->q[0] = OP##64(emu, GD->q[0], ED->q[0]); \ + else \ + GD->q[0] = OP##32(emu, GD->dword[0], ED->dword[0]); \ + break; \ + case B+4: \ + R_AL = OP##8(emu, R_AL, F8); \ + break; \ + case B+5: \ + if(rex.w) \ + R_RAX = OP##64(emu, R_RAX, F32S64); \ + else \ + R_RAX = OP##32(emu, R_EAX, F32); \ + break; + + GO(0x00, add) /* ADD 0x00 -> 0x05 */ + GO(0x08, or) /* OR 0x08 -> 0x0D */ + GO(0x10, adc) /* ADC 0x10 -> 0x15 */ + GO(0x18, sbb) /* SBB 0x18 -> 0x1D */ + GO(0x20, and) /* AND 0x20 -> 0x25 */ + GO(0x28, sub) /* SUB 0x28 -> 0x2D */ + GO(0x30, xor) /* XOR 0x30 -> 0x35 */ + #undef GO + case 0x88: /* MOV Eb,Gb */ + nextop = F8; + GETEB32(0); + GETGB; + EB->byte[0] = GB; + break; case 0x89: /* MOV Ed,Gd */ nextop = F8; GETED32(0); @@ -57,6 +116,12 @@ int Run67(x64emu_t *emu, rex_t rex) ED->dword[0] = GD->dword[0]; } break; + case 0x8A: /* MOV Gb,Eb */ + nextop = F8; + GETEB32(0); + GETGB; + GB = EB->byte[0]; + break; case 0x8D: /* LEA Gd,M */ nextop = F8; @@ -138,7 +203,7 @@ int Run67(x64emu_t *emu, rex_t rex) case 0xF7: /* GRP3 Ed(,Id) */ nextop = F8; tmp8u = (nextop>>3)&7; - GETED((tmp8u<2)?4:0); + GETED32((tmp8u<2)?4:0); if(rex.w) { switch(tmp8u) { case 0: diff --git a/src/emu/x64run_private.c b/src/emu/x64run_private.c index d9fcabfb..84cdea47 100755 --- a/src/emu/x64run_private.c +++ b/src/emu/x64run_private.c @@ -1162,6 +1162,19 @@ reg64_t* GetEd32O(x64emu_t *emu, rex_t rex, uint8_t v, uint8_t delta, uintptr_t } else return GetECommon32O(emu, rex, m, delta, offset); } +reg64_t* GetEb32O(x64emu_t *emu, rex_t rex, uint8_t v, uint8_t delta, uintptr_t offset) +{ + uint8_t m = v&0xC7; // filter Eb + if(m>=0xC0) { + if(rex.rex) { + return &emu->regs[(m&0x07)+(rex.b<<3)]; + } else { + int lowhigh = (m&4)>>2; + return (reg64_t *)(((char*)(&emu->regs[(m&0x03)]))+lowhigh); //? + } + } else return GetECommon32O(emu, rex, m, delta, offset); +} + #define GetEw GetEd reg64_t* GetEw16(x64emu_t *emu, rex_t rex, uint8_t v) diff --git a/src/emu/x64run_private.h b/src/emu/x64run_private.h index 49b8ff1a..358a972e 100755 --- a/src/emu/x64run_private.h +++ b/src/emu/x64run_private.h @@ -81,6 +81,7 @@ reg64_t* GetEbO(x64emu_t *emu, rex_t rex, uint8_t v, uint8_t delta, uintptr_t of reg64_t* GetEd(x64emu_t *emu, rex_t rex, uint8_t v, uint8_t delta); reg64_t* GetEdO(x64emu_t *emu, rex_t rex, uint8_t v, uint8_t delta, uintptr_t offset); reg64_t* GetEd32O(x64emu_t *emu, rex_t rex, uint8_t v, uint8_t delta, uintptr_t offset); +reg64_t* GetEb32O(x64emu_t *emu, rex_t rex, uint8_t v, uint8_t delta, uintptr_t offset); #define GetEw GetEd reg64_t* GetEw16(x64emu_t *emu, rex_t rex, uint8_t v); reg64_t* GetEw16off(x64emu_t *emu, rex_t rex, uint8_t v, uintptr_t offset); |