diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/emu/x64run.c | 10 | ||||
| -rw-r--r-- | src/emu/x64run0f.c | 70 | ||||
| -rwxr-xr-x | src/main.c | 10 |
3 files changed, 87 insertions, 3 deletions
diff --git a/src/emu/x64run.c b/src/emu/x64run.c index 34502ca5..5d37c153 100755 --- a/src/emu/x64run.c +++ b/src/emu/x64run.c @@ -146,6 +146,16 @@ x64emurun: GO(0x30, xor) /* XOR 0x30 -> 0x35 */ #undef GO + case 0x0F: /* More instructions */ + if(Run0F(emu)) { + unimp = 1; + goto fini; + } + if(emu->quit) + goto fini; + break; + + case 0x40: case 0x41: case 0x42: diff --git a/src/emu/x64run0f.c b/src/emu/x64run0f.c new file mode 100644 index 00000000..07eab35e --- /dev/null +++ b/src/emu/x64run0f.c @@ -0,0 +1,70 @@ +#define _GNU_SOURCE +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> +#include <signal.h> +#include <sys/types.h> +#include <unistd.h> + +#include "debug.h" +#include "box64stack.h" +#include "x64emu.h" +#include "x64run.h" +#include "x64emu_private.h" +#include "x64run_private.h" +#include "x64primop.h" +#include "x64trace.h" +#include "x87emu_private.h" +#include "box64context.h" +//#include "my_cpuid.h" +#include "bridge.h" +//#include "signals.h" +#ifdef DYNAREC +#include "../dynarec/arm_lock_helper.h" +#endif + +#define F8 *(uint8_t*)(R_RIP++) +#define F8S *(int8_t*)(R_RIP++) +#define F16 *(uint16_t*)(R_RIP+=2, R_RIP-2) +#define F32 *(uint32_t*)(R_RIP+=4, R_RIP-4) +#define F32S *(int32_t*)(R_RIP+=4, R_RIP-4) +#define F64 *(uint64_t*)(R_RIP+=8, R_RIP-8) +#define F64S *(int64_t*)(R_RIP+=8, R_RIP-8) +#define PK(a) *(uint8_t*)(R_RIP+a) + +#define GETED oped=GetEd(emu, rex, nextop) +#define GETGD opgd=GetGd(emu, rex, nextop) +#define GETEB oped=GetEb(emu, rex, nextop) +#define GETGB oped=GetGb(emu, rex, nextop) +#define ED oped +#define GD opgd +#define EB oped +#define GB oped->byte[0] + +int Run0F(x64emu_t *emu) +{ + uint8_t opcode; + uint8_t nextop; + reg64_t *oped, *opgd; + rex_t rex = {0}; + + opcode = F8; + while(opcode>=0x40 && opcode<=0x4f) { + rex.rex = opcode; + opcode = F8; + } + + switch(opcode) { + + case 0x1F: /* NOP (multi-byte) */ + nextop = F8; + GETED; + break; + + default: + return 1; + } + return 0; +} \ No newline at end of file diff --git a/src/main.c b/src/main.c index 92b3c0e6..cf7af7ce 100755 --- a/src/main.c +++ b/src/main.c @@ -826,8 +826,9 @@ int main(int argc, const char **argv, const char **env) { // stack setup is much more complicated then just that! SetupInitialStack(emu); // starting here, the argv[] don't need free anymore SetupX64Emu(emu); - SetRAX(emu, my_context->argc); - SetRBX(emu, (uintptr_t)my_context->argv); + SetRSI(emu, my_context->argc); + SetRDX(emu, (uint64_t)my_context->argv); + SetRCX(emu, (uint64_t)my_context->envv); // child fork to handle traces pthread_atfork(NULL, NULL, my_child_fork); @@ -894,9 +895,12 @@ int main(int argc, const char **argv, const char **env) { // emulate! printf_log(LOG_DEBUG, "Start x64emu on Main\n"); - SetRAX(emu, my_context->argc); + SetRSI(emu, my_context->argc); SetRDX(emu, (uint64_t)my_context->argv); + SetRCX(emu, (uint64_t)my_context->envv); SetRIP(emu, my_context->ep); + PushExit(emu); + *(uint64_t*)GetRSP(emu) = my_context->argc; ResetFlags(emu); Run(emu, 0); // Get EAX |