Added prefetch timing approximation for 286/386 CPUs, with configurable memory timing.
This commit is contained in:
parent
c5889e311f
commit
1b73963997
33 changed files with 1139 additions and 261 deletions
|
|
@ -3,6 +3,7 @@
|
|||
{ \
|
||||
PUSH_W(reg); \
|
||||
CLOCK_CYCLES((is486) ? 1 : 2); \
|
||||
PREFETCH_RUN(2, 1, -1, 0,0,1,0, 0); \
|
||||
return cpu_state.abrt; \
|
||||
}
|
||||
|
||||
|
|
@ -11,6 +12,7 @@
|
|||
{ \
|
||||
PUSH_L(reg); \
|
||||
CLOCK_CYCLES((is486) ? 1 : 2); \
|
||||
PREFETCH_RUN(2, 1, -1, 0,0,0,1, 0); \
|
||||
return cpu_state.abrt; \
|
||||
}
|
||||
|
||||
|
|
@ -19,6 +21,7 @@
|
|||
{ \
|
||||
reg = POP_W(); \
|
||||
CLOCK_CYCLES((is486) ? 1 : 4); \
|
||||
PREFETCH_RUN(4, 1, -1, 1,0,0,0, 0); \
|
||||
return cpu_state.abrt; \
|
||||
}
|
||||
|
||||
|
|
@ -27,6 +30,7 @@
|
|||
{ \
|
||||
reg = POP_L(); \
|
||||
CLOCK_CYCLES((is486) ? 1 : 4); \
|
||||
PREFETCH_RUN(4, 1, -1, 0,1,0,0, 0); \
|
||||
return cpu_state.abrt; \
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +98,7 @@ static int opPUSHA_w(uint32_t fetchdat)
|
|||
if (!cpu_state.abrt) SP -= 16;
|
||||
}
|
||||
CLOCK_CYCLES((is486) ? 11 : 18);
|
||||
PREFETCH_RUN(18, 1, -1, 0,0,8,0, 0);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
static int opPUSHA_l(uint32_t fetchdat)
|
||||
|
|
@ -123,6 +128,7 @@ static int opPUSHA_l(uint32_t fetchdat)
|
|||
if (!cpu_state.abrt) SP -= 32;
|
||||
}
|
||||
CLOCK_CYCLES((is486) ? 11 : 18);
|
||||
PREFETCH_RUN(18, 1, -1, 0,0,0,8, 0);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
|
||||
|
|
@ -151,6 +157,7 @@ static int opPOPA_w(uint32_t fetchdat)
|
|||
SP += 16;
|
||||
}
|
||||
CLOCK_CYCLES((is486) ? 9 : 24);
|
||||
PREFETCH_RUN(24, 1, -1, 7,0,0,0, 0);
|
||||
return 0;
|
||||
}
|
||||
static int opPOPA_l(uint32_t fetchdat)
|
||||
|
|
@ -178,6 +185,7 @@ static int opPOPA_l(uint32_t fetchdat)
|
|||
SP += 32;
|
||||
}
|
||||
CLOCK_CYCLES((is486) ? 9 : 24);
|
||||
PREFETCH_RUN(24, 1, -1, 0,7,0,0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -186,6 +194,7 @@ static int opPUSH_imm_w(uint32_t fetchdat)
|
|||
uint16_t val = getwordf();
|
||||
PUSH_W(val);
|
||||
CLOCK_CYCLES(2);
|
||||
PREFETCH_RUN(2, 3, -1, 0,0,1,0, 0);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
static int opPUSH_imm_l(uint32_t fetchdat)
|
||||
|
|
@ -193,6 +202,7 @@ static int opPUSH_imm_l(uint32_t fetchdat)
|
|||
uint32_t val = getlong(); if (cpu_state.abrt) return 1;
|
||||
PUSH_L(val);
|
||||
CLOCK_CYCLES(2);
|
||||
PREFETCH_RUN(2, 3, -1, 0,0,0,1, 0);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
|
||||
|
|
@ -204,6 +214,7 @@ static int opPUSH_imm_bw(uint32_t fetchdat)
|
|||
PUSH_W(tempw);
|
||||
|
||||
CLOCK_CYCLES(2);
|
||||
PREFETCH_RUN(2, 2, -1, 0,0,1,0, 0);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
static int opPUSH_imm_bl(uint32_t fetchdat)
|
||||
|
|
@ -214,6 +225,7 @@ static int opPUSH_imm_bl(uint32_t fetchdat)
|
|||
PUSH_L(templ);
|
||||
|
||||
CLOCK_CYCLES(2);
|
||||
PREFETCH_RUN(2, 2, -1, 0,0,0,1, 0);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
|
||||
|
|
@ -233,6 +245,7 @@ static int opPOPW_a16(uint32_t fetchdat)
|
|||
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 6);
|
||||
else CLOCK_CYCLES((cpu_mod == 3) ? 4 : 5);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? 4 : 5, 2, rmdat, 1,0,(cpu_mod == 3) ? 0:1,0, 0);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
static int opPOPW_a32(uint32_t fetchdat)
|
||||
|
|
@ -251,6 +264,7 @@ static int opPOPW_a32(uint32_t fetchdat)
|
|||
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 6);
|
||||
else CLOCK_CYCLES((cpu_mod == 3) ? 4 : 5);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? 4 : 5, 2, rmdat, 1,0,(cpu_mod == 3) ? 0:1,0, 1);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
|
||||
|
|
@ -270,6 +284,7 @@ static int opPOPL_a16(uint32_t fetchdat)
|
|||
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 6);
|
||||
else CLOCK_CYCLES((cpu_mod == 3) ? 4 : 5);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? 4 : 5, 2, rmdat, 0,1,0,(cpu_mod == 3) ? 0:1, 0);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
static int opPOPL_a32(uint32_t fetchdat)
|
||||
|
|
@ -288,6 +303,7 @@ static int opPOPL_a32(uint32_t fetchdat)
|
|||
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 6);
|
||||
else CLOCK_CYCLES((cpu_mod == 3) ? 4 : 5);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? 4 : 5, 2, rmdat, 0,1,0,(cpu_mod == 3) ? 0:1, 1);
|
||||
return cpu_state.abrt;
|
||||
}
|
||||
|
||||
|
|
@ -297,6 +313,7 @@ static int opENTER_w(uint32_t fetchdat)
|
|||
uint16_t offset = getwordf();
|
||||
int count = (fetchdat >> 16) & 0xff; cpu_state.pc++;
|
||||
uint32_t tempEBP = EBP, tempESP = ESP, frame_ptr;
|
||||
int reads = 0, writes = 1, instr_cycles = 0;
|
||||
|
||||
PUSH_W(BP); if (cpu_state.abrt) return 1;
|
||||
frame_ptr = ESP;
|
||||
|
|
@ -313,16 +330,20 @@ static int opENTER_w(uint32_t fetchdat)
|
|||
PUSH_W(tempw);
|
||||
if (cpu_state.abrt) { ESP = tempESP; EBP = tempEBP; return 1; }
|
||||
CLOCK_CYCLES((is486) ? 3 : 4);
|
||||
reads++; writes++; instr_cycles += (is486) ? 3 : 4;
|
||||
}
|
||||
PUSH_W(frame_ptr);
|
||||
if (cpu_state.abrt) { ESP = tempESP; EBP = tempEBP; return 1; }
|
||||
CLOCK_CYCLES((is486) ? 3 : 5);
|
||||
writes++; instr_cycles += (is486) ? 3 : 5;
|
||||
}
|
||||
BP = frame_ptr;
|
||||
|
||||
if (stack32) ESP -= offset;
|
||||
else SP -= offset;
|
||||
CLOCK_CYCLES((is486) ? 14 : 10);
|
||||
instr_cycles += (is486) ? 14 : 10;
|
||||
PREFETCH_RUN(instr_cycles, 3, -1, reads,0,writes,0, 0);
|
||||
return 0;
|
||||
}
|
||||
static int opENTER_l(uint32_t fetchdat)
|
||||
|
|
@ -330,6 +351,7 @@ static int opENTER_l(uint32_t fetchdat)
|
|||
uint16_t offset = getwordf();
|
||||
int count = (fetchdat >> 16) & 0xff; cpu_state.pc++;
|
||||
uint32_t tempEBP = EBP, tempESP = ESP, frame_ptr;
|
||||
int reads = 0, writes = 1, instr_cycles = 0;
|
||||
|
||||
PUSH_L(EBP); if (cpu_state.abrt) return 1;
|
||||
frame_ptr = ESP;
|
||||
|
|
@ -346,16 +368,20 @@ static int opENTER_l(uint32_t fetchdat)
|
|||
PUSH_L(templ);
|
||||
if (cpu_state.abrt) { ESP = tempESP; EBP = tempEBP; return 1; }
|
||||
CLOCK_CYCLES((is486) ? 3 : 4);
|
||||
reads++; writes++; instr_cycles += (is486) ? 3 : 4;
|
||||
}
|
||||
PUSH_L(frame_ptr);
|
||||
if (cpu_state.abrt) { ESP = tempESP; EBP = tempEBP; return 1; }
|
||||
CLOCK_CYCLES((is486) ? 3 : 5);
|
||||
writes++; instr_cycles += (is486) ? 3 : 5;
|
||||
}
|
||||
EBP = frame_ptr;
|
||||
|
||||
if (stack32) ESP -= offset;
|
||||
else SP -= offset;
|
||||
CLOCK_CYCLES((is486) ? 14 : 10);
|
||||
instr_cycles += (is486) ? 14 : 10;
|
||||
PREFETCH_RUN(instr_cycles, 3, -1, reads,0,writes,0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -371,6 +397,7 @@ static int opLEAVE_w(uint32_t fetchdat)
|
|||
BP = temp;
|
||||
|
||||
CLOCK_CYCLES(4);
|
||||
PREFETCH_RUN(4, 1, -1, 1,0,0,0, 0);
|
||||
return 0;
|
||||
}
|
||||
static int opLEAVE_l(uint32_t fetchdat)
|
||||
|
|
@ -384,6 +411,7 @@ static int opLEAVE_l(uint32_t fetchdat)
|
|||
EBP = temp;
|
||||
|
||||
CLOCK_CYCLES(4);
|
||||
PREFETCH_RUN(4, 1, -1, 0,1,0,0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -393,12 +421,14 @@ static int opLEAVE_l(uint32_t fetchdat)
|
|||
{ \
|
||||
PUSH_W(seg); \
|
||||
CLOCK_CYCLES(2); \
|
||||
PREFETCH_RUN(2, 1, -1, 0,0,1,0, 0); \
|
||||
return cpu_state.abrt; \
|
||||
} \
|
||||
static int opPUSH_ ## seg ## _l(uint32_t fetchdat) \
|
||||
{ \
|
||||
PUSH_L(seg); \
|
||||
CLOCK_CYCLES(2); \
|
||||
PREFETCH_RUN(2, 1, -1, 0,0,0,1, 0); \
|
||||
return cpu_state.abrt; \
|
||||
}
|
||||
|
||||
|
|
@ -410,6 +440,7 @@ static int opLEAVE_l(uint32_t fetchdat)
|
|||
temp_seg = POP_W(); if (cpu_state.abrt) return 1; \
|
||||
loadseg(temp_seg, realseg); if (cpu_state.abrt) ESP = temp_esp; \
|
||||
CLOCK_CYCLES(is486 ? 3 : 7); \
|
||||
PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0,0,1,0, 0); \
|
||||
return cpu_state.abrt; \
|
||||
} \
|
||||
static int opPOP_ ## seg ## _l(uint32_t fetchdat) \
|
||||
|
|
@ -419,6 +450,7 @@ static int opLEAVE_l(uint32_t fetchdat)
|
|||
temp_seg = POP_L(); if (cpu_state.abrt) return 1; \
|
||||
loadseg(temp_seg & 0xffff, realseg); if (cpu_state.abrt) ESP = temp_esp; \
|
||||
CLOCK_CYCLES(is486 ? 3 : 7); \
|
||||
PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0,0,1,0, 0); \
|
||||
return cpu_state.abrt; \
|
||||
}
|
||||
|
||||
|
|
@ -443,7 +475,8 @@ static int opPOP_SS_w(uint32_t fetchdat)
|
|||
temp_seg = POP_W(); if (cpu_state.abrt) return 1;
|
||||
loadseg(temp_seg, &_ss); if (cpu_state.abrt) { ESP = temp_esp; return 1; }
|
||||
CLOCK_CYCLES(is486 ? 3 : 7);
|
||||
|
||||
PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0,0,1,0, 0);
|
||||
|
||||
cpu_state.oldpc = cpu_state.pc;
|
||||
cpu_state.op32 = use32;
|
||||
cpu_state.ssegs = 0;
|
||||
|
|
@ -462,6 +495,7 @@ static int opPOP_SS_l(uint32_t fetchdat)
|
|||
temp_seg = POP_L(); if (cpu_state.abrt) return 1;
|
||||
loadseg(temp_seg & 0xffff, &_ss); if (cpu_state.abrt) { ESP = temp_esp; return 1; }
|
||||
CLOCK_CYCLES(is486 ? 3 : 7);
|
||||
PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0,0,1,0, 0);
|
||||
|
||||
cpu_state.oldpc = cpu_state.pc;
|
||||
cpu_state.op32 = use32;
|
||||
|
|
|
|||
Loading…
Reference in a new issue