Fixed a number of bugs in the NCR 53C810 code;
64-bit Windows 86Box now compiles without warnings.
This commit is contained in:
@@ -146,7 +146,7 @@ static uint32_t ropFSTs(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
static uint32_t ropFSTd(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
int host_reg1, host_reg2;
|
||||
int host_reg1 = 0, host_reg2 = 0;
|
||||
|
||||
FP_ENTER();
|
||||
op_pc--;
|
||||
@@ -556,7 +556,7 @@ static uint32_t ropFISTPl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
|
||||
static uint32_t ropFISTPq(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
x86seg *target_seg;
|
||||
int host_reg1, host_reg2;
|
||||
int host_reg1 = 0, host_reg2 = 0;
|
||||
|
||||
FP_ENTER();
|
||||
op_pc--;
|
||||
@@ -622,11 +622,9 @@ static uint32_t ropFCHS(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint3
|
||||
static uint32_t ropFLD ## name(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block) \
|
||||
{ \
|
||||
static double fp_imm = v; \
|
||||
static uint64_t *fpp; \
|
||||
\
|
||||
FP_ENTER(); \
|
||||
fpp = (uint64_t *)&fp_imm; \
|
||||
FP_LOAD_IMM_Q(*fpp); \
|
||||
FP_LOAD_IMM_Q(*(uint64_t *)&fp_imm); \
|
||||
\
|
||||
return op_pc; \
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
static uint32_t ropMOVQ_q_mm(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
|
||||
{
|
||||
int host_reg1, host_reg2;
|
||||
int host_reg1 = 0, host_reg2 = 0;
|
||||
|
||||
MMX_ENTER();
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#ifdef __amd64__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include "../86box.h"
|
||||
#include "../mem.h"
|
||||
#include "cpu.h"
|
||||
#include "x86.h"
|
||||
#include "x86_flags.h"
|
||||
#include "x86_ops.h"
|
||||
#include "x87.h"
|
||||
#include "../mem.h"
|
||||
|
||||
#include "386_common.h"
|
||||
|
||||
#include "codegen.h"
|
||||
#include "codegen_ops.h"
|
||||
#include "codegen_ops_x86-64.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
int codegen_flat_ds, codegen_flat_ss;
|
||||
int codegen_flags_changed = 0;
|
||||
int codegen_fpu_entered = 0;
|
||||
@@ -64,7 +63,9 @@ static int last_ssegs;
|
||||
|
||||
void codegen_init()
|
||||
{
|
||||
#ifdef __linux__
|
||||
int c;
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
void *start;
|
||||
size_t len;
|
||||
long pagesize = sysconf(_SC_PAGESIZE);
|
||||
@@ -81,7 +82,10 @@ void codegen_init()
|
||||
memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t));
|
||||
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
|
||||
|
||||
#ifdef __linux__
|
||||
for (c = 0; c < BLOCK_SIZE; c++)
|
||||
codeblock[c].valid = 0;
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
start = (void *)((long)codeblock & pagemask);
|
||||
len = ((BLOCK_SIZE * sizeof(codeblock_t)) + pagesize) & pagemask;
|
||||
if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
|
||||
@@ -90,17 +94,37 @@ void codegen_init()
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
// pclog("Codegen is %p\n", (void *)pages[0xfab12 >> 12].block);
|
||||
}
|
||||
|
||||
void codegen_reset()
|
||||
{
|
||||
int c;
|
||||
|
||||
memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t));
|
||||
memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *));
|
||||
mem_reset_page_blocks();
|
||||
|
||||
for (c = 0; c < BLOCK_SIZE; c++)
|
||||
codeblock[c].valid = 0;
|
||||
}
|
||||
|
||||
void dump_block()
|
||||
{
|
||||
/* codeblock_t *block = pages[0x119000 >> 12].block;
|
||||
|
||||
pclog("dump_block:\n");
|
||||
while (block)
|
||||
{
|
||||
uint32_t start_pc = (block->pc & 0xffc) | (block->phys & ~0xfff);
|
||||
uint32_t end_pc = (block->endpc & 0xffc) | (block->phys & ~0xfff);
|
||||
pclog(" %p : %08x-%08x %08x-%08x %p %p\n", (void *)block, start_pc, end_pc, block->pc, block->endpc, (void *)block->prev, (void *)block->next);
|
||||
if (!block->pc)
|
||||
fatal("Dead PC=0\n");
|
||||
|
||||
block = block->next;
|
||||
}
|
||||
pclog("dump_block done\n");*/
|
||||
}
|
||||
|
||||
static void add_to_block_list(codeblock_t *block)
|
||||
@@ -124,7 +148,7 @@ static void add_to_block_list(codeblock_t *block)
|
||||
|
||||
if (block->next)
|
||||
{
|
||||
if (!block->next->valid)
|
||||
if (block->next->valid == 0)
|
||||
fatal("block->next->valid=0 %p %p %x %x\n", (void *)block->next, (void *)codeblock, block_current, block_pos);
|
||||
}
|
||||
|
||||
@@ -141,7 +165,7 @@ static void add_to_block_list(codeblock_t *block)
|
||||
else
|
||||
{
|
||||
block->next_2 = NULL;
|
||||
pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block;
|
||||
pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,6 +204,7 @@ static void remove_from_block_list(codeblock_t *block, uint32_t pc)
|
||||
}
|
||||
else
|
||||
{
|
||||
// pclog(" pages.block_2=%p 3 %p %p\n", (void *)block->next_2, (void *)block, (void *)pages[block->phys_2 >> 12].block_2);
|
||||
pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block->next_2;
|
||||
if (block->next_2)
|
||||
block->next_2->prev_2 = NULL;
|
||||
@@ -195,7 +220,7 @@ static void delete_block(codeblock_t *block)
|
||||
if (block == codeblock_hash[HASH(block->phys)])
|
||||
codeblock_hash[HASH(block->phys)] = NULL;
|
||||
|
||||
if (!block->valid)
|
||||
if (block->valid == 0)
|
||||
fatal("Deleting deleted block\n");
|
||||
block->valid = 0;
|
||||
|
||||
@@ -237,9 +262,6 @@ void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr)
|
||||
void codegen_block_init(uint32_t phys_addr)
|
||||
{
|
||||
codeblock_t *block;
|
||||
#if UNUSED
|
||||
int has_evicted = 0;
|
||||
#endif
|
||||
page_t *page = &pages[phys_addr >> 12];
|
||||
|
||||
if (!page->block[(phys_addr >> 10) & 3])
|
||||
@@ -248,8 +270,11 @@ void codegen_block_init(uint32_t phys_addr)
|
||||
block_current = (block_current + 1) & BLOCK_MASK;
|
||||
block = &codeblock[block_current];
|
||||
|
||||
// if (block->pc == 0xb00b4ff5)
|
||||
// pclog("Init target block\n");
|
||||
if (block->valid != 0)
|
||||
{
|
||||
// pclog("Reuse block : was %08x now %08x\n", block->pc, cs+pc);
|
||||
delete_block(block);
|
||||
cpu_recomp_reuse++;
|
||||
}
|
||||
@@ -268,9 +293,8 @@ void codegen_block_init(uint32_t phys_addr)
|
||||
block->next_2 = block->prev_2 = NULL;
|
||||
block->page_mask = 0;
|
||||
block->flags = 0;
|
||||
|
||||
block->status = cpu_cur_status;
|
||||
|
||||
block->status = cpu_cur_status;
|
||||
|
||||
block->was_recompiled = 0;
|
||||
|
||||
recomp_page = block->phys & ~0xfff;
|
||||
@@ -280,9 +304,6 @@ void codegen_block_init(uint32_t phys_addr)
|
||||
|
||||
void codegen_block_start_recompile(codeblock_t *block)
|
||||
{
|
||||
#if UNUSED
|
||||
int has_evicted = 0;
|
||||
#endif
|
||||
page_t *page = &pages[block->phys >> 12];
|
||||
|
||||
if (!page->block[(block->phys >> 10) & 3])
|
||||
@@ -353,6 +374,8 @@ void codegen_block_start_recompile(codeblock_t *block)
|
||||
addbyte(0xBD);
|
||||
addquad(((uintptr_t)&cpu_state) + 128);
|
||||
|
||||
// pclog("New block %i for %08X %03x\n", block_current, cs+pc, block_num);
|
||||
|
||||
last_op32 = -1;
|
||||
last_ea_seg = NULL;
|
||||
last_ssegs = -1;
|
||||
@@ -412,9 +435,11 @@ void codegen_block_generate_end_mask()
|
||||
start_pc >>= PAGE_MASK_SHIFT;
|
||||
end_pc >>= PAGE_MASK_SHIFT;
|
||||
|
||||
// pclog("block_end: %08x %08x\n", start_pc, end_pc);
|
||||
for (; start_pc <= end_pc; start_pc++)
|
||||
{
|
||||
block->page_mask |= ((uint64_t)1 << start_pc);
|
||||
// pclog(" %08x %llx\n", start_pc, block->page_mask);
|
||||
}
|
||||
|
||||
pages[block->phys >> 12].code_present_mask[(block->phys >> 10) & 3] |= block->page_mask;
|
||||
@@ -427,7 +452,7 @@ void codegen_block_generate_end_mask()
|
||||
block->phys_2 = get_phys_noabrt(block->endpc);
|
||||
if (block->phys_2 != -1)
|
||||
{
|
||||
page_t *page_2 = &pages[block->phys_2 >> 12];
|
||||
page_t *page_2 = &pages[block->phys_2 >> 12];
|
||||
|
||||
start_pc = 0;
|
||||
end_pc = (block->endpc & 0x3ff) >> PAGE_MASK_SHIFT;
|
||||
@@ -442,14 +467,16 @@ void codegen_block_generate_end_mask()
|
||||
fatal("!page_mask2\n");
|
||||
if (block->next_2)
|
||||
{
|
||||
if (!block->next_2->valid)
|
||||
fatal("block->next_2->vsalid=0 %p\n", (void *)block->next_2);
|
||||
// pclog(" next_2->pc=%08x\n", block->next_2->pc);
|
||||
if (block->next_2->valid == 0)
|
||||
fatal("block->next_2->valid=0 %p\n", (void *)block->next_2);
|
||||
}
|
||||
|
||||
block->dirty_mask2 = &page_2->dirty_mask[(block->phys_2 >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK];
|
||||
}
|
||||
}
|
||||
|
||||
// pclog("block_end: %08x %08x %016llx\n", block->pc, block->endpc, block->page_mask);
|
||||
recomp_page = -1;
|
||||
}
|
||||
|
||||
@@ -469,16 +496,26 @@ void codegen_block_end_recompile(codeblock_t *block)
|
||||
{
|
||||
addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/
|
||||
addbyte(0x6d);
|
||||
addbyte(cpu_state_offset(_cycles));
|
||||
addbyte((uint8_t)cpu_state_offset(_cycles));
|
||||
addlong((uint32_t)codegen_block_cycles);
|
||||
}
|
||||
if (codegen_block_ins)
|
||||
{
|
||||
addbyte(0x81); /*ADD $codegen_block_ins,ins*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(cpu_recomp_ins));
|
||||
addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins));
|
||||
addlong(codegen_block_ins);
|
||||
}
|
||||
#if 0
|
||||
if (codegen_block_full_ins)
|
||||
{
|
||||
addbyte(0x81); /*ADD $codegen_block_ins,ins*/
|
||||
addbyte(0x04);
|
||||
addbyte(0x25);
|
||||
addlong((uint32_t)&cpu_recomp_full_ins);
|
||||
addlong(codegen_block_full_ins);
|
||||
}
|
||||
#endif
|
||||
addbyte(0x48); /*ADDL $40,%rsp*/
|
||||
addbyte(0x83);
|
||||
addbyte(0xC4);
|
||||
@@ -505,6 +542,7 @@ void codegen_block_end_recompile(codeblock_t *block)
|
||||
block->next_2 = block->prev_2 = NULL;
|
||||
codegen_block_generate_end_mask();
|
||||
add_to_block_list(block);
|
||||
// pclog("End block %i\n", block_num);
|
||||
}
|
||||
|
||||
void codegen_flush()
|
||||
@@ -512,29 +550,6 @@ void codegen_flush()
|
||||
return;
|
||||
}
|
||||
|
||||
static int opcode_conditional_jump[256] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /*00*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*30*/
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*40*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*50*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*60*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*70*/
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*90*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*a0*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*b0*/
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*c0*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*d0*/
|
||||
1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*e0*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*f0*/
|
||||
};
|
||||
|
||||
static int opcode_modrm[256] =
|
||||
{
|
||||
1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, /*00*/
|
||||
@@ -571,7 +586,7 @@ int opcode_0f_modrm[256] =
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*90*/
|
||||
0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /*a0*/
|
||||
0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, /*a0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, /*b0*/
|
||||
|
||||
1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /*c0*/
|
||||
@@ -594,7 +609,7 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
{
|
||||
addbyte(0xC7); /*MOVL $0,(ssegs)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(eaaddr));
|
||||
addbyte((uint8_t)cpu_state_offset(eaaddr));
|
||||
addlong((fetchdat >> 8) & 0xffff);
|
||||
(*op_pc) += 2;
|
||||
}
|
||||
@@ -704,14 +719,14 @@ static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
}
|
||||
addbyte(0x89); /*MOV eaaddr, EAX*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(eaaddr));
|
||||
addbyte((uint8_t)cpu_state_offset(eaaddr));
|
||||
|
||||
if (mod1seg[cpu_rm] == &ss && !op_ssegs)
|
||||
op_ea_seg = &_ss;
|
||||
}
|
||||
return op_ea_seg;
|
||||
}
|
||||
|
||||
//#if 0
|
||||
static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, int stack_offset)
|
||||
{
|
||||
uint32_t new_eaaddr;
|
||||
@@ -859,7 +874,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
|
||||
addbyte(0x89); /*MOV eaaddr, EAX*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(eaaddr));
|
||||
addbyte((uint8_t)cpu_state_offset(eaaddr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -870,7 +885,7 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
new_eaaddr = fastreadl(cs + (*op_pc) + 1);
|
||||
addbyte(0xC7); /*MOVL $new_eaaddr,(eaaddr)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(eaaddr));
|
||||
addbyte((uint8_t)cpu_state_offset(eaaddr));
|
||||
addlong(new_eaaddr);
|
||||
(*op_pc) += 4;
|
||||
return op_ea_seg;
|
||||
@@ -901,19 +916,19 @@ static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat,
|
||||
}
|
||||
addbyte(0x89); /*MOV eaaddr, EAX*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(eaaddr));
|
||||
addbyte((uint8_t)cpu_state_offset(eaaddr));
|
||||
}
|
||||
else
|
||||
{
|
||||
addbyte(0x44); /*MOV eaaddr, base_reg*/
|
||||
addbyte(0x89);
|
||||
addbyte(0x45 | (base_reg << 3));
|
||||
addbyte(cpu_state_offset(eaaddr));
|
||||
addbyte((uint8_t)cpu_state_offset(eaaddr));
|
||||
}
|
||||
}
|
||||
return op_ea_seg;
|
||||
}
|
||||
|
||||
//#endif
|
||||
void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_pc, uint32_t old_pc)
|
||||
{
|
||||
codeblock_t *block = &codeblock[block_current];
|
||||
@@ -1084,18 +1099,18 @@ void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t
|
||||
generate_call:
|
||||
codegen_timing_opcode(opcode, fetchdat, op_32);
|
||||
|
||||
if (((op_table == x86_dynarec_opcodes) &&
|
||||
(((opcode & 0xf0) == 0x70) || ((opcode & 0xfc) == 0xe0) || (opcode == 0xc2) ||
|
||||
((opcode & 0xfe) == 0xca) || ((opcode & 0xfc) == 0xcc) || ((opcode & 0xfc) == 0xe8) ||
|
||||
((opcode == 0xff) && (((fetchdat & 0x38) >= 0x10) && ((fetchdat & 0x38) < 0x30)))) ||
|
||||
((op_table == x86_dynarec_opcodes_0f) && ((opcode & 0xf0) == 0x80))))
|
||||
if ((op_table == x86_dynarec_opcodes &&
|
||||
((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 ||
|
||||
(opcode & 0xfe) == 0xca || (opcode & 0xfc) == 0xcc || (opcode & 0xfc) == 0xe8 ||
|
||||
(opcode == 0xff && ((fetchdat & 0x38) >= 0x10 && (fetchdat & 0x38) < 0x30)))) ||
|
||||
(op_table == x86_dynarec_opcodes_0f && ((opcode & 0xf0) == 0x80)))
|
||||
{
|
||||
/*Opcode is likely to cause block to exit, update cycle count*/
|
||||
if (codegen_block_cycles)
|
||||
{
|
||||
addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/
|
||||
addbyte(0x6d);
|
||||
addbyte(cpu_state_offset(_cycles));
|
||||
addbyte((uint8_t)cpu_state_offset(_cycles));
|
||||
addlong((uint32_t)codegen_block_cycles);
|
||||
codegen_block_cycles = 0;
|
||||
}
|
||||
@@ -1103,10 +1118,21 @@ generate_call:
|
||||
{
|
||||
addbyte(0x81); /*ADD $codegen_block_ins,ins*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(cpu_recomp_ins));
|
||||
addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins));
|
||||
addlong(codegen_block_ins);
|
||||
codegen_block_ins = 0;
|
||||
}
|
||||
#if 0
|
||||
if (codegen_block_full_ins)
|
||||
{
|
||||
addbyte(0x81); /*ADD $codegen_block_ins,ins*/
|
||||
addbyte(0x04);
|
||||
addbyte(0x25);
|
||||
addlong((uint32_t)&cpu_recomp_full_ins);
|
||||
addlong(codegen_block_full_ins);
|
||||
codegen_block_full_ins = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((op_table == x86_dynarec_opcodes_REPNE || op_table == x86_dynarec_opcodes_REPE) && !op_table[opcode | op_32])
|
||||
@@ -1133,15 +1159,17 @@ generate_call:
|
||||
}
|
||||
|
||||
op = op_table[((opcode >> opcode_shift) | op_32) & opcode_mask];
|
||||
// if (output)
|
||||
// pclog("Generate call at %08X %02X %08X %02X %08X %08X %08X %08X %08X %02X %02X %02X %02X\n", &codeblock[block_current][block_pos], opcode, new_pc, ram[old_pc], EAX, EBX, ECX, EDX, ESI, ram[0x7bd2+6],ram[0x7bd2+7],ram[0x7bd2+8],ram[0x7bd2+9]);
|
||||
if (op_ssegs != last_ssegs)
|
||||
{
|
||||
last_ssegs = op_ssegs;
|
||||
addbyte(0xC6); /*MOVB $0,(ssegs)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(ssegs));
|
||||
addbyte((uint8_t)cpu_state_offset(ssegs));
|
||||
addbyte(op_ssegs);
|
||||
}
|
||||
|
||||
//#if 0
|
||||
if ((!test_modrm ||
|
||||
(op_table == x86_dynarec_opcodes && opcode_modrm[opcode]) ||
|
||||
(op_table == x86_dynarec_opcodes_0f && opcode_0f_modrm[opcode]))/* && !(op_32 & 0x200)*/)
|
||||
@@ -1157,7 +1185,7 @@ generate_call:
|
||||
|
||||
addbyte(0xC7); /*MOVL $rm | mod | reg,(rm_mod_reg_data)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(rm_data.rm_mod_reg_data));
|
||||
addbyte((uint8_t)cpu_state_offset(rm_data.rm_mod_reg_data));
|
||||
addlong(cpu_rm | (cpu_mod << 8) | (cpu_reg << 16));
|
||||
|
||||
op_pc += pc_off;
|
||||
@@ -1167,30 +1195,31 @@ generate_call:
|
||||
op_ea_seg = codegen_generate_ea_32_long(op_ea_seg, fetchdat, op_ssegs, &op_pc, stack_offset);
|
||||
op_pc -= pc_off;
|
||||
}
|
||||
|
||||
//#endif
|
||||
if (op_ea_seg != last_ea_seg)
|
||||
{
|
||||
// last_ea_seg = op_ea_seg;
|
||||
addbyte(0xC7); /*MOVL $&_ds,(ea_seg)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(ea_seg));
|
||||
addlong((uint32_t)op_ea_seg);
|
||||
addbyte((uint8_t)cpu_state_offset(ea_seg));
|
||||
addlong((uint32_t)(uintptr_t)op_ea_seg);
|
||||
}
|
||||
|
||||
|
||||
addbyte(0xC7); /*MOVL [pc],new_pc*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(pc));
|
||||
addbyte((uint8_t)cpu_state_offset(pc));
|
||||
addlong(op_pc + pc_off);
|
||||
addbyte(0xC7); /*MOVL $old_pc,(oldpc)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(oldpc));
|
||||
addbyte((uint8_t)cpu_state_offset(oldpc));
|
||||
addlong(old_pc);
|
||||
if (op_32 != last_op32)
|
||||
{
|
||||
last_op32 = op_32;
|
||||
addbyte(0xC7); /*MOVL $use32,(op32)*/
|
||||
addbyte(0x45);
|
||||
addbyte(cpu_state_offset(op32));
|
||||
addbyte((uint8_t)cpu_state_offset(op32));
|
||||
addlong(op_32);
|
||||
}
|
||||
|
||||
@@ -1204,7 +1233,9 @@ generate_call:
|
||||
addbyte(0x85); /*OR %eax, %eax*/
|
||||
addbyte(0xc0);
|
||||
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
|
||||
addlong((uint32_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(&block->data[block_pos + 4]));
|
||||
addlong((uint32_t)(uintptr_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(uintptr_t)(&block->data[block_pos + 4]));
|
||||
|
||||
// call(block, codegen_debug);
|
||||
|
||||
codegen_endpc = (cs + cpu_state.pc) + 8;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user