mirror of
https://github.com/ptitSeb/box64.git
synced 2024-11-24 06:59:53 +00:00
Added 0F 1F NOP opcode
This commit is contained in:
parent
ad05515b70
commit
f2a9066697
@ -109,6 +109,7 @@ set(ELFLOADER_SRC
|
||||
"${BOX64_ROOT}/src/emu/x87emu_private.c"
|
||||
"${BOX64_ROOT}/src/emu/x64primop.c"
|
||||
"${BOX64_ROOT}/src/emu/x64run.c"
|
||||
"${BOX64_ROOT}/src/emu/x64run0f.c"
|
||||
"${BOX64_ROOT}/src/emu/x64run_private.c"
|
||||
"${BOX64_ROOT}/src/emu/x64syscall.c"
|
||||
"${BOX64_ROOT}/src/emu/x64tls.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:
|
||||
|
70
src/emu/x64run0f.c
Normal file
70
src/emu/x64run0f.c
Normal file
@ -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;
|
||||
}
|
10
src/main.c
10
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
|
||||
|
Loading…
Reference in New Issue
Block a user