Old recompiler improvements: limited in-block IRQ checking to floppy IRQ's only, rewrote the GPF handlers in ASM, and changed the recompiled INC and DEC instructions to actually use INC and DEC on host. Also removed the keyboard_at.c timer hack.

This commit is contained in:
OBattler
2020-07-15 05:03:19 +02:00
parent 10e16249fd
commit ec74ffb6a5
8 changed files with 81 additions and 12 deletions

View File

@@ -7,7 +7,8 @@ static uint32_t ropINC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
host_reg = LOAD_REG_W(opcode & 7);
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
ADD_HOST_REG_IMM_W(host_reg, 1);
// ADD_HOST_REG_IMM_W(host_reg, 1);
INC_HOST_REG_W(host_reg);
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC16);
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
@@ -26,7 +27,8 @@ static uint32_t ropINC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
host_reg = LOAD_REG_L(opcode & 7);
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
ADD_HOST_REG_IMM(host_reg, 1);
// ADD_HOST_REG_IMM(host_reg, 1);
INC_HOST_REG(host_reg);
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_INC32);
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);
@@ -45,7 +47,8 @@ static uint32_t ropDEC_rw(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
host_reg = LOAD_REG_W(opcode & 7);
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_op1, host_reg);
SUB_HOST_REG_IMM_W(host_reg, 1);
// SUB_HOST_REG_IMM_W(host_reg, 1);
DEC_HOST_REG_W(host_reg);
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC16);
STORE_HOST_REG_ADDR_WL((uintptr_t)&cpu_state.flags_res, host_reg);
@@ -64,7 +67,8 @@ static uint32_t ropDEC_rl(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
host_reg = LOAD_REG_L(opcode & 7);
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_op1, host_reg);
SUB_HOST_REG_IMM(host_reg, 1);
// SUB_HOST_REG_IMM(host_reg, 1);
DEC_HOST_REG(host_reg);
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op2, 1);
STORE_IMM_ADDR_L((uintptr_t)&cpu_state.flags_op, FLAGS_DEC32);
STORE_HOST_REG_ADDR((uintptr_t)&cpu_state.flags_res, host_reg);

View File

@@ -2967,6 +2967,29 @@ static inline void SUB_HOST_REG_IMM(int host_reg, uint32_t imm)
addlong(imm);
}
static inline void INC_HOST_REG_W(int host_reg)
{
addbyte(0x66); /*DECW host_reg*/
addbyte(0xff);
addbyte(0xc0 | (host_reg & 7));
}
static inline void INC_HOST_REG(int host_reg)
{
addbyte(0xff); /*DECL host_reg*/
addbyte(0xc0 | (host_reg & 7));
}
static inline void DEC_HOST_REG_W(int host_reg)
{
addbyte(0x66); /*DECW host_reg*/
addbyte(0xff);
addbyte(0xc8 | (host_reg & 7));
}
static inline void DEC_HOST_REG(int host_reg)
{
addbyte(0xff); /*DECL host_reg*/
addbyte(0xc8 | (host_reg & 7));
}
static inline int CMP_HOST_REG_IMM_B(int host_reg, uint8_t imm)
{
if (host_reg & 8)

View File

@@ -483,6 +483,25 @@ static inline void SUB_HOST_REG_IMM(int host_reg, uint32_t imm)
}
}
static inline void INC_HOST_REG_W(int host_reg)
{
addbyte(0x66); /*DECW host_reg*/
addbyte(0x40 | host_reg);
}
static inline void INC_HOST_REG(int host_reg)
{
addbyte(0x40 | host_reg); /*DECL host_reg*/
}
static inline void DEC_HOST_REG_W(int host_reg)
{
addbyte(0x66); /*DECW host_reg*/
addbyte(0x48 | host_reg);
}
static inline void DEC_HOST_REG(int host_reg)
{
addbyte(0x48 | host_reg); /*DECL host_reg*/
}
static inline int CMP_HOST_REG_B(int dst_reg, int src_reg)
{
SUB_HOST_REG_B(dst_reg, src_reg);

View File

@@ -294,6 +294,7 @@ void codegen_block_start_recompile(codeblock_t *block)
block->status = cpu_cur_status;
block_pos = BLOCK_GPF_OFFSET;
#ifdef OLD_GPF
#if WIN64
addbyte(0x48); /*XOR RCX, RCX*/
addbyte(0x31);
@@ -308,6 +309,17 @@ void codegen_block_start_recompile(codeblock_t *block)
addbyte(0xf6);
#endif
call(block, (uintptr_t)x86gpf);
#else
addbyte(0xc6); /* mov byte ptr[&(cpu_state.abrt)],ABRT_GPF */
addbyte(0x05);
addlong((uint32_t) (uintptr_t) &(cpu_state.abrt));
addbyte(ABRT_GPF);
addbyte(0x31); /* xor eax,eax */
addbyte(0xc0);
addbyte(0x67); /* mov [&(abrt_error)],eax */
addbyte(0xa3);
addlong((uint32_t) (uintptr_t) &(abrt_error));
#endif
while (block_pos < BLOCK_EXIT_OFFSET)
addbyte(0x90); /*NOP*/
block_pos = BLOCK_EXIT_OFFSET; /*Exit code*/

View File

@@ -1440,6 +1440,7 @@ void codegen_block_start_recompile(codeblock_t *block)
block->status = cpu_cur_status;
block_pos = BLOCK_GPF_OFFSET;
#ifdef OLD_GPF
addbyte(0xc7); /*MOV [ESP],0*/
addbyte(0x04);
addbyte(0x24);
@@ -1451,6 +1452,16 @@ void codegen_block_start_recompile(codeblock_t *block)
addlong(0);
addbyte(0xe8); /*CALL x86gpf*/
addlong((uint32_t)x86gpf - (uint32_t)(&codeblock[block_current].data[block_pos + 4]));
#else
addbyte(0xc6); /* mov byte ptr[&(cpu_state.abrt)],ABRT_GPF */
addbyte(0x05);
addlong((uint32_t) (uintptr_t) &(cpu_state.abrt));
addbyte(ABRT_GPF);
addbyte(0x31); /* xor eax,eax */
addbyte(0xc0);
addbyte(0xa3); /* mov [&(abrt_error)],eax */
addlong((uint32_t) (uintptr_t) &(abrt_error));
#endif
block_pos = BLOCK_EXIT_OFFSET; /*Exit code*/
addbyte(0x83); /*ADDL $16,%esp*/
addbyte(0xC4);

View File

@@ -8,7 +8,11 @@
#define HASH(l) ((l) & 0x1ffff)
#define BLOCK_EXIT_OFFSET 0x7f0
#ifdef OLD_GPF
#define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 20)
#else
#define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 14)
#endif
#define BLOCK_MAX 1720