Initial commit of dynamic recompiler.

Various CPU changes to support dynamic recompiler.
This commit is contained in:
TomW 2014-11-05 21:24:16 +00:00
commit 4676daade4
52 changed files with 3740 additions and 1139 deletions

View file

@ -19,36 +19,42 @@
static int opJ ## condition(uint32_t fetchdat) \
{ \
int8_t offset = (int8_t)getbytef(); \
cycles -= timing_bnt; \
if (cond_ ## condition) \
{ \
pc += offset; \
cycles -= timing_bt; \
CPU_BLOCK_END(); \
return 1; \
} \
cycles -= timing_bnt; \
return 0; \
} \
\
static int opJ ## condition ## _w(uint32_t fetchdat) \
{ \
int16_t offset = (int16_t)getwordf(); \
cycles -= timing_bnt; \
if (cond_ ## condition) \
{ \
pc += offset; \
cycles -= timing_bt; \
CPU_BLOCK_END(); \
return 1; \
} \
cycles -= timing_bnt; \
return 0; \
} \
\
static int opJ ## condition ## _l(uint32_t fetchdat) \
{ \
uint32_t offset = getlong(); \
uint32_t offset = getlong(); if (abrt) return 1; \
cycles -= timing_bnt; \
if (cond_ ## condition) \
{ \
pc += offset; \
cycles -= timing_bt; \
CPU_BLOCK_END(); \
return 1; \
} \
cycles -= timing_bnt; \
return 0; \
} \
@ -75,18 +81,26 @@ static int opLOOPNE_w(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
CX--;
if (CX && !ZF_SET())
pc += offset;
cycles -= (is486) ? 7 : 11;
if (CX && !ZF_SET())
{
pc += offset;
CPU_BLOCK_END();
return 1;
}
return 0;
}
static int opLOOPNE_l(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
ECX--;
if (ECX && !ZF_SET())
pc += offset;
cycles -= (is486) ? 7 : 11;
if (ECX && !ZF_SET())
{
pc += offset;
CPU_BLOCK_END();
return 1;
}
return 0;
}
@ -94,18 +108,26 @@ static int opLOOPE_w(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
CX--;
if (CX && ZF_SET())
pc += offset;
cycles -= (is486) ? 7 : 11;
if (CX && ZF_SET())
{
pc += offset;
CPU_BLOCK_END();
return 1;
}
return 0;
}
static int opLOOPE_l(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
ECX--;
if (ECX && ZF_SET())
pc += offset;
cycles -= (is486) ? 7 : 11;
if (ECX && ZF_SET())
{
pc += offset;
CPU_BLOCK_END();
return 1;
}
return 0;
}
@ -113,41 +135,53 @@ static int opLOOP_w(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
CX--;
if (CX)
pc += offset;
cycles -= (is486) ? 7 : 11;
if (CX)
{
pc += offset;
CPU_BLOCK_END();
return 1;
}
return 0;
}
static int opLOOP_l(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
ECX--;
if (ECX)
pc += offset;
cycles -= (is486) ? 7 : 11;
if (ECX)
{
pc += offset;
CPU_BLOCK_END();
return 1;
}
return 0;
}
static int opJCXZ(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
cycles -= 5;
if (!CX)
{
pc += offset;
cycles -= 4;
CPU_BLOCK_END();
return 1;
}
cycles -= 5;
return 0;
}
static int opJECXZ(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
cycles -= 5;
if (!ECX)
{
pc += offset;
cycles -= 4;
CPU_BLOCK_END();
return 1;
}
cycles -= 5;
return 0;
}
@ -156,6 +190,7 @@ static int opJMP_r8(uint32_t fetchdat)
{
int8_t offset = (int8_t)getbytef();
pc += offset;
CPU_BLOCK_END();
cycles -= (is486) ? 3 : 7;
return 0;
}
@ -163,13 +198,15 @@ static int opJMP_r16(uint32_t fetchdat)
{
int16_t offset = (int16_t)getwordf();
pc += offset;
CPU_BLOCK_END();
cycles -= (is486) ? 3 : 7;
return 0;
}
static int opJMP_r32(uint32_t fetchdat)
{
int32_t offset = (int32_t)getlong(); if (abrt) return 0;
int32_t offset = (int32_t)getlong(); if (abrt) return 1;
pc += offset;
CPU_BLOCK_END();
cycles -= (is486) ? 3 : 7;
return 0;
}
@ -177,84 +214,92 @@ static int opJMP_r32(uint32_t fetchdat)
static int opJMP_far_a16(uint32_t fetchdat)
{
uint16_t addr = getwordf();
uint16_t seg = getword(); if (abrt) return 0;
uint16_t seg = getword(); if (abrt) return 1;
uint32_t oxpc = pc;
pc = addr;
loadcsjmp(seg, oxpc);
CPU_BLOCK_END();
cycles -= (is486) ? 17 : 12;
return 0;
}
static int opJMP_far_a32(uint32_t fetchdat)
{
uint32_t addr = getlong();
uint16_t seg = getword(); if (abrt) return 0;
uint16_t seg = getword(); if (abrt) return 1;
uint32_t oxpc = pc;
pc = addr;
loadcsjmp(seg, oxpc);
CPU_BLOCK_END();
cycles -= (is486) ? 17 : 12;
return 0;
}
int opCALL_r16(uint32_t fetchdat)
static int opCALL_r16(uint32_t fetchdat)
{
int16_t addr = (int16_t)getwordf();
PUSH_W(pc);
pc += addr;
CPU_BLOCK_END();
cycles -= (is486) ? 3 : 7;
return 0;
}
int opCALL_r32(uint32_t fetchdat)
static int opCALL_r32(uint32_t fetchdat)
{
int32_t addr = getlong(); if (abrt) return 0;
int32_t addr = getlong(); if (abrt) return 1;
PUSH_L(pc);
pc += addr;
CPU_BLOCK_END();
cycles -= (is486) ? 3 : 7;
return 0;
}
int opRET_w(uint32_t fetchdat)
static int opRET_w(uint32_t fetchdat)
{
uint16_t ret;
ret = POP_W(); if (abrt) return 0;
ret = POP_W(); if (abrt) return 1;
pc = ret;
CPU_BLOCK_END();
cycles -= (is486) ? 5 : 10;
return 0;
}
int opRET_l(uint32_t fetchdat)
static int opRET_l(uint32_t fetchdat)
{
uint32_t ret;
ret = POP_L(); if (abrt) return 0;
ret = POP_L(); if (abrt) return 1;
pc = ret;
CPU_BLOCK_END();
cycles -= (is486) ? 5 : 10;
return 0;
}
int opRET_w_imm(uint32_t fetchdat)
static int opRET_w_imm(uint32_t fetchdat)
{
uint16_t offset = getwordf();
uint16_t ret;
ret = POP_W(); if (abrt) return 0;
ret = POP_W(); if (abrt) return 1;
if (stack32) ESP += offset;
else SP += offset;
pc = ret;
CPU_BLOCK_END();
cycles -= (is486) ? 5 : 10;
return 0;
}
int opRET_l_imm(uint32_t fetchdat)
static int opRET_l_imm(uint32_t fetchdat)
{
uint16_t offset = getwordf();
uint32_t ret;
ret = POP_L(); if (abrt) return 0;
ret = POP_L(); if (abrt) return 1;
if (stack32) ESP += offset;
else SP += offset;
pc = ret;
CPU_BLOCK_END();
cycles -= (is486) ? 5 : 10;
return 0;