mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 09:35:32 -07:00
sonarlinting and formatting in src/cpu
This commit is contained in:
@@ -230,8 +230,12 @@ fetch_ea_16_long(uint32_t rmdat)
|
||||
void
|
||||
exec386_2386(int cycs)
|
||||
{
|
||||
int vector, tempi, cycdiff, oldcyc;
|
||||
int cycle_period, ins_cycles;
|
||||
int vector;
|
||||
int tempi;
|
||||
int cycdiff;
|
||||
int oldcyc;
|
||||
int cycle_period;
|
||||
int ins_cycles;
|
||||
uint32_t addr;
|
||||
|
||||
cycles += cycs;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "386_common.h"
|
||||
#include "x86_flags.h"
|
||||
#include "x86seg.h"
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
#ifdef USE_DYNAREC
|
||||
# include "codegen.h"
|
||||
@@ -34,19 +35,26 @@
|
||||
# define CPU_BLOCK_END()
|
||||
#endif
|
||||
|
||||
x86seg gdt, ldt, idt, tr;
|
||||
x86seg gdt;
|
||||
x86seg ldt;
|
||||
x86seg idt;
|
||||
x86seg tr;
|
||||
|
||||
uint32_t cr2, cr3, cr4;
|
||||
uint32_t cr2;
|
||||
uint32_t cr3;
|
||||
uint32_t cr4;
|
||||
uint32_t dr[8];
|
||||
|
||||
uint32_t use32;
|
||||
int stack32;
|
||||
|
||||
uint32_t *eal_r, *eal_w;
|
||||
uint32_t *eal_r;
|
||||
uint32_t *eal_w;
|
||||
|
||||
int nmi_enable = 1;
|
||||
|
||||
int alt_access, cpl_override = 0;
|
||||
int alt_access;
|
||||
int cpl_override = 0;
|
||||
|
||||
#ifdef USE_NEW_DYNAREC
|
||||
uint16_t cpu_cur_status = 0;
|
||||
@@ -59,23 +67,33 @@ extern uint8_t *pccache2;
|
||||
extern int optype;
|
||||
extern uint32_t pccache;
|
||||
|
||||
int in_sys = 0, unmask_a20_in_smm = 0;
|
||||
uint32_t old_rammask = 0xffffffff;
|
||||
int in_sys = 0;
|
||||
int unmask_a20_in_smm = 0;
|
||||
uint32_t old_rammask = 0xffffffff;
|
||||
|
||||
int soft_reset_mask = 0;
|
||||
|
||||
int smi_latched = 0;
|
||||
int smm_in_hlt = 0, smi_block = 0;
|
||||
int smm_in_hlt = 0;
|
||||
int smi_block = 0;
|
||||
|
||||
int prefetch_prefixes = 0;
|
||||
|
||||
int tempc, oldcpl, optype, inttype, oddeven = 0;
|
||||
int tempc;
|
||||
int oldcpl;
|
||||
int optype;
|
||||
int inttype;
|
||||
int oddeven = 0;
|
||||
int timetolive;
|
||||
|
||||
uint16_t oldcs;
|
||||
|
||||
uint32_t oldds, oldss, olddslimit, oldsslimit,
|
||||
olddslimitw, oldsslimitw;
|
||||
uint32_t oldds;
|
||||
uint32_t oldss;
|
||||
uint32_t olddslimit;
|
||||
uint32_t oldsslimit;
|
||||
uint32_t olddslimitw;
|
||||
uint32_t oldsslimitw;
|
||||
uint32_t oxpc;
|
||||
uint32_t rmdat32;
|
||||
uint32_t backupregs[16];
|
||||
@@ -99,8 +117,10 @@ int opcode_length[256] = { 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 3, 1, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 1, 1, 1, 1, /* 0xex */
|
||||
1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 3, 3 }; /* 0xfx */
|
||||
|
||||
uint32_t addr64, addr64_2;
|
||||
uint32_t addr64a[8], addr64a_2[8];
|
||||
uint32_t addr64;
|
||||
uint32_t addr64_2;
|
||||
uint32_t addr64a[8];
|
||||
uint32_t addr64a_2[8];
|
||||
|
||||
static pc_timer_t *cpu_fast_off_timer = NULL;
|
||||
static double cpu_fast_off_period = 0.0;
|
||||
@@ -494,12 +514,10 @@ smm_seg_load(x86seg *s)
|
||||
static void
|
||||
smram_save_state_p5(uint32_t *saved_state, int in_hlt)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
saved_state[SMRAM_FIELD_P5_SMM_REVISION_ID] = SMM_REVISION_ID;
|
||||
saved_state[SMRAM_FIELD_P5_SMBASE_OFFSET] = smbase;
|
||||
|
||||
for (n = 0; n < 8; n++)
|
||||
for (uint8_t n = 0; n < 8; n++)
|
||||
saved_state[SMRAM_FIELD_P5_EAX - n] = cpu_state.regs[n].l;
|
||||
|
||||
if (in_hlt)
|
||||
@@ -588,9 +606,7 @@ smram_save_state_p5(uint32_t *saved_state, int in_hlt)
|
||||
static void
|
||||
smram_restore_state_p5(uint32_t *saved_state)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
for (n = 0; n < 8; n++)
|
||||
for (uint8_t n = 0; n < 8; n++)
|
||||
cpu_state.regs[n].l = saved_state[SMRAM_FIELD_P5_EAX - n];
|
||||
|
||||
if (saved_state[SMRAM_FIELD_P5_AUTOHALT_RESTART] & 0xffff)
|
||||
@@ -701,12 +717,10 @@ smram_restore_state_p5(uint32_t *saved_state)
|
||||
static void
|
||||
smram_save_state_p6(uint32_t *saved_state, int in_hlt)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
saved_state[SMRAM_FIELD_P6_SMM_REVISION_ID] = SMM_REVISION_ID;
|
||||
saved_state[SMRAM_FIELD_P6_SMBASE_OFFSET] = smbase;
|
||||
|
||||
for (n = 0; n < 8; n++)
|
||||
for (uint8_t n = 0; n < 8; n++)
|
||||
saved_state[SMRAM_FIELD_P6_EAX - n] = cpu_state.regs[n].l;
|
||||
|
||||
if (in_hlt)
|
||||
@@ -787,9 +801,7 @@ smram_save_state_p6(uint32_t *saved_state, int in_hlt)
|
||||
static void
|
||||
smram_restore_state_p6(uint32_t *saved_state)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
for (n = 0; n < 8; n++)
|
||||
for (uint8_t n = 0; n < 8; n++)
|
||||
cpu_state.regs[n].l = saved_state[SMRAM_FIELD_P6_EAX - n];
|
||||
|
||||
if (saved_state[SMRAM_FIELD_P6_AUTOHALT_RESTART] & 0xffff)
|
||||
@@ -894,12 +906,10 @@ smram_restore_state_p6(uint32_t *saved_state)
|
||||
static void
|
||||
smram_save_state_amd_k(uint32_t *saved_state, int in_hlt)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
saved_state[SMRAM_FIELD_AMD_K_SMM_REVISION_ID] = SMM_REVISION_ID;
|
||||
saved_state[SMRAM_FIELD_AMD_K_SMBASE_OFFSET] = smbase;
|
||||
|
||||
for (n = 0; n < 8; n++)
|
||||
for (uint8_t n = 0; n < 8; n++)
|
||||
saved_state[SMRAM_FIELD_AMD_K_EAX - n] = cpu_state.regs[n].l;
|
||||
|
||||
if (in_hlt)
|
||||
@@ -979,9 +989,7 @@ smram_save_state_amd_k(uint32_t *saved_state, int in_hlt)
|
||||
static void
|
||||
smram_restore_state_amd_k(uint32_t *saved_state)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
for (n = 0; n < 8; n++)
|
||||
for (uint8_t n = 0; n < 8; n++)
|
||||
cpu_state.regs[n].l = saved_state[SMRAM_FIELD_AMD_K_EAX - n];
|
||||
|
||||
if (saved_state[SMRAM_FIELD_AMD_K_AUTOHALT_RESTART] & 0xffff)
|
||||
@@ -1080,7 +1088,7 @@ smram_restore_state_amd_k(uint32_t *saved_state)
|
||||
}
|
||||
|
||||
static void
|
||||
smram_save_state_cyrix(uint32_t *saved_state, int in_hlt)
|
||||
smram_save_state_cyrix(uint32_t *saved_state, UNUSED(int in_hlt))
|
||||
{
|
||||
saved_state[0] = dr[7];
|
||||
saved_state[1] = cpu_state.flags | (cpu_state.eflags << 16);
|
||||
@@ -1104,7 +1112,7 @@ smram_restore_state_cyrix(uint32_t *saved_state)
|
||||
void
|
||||
enter_smm(int in_hlt)
|
||||
{
|
||||
uint32_t saved_state[SMM_SAVE_STATE_MAP_SIZE], n;
|
||||
uint32_t saved_state[SMM_SAVE_STATE_MAP_SIZE];
|
||||
uint32_t smram_state = smbase + 0x10000;
|
||||
|
||||
/* If it's a CPU on which SMM is not supported, do nothing. */
|
||||
@@ -1231,7 +1239,7 @@ enter_smm(int in_hlt)
|
||||
writememl(0, smram_state - 0x18, saved_state[5]);
|
||||
writememl(0, smram_state - 0x24, saved_state[6]);
|
||||
} else {
|
||||
for (n = 0; n < SMM_SAVE_STATE_MAP_SIZE; n++) {
|
||||
for (uint8_t n = 0; n < SMM_SAVE_STATE_MAP_SIZE; n++) {
|
||||
smram_state -= 4;
|
||||
writememl(0, smram_state, saved_state[n]);
|
||||
}
|
||||
@@ -1291,7 +1299,7 @@ enter_smm_check(int in_hlt)
|
||||
void
|
||||
leave_smm(void)
|
||||
{
|
||||
uint32_t saved_state[SMM_SAVE_STATE_MAP_SIZE], n;
|
||||
uint32_t saved_state[SMM_SAVE_STATE_MAP_SIZE];
|
||||
uint32_t smram_state = smbase + 0x10000;
|
||||
|
||||
/* If it's a CPU on which SMM is not supported (or not implemented in 86Box), do nothing. */
|
||||
@@ -1312,7 +1320,7 @@ leave_smm(void)
|
||||
cyrix_load_seg_descriptor(smram_state - 0x20, &cpu_state.seg_cs);
|
||||
saved_state[6] = readmeml(0, smram_state - 0x24);
|
||||
} else {
|
||||
for (n = 0; n < SMM_SAVE_STATE_MAP_SIZE; n++) {
|
||||
for (uint8_t n = 0; n < SMM_SAVE_STATE_MAP_SIZE; n++) {
|
||||
smram_state -= 4;
|
||||
saved_state[n] = readmeml(0, smram_state);
|
||||
x386_common_log("Reading %08X from memory at %08X to array element %i\n", saved_state[n], smram_state, n);
|
||||
@@ -1483,7 +1491,8 @@ int
|
||||
x86_int_sw_rm(int num)
|
||||
{
|
||||
uint32_t addr;
|
||||
uint16_t new_pc, new_cs;
|
||||
uint16_t new_pc;
|
||||
uint16_t new_cs;
|
||||
|
||||
flags_rebuild();
|
||||
cycles -= timing_int;
|
||||
@@ -1571,8 +1580,10 @@ checkio(uint32_t port, int mask)
|
||||
int
|
||||
divl(uint32_t val)
|
||||
{
|
||||
uint64_t num, quo;
|
||||
uint32_t rem, quo32;
|
||||
uint64_t num;
|
||||
uint64_t quo;
|
||||
uint32_t rem;
|
||||
uint32_t quo32;
|
||||
|
||||
if (val == 0) {
|
||||
divexcp();
|
||||
@@ -1598,8 +1609,10 @@ divl(uint32_t val)
|
||||
int
|
||||
idivl(int32_t val)
|
||||
{
|
||||
int64_t num, quo;
|
||||
int32_t rem, quo32;
|
||||
int64_t num;
|
||||
int64_t quo;
|
||||
int32_t rem;
|
||||
int32_t quo32;
|
||||
|
||||
if (val == 0) {
|
||||
divexcp();
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
|
||||
#define CPU_BLOCK_END() cpu_block_end = 1
|
||||
|
||||
int inrecomp = 0, cpu_block_end = 0;
|
||||
int inrecomp = 0;
|
||||
int cpu_block_end = 0;
|
||||
int cpu_end_block_after_ins = 0;
|
||||
|
||||
#ifdef ENABLE_386_DYNAREC_LOG
|
||||
@@ -334,7 +335,8 @@ exec386_dynarec_int(void)
|
||||
static __inline void
|
||||
exec386_dynarec_dyn(void)
|
||||
{
|
||||
uint32_t start_pc = 0, phys_addr = get_phys(cs + cpu_state.pc);
|
||||
uint32_t start_pc = 0;
|
||||
uint32_t phys_addr = get_phys(cs + cpu_state.pc);
|
||||
int hash = HASH(phys_addr);
|
||||
# ifdef USE_NEW_DYNAREC
|
||||
codeblock_t *block = &codeblock[codeblock_hash[hash]];
|
||||
@@ -674,10 +676,13 @@ exec386_dynarec_dyn(void)
|
||||
void
|
||||
exec386_dynarec(int cycs)
|
||||
{
|
||||
int vector, tempi;
|
||||
int vector;
|
||||
int tempi;
|
||||
int cycdiff;
|
||||
int oldcyc, oldcyc2;
|
||||
uint64_t oldtsc, delta;
|
||||
int oldcyc;
|
||||
int oldcyc2;
|
||||
uint64_t oldtsc;
|
||||
uint64_t delta;
|
||||
|
||||
int cyc_period = cycs / 2000; /*5us*/
|
||||
|
||||
@@ -794,8 +799,12 @@ exec386_dynarec(int cycs)
|
||||
void
|
||||
exec386(int cycs)
|
||||
{
|
||||
int vector, tempi, cycdiff, oldcyc;
|
||||
int cycle_period, ins_cycles;
|
||||
int vector;
|
||||
int tempi;
|
||||
int cycdiff;
|
||||
int oldcyc;
|
||||
int cycle_period;
|
||||
int ins_cycles;
|
||||
uint32_t addr;
|
||||
|
||||
cycles += cycs;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <86box/pic.h>
|
||||
#include <86box/gdbstub.h>
|
||||
#include "codegen.h"
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
#define CPU_BLOCK_END() cpu_block_end = 1
|
||||
|
||||
@@ -31,7 +32,7 @@
|
||||
#include "386_common.h"
|
||||
|
||||
static __inline void
|
||||
fetch_ea_32_long(uint32_t rmdat)
|
||||
fetch_ea_32_long(UNUSED(uint32_t rmdat))
|
||||
{
|
||||
eal_r = eal_w = NULL;
|
||||
easeg = cpu_state.ea_seg->base;
|
||||
@@ -45,7 +46,7 @@ fetch_ea_32_long(uint32_t rmdat)
|
||||
}
|
||||
|
||||
static __inline void
|
||||
fetch_ea_16_long(uint32_t rmdat)
|
||||
fetch_ea_16_long(UNUSED(uint32_t rmdat))
|
||||
{
|
||||
eal_r = eal_w = NULL;
|
||||
easeg = cpu_state.ea_seg->base;
|
||||
|
||||
@@ -19,15 +19,21 @@
|
||||
#include <86box/timer.h>
|
||||
#include <86box/i8080.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
static int completed = 1;
|
||||
static int in_rep = 0, repeating = 0, rep_c_flag = 0;
|
||||
static int oldc, cycdiff;
|
||||
static int completed = 1;
|
||||
static int in_rep = 0;
|
||||
static int repeating = 0;
|
||||
static int rep_c_flag = 0;
|
||||
static int oldc;
|
||||
static int cycdiff;
|
||||
#ifdef UNUSED_8080_VARS
|
||||
static int prefetching = 1;
|
||||
static int refresh = 0, clear_lock = 0;
|
||||
static int refresh = 0;
|
||||
static int clear_lock = 0;
|
||||
|
||||
static uint32_t cpu_src = 0, cpu_dest = 0;
|
||||
static uint32_t cpu_src = 0;
|
||||
static uint32_t cpu_dest = 0;
|
||||
static uint32_t cpu_data = 0;
|
||||
#endif
|
||||
|
||||
@@ -43,7 +49,7 @@ clock_end(void)
|
||||
int diff = cycdiff - cycles;
|
||||
|
||||
/* On 808x systems, clock speed is usually crystal frequency divided by an integer. */
|
||||
tsc += (uint64_t) diff * ((uint64_t) xt_cpu_multi >> 32ULL); /* Shift xt_cpu_multi by 32 bits to the right and then multiply. */
|
||||
tsc += (uint64_t) diff * (xt_cpu_multi >> 32ULL); /* Shift xt_cpu_multi by 32 bits to the right and then multiply. */
|
||||
if (TIMER_VAL_LESS_THAN_VAL(timer_target, (uint32_t) tsc))
|
||||
timer_process();
|
||||
}
|
||||
@@ -237,7 +243,7 @@ setreg_i8080(i8080 *cpu, uint8_t reg, uint8_t val)
|
||||
}
|
||||
|
||||
void
|
||||
interpret_exec8080(i8080 *cpu, uint8_t opcode)
|
||||
interpret_exec8080(UNUSED(i8080 *cpu), uint8_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case 0x00:
|
||||
|
||||
184
src/cpu/808x.c
184
src/cpu/808x.c
@@ -35,6 +35,8 @@
|
||||
#include <86box/ppi.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/gdbstub.h>
|
||||
#include <86box/plat_fallthrough.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
/* Is the CPU 8088 or 8086. */
|
||||
int is8086 = 0;
|
||||
@@ -46,7 +48,8 @@ uint32_t custom_nmi_vector = 0x00000000;
|
||||
static uint8_t pfq[6];
|
||||
|
||||
/* Variables to aid with the prefetch queue operation. */
|
||||
static int biu_cycles = 0, pfq_pos = 0;
|
||||
static int biu_cycles = 0;
|
||||
static int pfq_pos = 0;
|
||||
|
||||
/* The IP equivalent of the current prefetch queue position. */
|
||||
static uint16_t pfq_ip;
|
||||
@@ -57,30 +60,37 @@ static x86seg *_opseg[4];
|
||||
|
||||
static int noint = 0;
|
||||
static int in_lock = 0;
|
||||
static int cpu_alu_op, pfq_size;
|
||||
static int cpu_alu_op;
|
||||
static int pfq_size;
|
||||
|
||||
static uint32_t cpu_src = 0, cpu_dest = 0;
|
||||
static uint32_t cpu_src = 0;
|
||||
static uint32_t cpu_dest = 0;
|
||||
static uint32_t cpu_data = 0;
|
||||
|
||||
static uint16_t last_addr = 0x0000;
|
||||
|
||||
static uint32_t *ovr_seg = NULL;
|
||||
static int prefetching = 1, completed = 1;
|
||||
static int in_rep = 0, repeating = 0, rep_c_flag = 0;
|
||||
static int oldc, clear_lock = 0;
|
||||
static int refresh = 0, cycdiff;
|
||||
static int prefetching = 1;
|
||||
static int completed = 1;
|
||||
static int in_rep = 0;
|
||||
static int repeating = 0;
|
||||
static int rep_c_flag = 0;
|
||||
static int oldc;
|
||||
static int clear_lock = 0;
|
||||
static int refresh = 0;
|
||||
static int cycdiff;
|
||||
|
||||
static int access_code = 0;
|
||||
static int hlda = 0;
|
||||
static int not_ready = 0;
|
||||
static int access_code = 0;
|
||||
static int hlda = 0;
|
||||
static int not_ready = 0;
|
||||
static int bus_request_type = 0;
|
||||
static int pic_data = -1;
|
||||
static int last_was_code = 0;
|
||||
static uint16_t mem_data = 0;
|
||||
static uint32_t mem_seg = 0;
|
||||
static uint16_t mem_addr = 0;
|
||||
static int schedule_fetch = 1;
|
||||
static int pasv = 0;
|
||||
static int pic_data = -1;
|
||||
static int last_was_code = 0;
|
||||
static uint16_t mem_data = 0;
|
||||
static uint32_t mem_seg = 0;
|
||||
static uint16_t mem_addr = 0;
|
||||
static int schedule_fetch = 1;
|
||||
static int pasv = 0;
|
||||
|
||||
#define BUS_OUT 1
|
||||
#define BUS_HIGH 2
|
||||
@@ -204,7 +214,7 @@ clock_end(void)
|
||||
int diff = cycdiff - cycles;
|
||||
|
||||
/* On 808x systems, clock speed is usually crystal frequency divided by an integer. */
|
||||
tsc += ((uint64_t) diff * ((uint64_t) xt_cpu_multi >> 32ULL)); /* Shift xt_cpu_multi by 32 bits to the right and then multiply. */
|
||||
tsc += ((uint64_t) diff * (xt_cpu_multi >> 32ULL)); /* Shift xt_cpu_multi by 32 bits to the right and then multiply. */
|
||||
if (TIMER_VAL_LESS_THAN_VAL(timer_target, (uint32_t) tsc))
|
||||
timer_process();
|
||||
}
|
||||
@@ -423,9 +433,7 @@ run_dma_cycle(int idle)
|
||||
static void
|
||||
cycles_idle(int c)
|
||||
{
|
||||
int d;
|
||||
|
||||
for (d = 0; d < c; d++) {
|
||||
for (int d = 0; d < c; d++) {
|
||||
x808x_log("[%04X:%04X] %02X TI\n", CS, cpu_state.pc, opcode);
|
||||
|
||||
cycles_forward(1);
|
||||
@@ -500,14 +508,12 @@ bus_init(void)
|
||||
static void
|
||||
wait(int c, int bus)
|
||||
{
|
||||
int d;
|
||||
|
||||
if (c < 0)
|
||||
pclog("Negative cycles: %i!\n", c);
|
||||
|
||||
x808x_log("[%04X:%04X] %02X %i cycles (%i)\n", CS, cpu_state.pc, opcode, c, bus);
|
||||
|
||||
for (d = 0; d < c; d++) {
|
||||
for (int d = 0; d < c; d++) {
|
||||
x808x_log("[%04X:%04X] %02X cycle %i BIU\n", CS, cpu_state.pc, opcode, d);
|
||||
cycles_biu(bus, !d);
|
||||
x808x_log("[%04X:%04X] %02X cycle %i EU\n", CS, cpu_state.pc, opcode, d);
|
||||
@@ -530,12 +536,12 @@ sub_cycles(int c)
|
||||
void
|
||||
resub_cycles(int old_cycles)
|
||||
{
|
||||
int i, cyc_diff = 0;
|
||||
int cyc_diff = 0;
|
||||
|
||||
if (old_cycles > cycles) {
|
||||
cyc_diff = old_cycles - cycles;
|
||||
|
||||
for (i = 0; i < cyc_diff; i++) {
|
||||
for (int i = 0; i < cyc_diff; i++) {
|
||||
if (not_ready > 0)
|
||||
not_ready--;
|
||||
}
|
||||
@@ -934,7 +940,7 @@ reset_808x(int hard)
|
||||
_opseg[2] = &cpu_state.seg_ss;
|
||||
_opseg[3] = &cpu_state.seg_ds;
|
||||
|
||||
pfq_size = (is8086) ? 6 : 4;
|
||||
pfq_size = is8086 ? 6 : 4;
|
||||
pfq_clear();
|
||||
}
|
||||
|
||||
@@ -1205,8 +1211,10 @@ pop(void)
|
||||
static void
|
||||
interrupt(uint16_t addr)
|
||||
{
|
||||
uint16_t old_cs, old_ip;
|
||||
uint16_t new_cs, new_ip;
|
||||
uint16_t old_cs;
|
||||
uint16_t old_ip;
|
||||
uint16_t new_cs;
|
||||
uint16_t new_ip;
|
||||
uint16_t tempf;
|
||||
|
||||
addr <<= 2;
|
||||
@@ -1242,8 +1250,10 @@ interrupt_808x(uint16_t addr)
|
||||
static void
|
||||
custom_nmi(void)
|
||||
{
|
||||
uint16_t old_cs, old_ip;
|
||||
uint16_t new_cs, new_ip;
|
||||
uint16_t old_cs;
|
||||
uint16_t old_ip;
|
||||
uint16_t new_cs;
|
||||
uint16_t new_ip;
|
||||
uint16_t tempf;
|
||||
|
||||
cpu_state.eaaddr = 0x0002;
|
||||
@@ -1376,7 +1386,7 @@ rep_interrupt(void)
|
||||
}
|
||||
|
||||
static int
|
||||
rep_action(int bits)
|
||||
rep_action(UNUSED(int bits))
|
||||
{
|
||||
uint16_t t;
|
||||
|
||||
@@ -1562,14 +1572,14 @@ alu_op(int bits)
|
||||
case 2:
|
||||
if (cpu_state.flags & C_FLAG)
|
||||
cpu_src++;
|
||||
/* Fall through. */
|
||||
fallthrough;
|
||||
case 0:
|
||||
add(bits);
|
||||
break;
|
||||
case 3:
|
||||
if (cpu_state.flags & C_FLAG)
|
||||
cpu_src++;
|
||||
/* Fall through. */
|
||||
fallthrough;
|
||||
case 5:
|
||||
case 7:
|
||||
sub(bits);
|
||||
@@ -1600,10 +1610,11 @@ mul(uint16_t a, uint16_t b)
|
||||
{
|
||||
int negate = 0;
|
||||
int bit_count = 8;
|
||||
int carry, i;
|
||||
int carry;
|
||||
uint16_t high_bit = 0x80;
|
||||
uint16_t size_mask;
|
||||
uint16_t c, r;
|
||||
uint16_t c;
|
||||
uint16_t r;
|
||||
|
||||
size_mask = (1 << bit_count) - 1;
|
||||
|
||||
@@ -1644,7 +1655,7 @@ mul(uint16_t a, uint16_t b)
|
||||
a &= size_mask;
|
||||
carry = (a & 1) != 0;
|
||||
a >>= 1;
|
||||
for (i = 0; i < bit_count; ++i) {
|
||||
for (int i = 0; i < bit_count; ++i) {
|
||||
wait(7, 0);
|
||||
if (carry) {
|
||||
cpu_src = c;
|
||||
@@ -1705,7 +1716,7 @@ set_pzs(int bits)
|
||||
}
|
||||
|
||||
static void
|
||||
set_co_mul(int bits, int carry)
|
||||
set_co_mul(UNUSED(int bits), int carry)
|
||||
{
|
||||
set_cf(carry);
|
||||
set_of(carry);
|
||||
@@ -1718,10 +1729,11 @@ set_co_mul(int bits, int carry)
|
||||
static int
|
||||
x86_div(uint16_t l, uint16_t h)
|
||||
{
|
||||
int b, bit_count = 8;
|
||||
int bit_count = 8;
|
||||
int negative = 0;
|
||||
int dividend_negative = 0;
|
||||
int size_mask, carry;
|
||||
int size_mask;
|
||||
int carry;
|
||||
uint16_t r;
|
||||
|
||||
if (opcode & 1) {
|
||||
@@ -1765,7 +1777,7 @@ x86_div(uint16_t l, uint16_t h)
|
||||
wait(1, 0);
|
||||
wait(2, 0);
|
||||
carry = 1;
|
||||
for (b = 0; b < bit_count; ++b) {
|
||||
for (int b = 0; b < bit_count; ++b) {
|
||||
r = (l << 1) + (carry ? 1 : 0);
|
||||
carry = top_bit(l, bit_count);
|
||||
l = r;
|
||||
@@ -1948,20 +1960,46 @@ cpu_outw(uint16_t port, uint16_t val)
|
||||
void
|
||||
execx86(int cycs)
|
||||
{
|
||||
uint8_t temp = 0, temp2, old_af, nests;
|
||||
uint8_t temp_val, temp_al, bit, handled = 0;
|
||||
uint8_t odd, zero, nibbles_count, destcmp;
|
||||
uint8_t destbyte, srcbyte, nibble_result, bit_length;
|
||||
uint8_t temp = 0;
|
||||
uint8_t temp2;
|
||||
uint8_t old_af;
|
||||
uint8_t nests;
|
||||
uint8_t temp_val;
|
||||
uint8_t temp_al;
|
||||
uint8_t bit;
|
||||
uint8_t handled = 0;
|
||||
uint8_t odd;
|
||||
uint8_t zero;
|
||||
uint8_t nibbles_count;
|
||||
uint8_t destcmp;
|
||||
uint8_t destbyte;
|
||||
uint8_t srcbyte;
|
||||
uint8_t nibble_result;
|
||||
uint8_t bit_length;
|
||||
uint8_t bit_offset;
|
||||
int8_t nibble_result_s;
|
||||
uint16_t addr, tempw, new_cs, new_ip;
|
||||
uint16_t tempw_int, size, tempbp, lowbound;
|
||||
uint16_t highbound, regval, orig_sp, wordtopush;
|
||||
uint16_t immediate, old_flags;
|
||||
uint16_t tmpa;
|
||||
uint16_t addr;
|
||||
uint16_t tempw;
|
||||
uint16_t new_cs;
|
||||
uint16_t new_ip;
|
||||
uint16_t tempw_int;
|
||||
uint16_t size;
|
||||
uint16_t tempbp;
|
||||
uint16_t lowbound;
|
||||
uint16_t highbound;
|
||||
uint16_t regval;
|
||||
uint16_t orig_sp;
|
||||
uint16_t wordtopush;
|
||||
uint16_t immediate;
|
||||
uint16_t old_flags;
|
||||
uint16_t tmpa;
|
||||
int bits;
|
||||
uint32_t dest_seg, i, carry, nibble;
|
||||
uint32_t srcseg, byteaddr;
|
||||
uint32_t dest_seg;
|
||||
uint32_t i;
|
||||
uint32_t carry;
|
||||
uint32_t nibble;
|
||||
uint32_t srcseg;
|
||||
uint32_t byteaddr;
|
||||
|
||||
cycles += cycs;
|
||||
|
||||
@@ -1970,7 +2008,9 @@ execx86(int cycs)
|
||||
|
||||
if (!repeating) {
|
||||
cpu_state.oldpc = cpu_state.pc;
|
||||
// opcode = pfq_fetchb();
|
||||
#if 0
|
||||
opcode = pfq_fetchb();
|
||||
#endif
|
||||
opcode = pfq_fetchb_common();
|
||||
handled = 0;
|
||||
oldc = cpu_state.flags & C_FLAG;
|
||||
@@ -2498,7 +2538,7 @@ execx86(int cycs)
|
||||
}
|
||||
for (i = 0; i < bit_length; i++) {
|
||||
byteaddr = (es) + DI;
|
||||
writememb(es, DI, (read_mem_b(byteaddr) & ~(1 << (bit_offset))) | ((!!(AX & (1 << i))) << bit_offset));
|
||||
writememb(es, DI, (read_mem_b(byteaddr) & ~(1 << bit_offset)) | ((!!(AX & (1 << i))) << bit_offset));
|
||||
bit_offset++;
|
||||
if (bit_offset == 8) {
|
||||
DI++;
|
||||
@@ -3063,7 +3103,7 @@ execx86(int cycs)
|
||||
bits = 8 << (opcode & 1);
|
||||
wait(2, 0);
|
||||
cpu_state.eaaddr = pfq_fetchw();
|
||||
set_accum(bits, readmem((ovr_seg ? *ovr_seg : ds)));
|
||||
set_accum(bits, readmem(ovr_seg ? *ovr_seg : ds));
|
||||
break;
|
||||
case 0xA2:
|
||||
case 0xA3:
|
||||
@@ -3453,55 +3493,55 @@ execx86(int cycs)
|
||||
if (fpu_softfloat) {
|
||||
switch (opcode) {
|
||||
case 0xD8:
|
||||
ops_sf_fpu_8087_d8[(rmdat >> 3) & 0x1f]((uint32_t) rmdat);
|
||||
ops_sf_fpu_8087_d8[(rmdat >> 3) & 0x1f](rmdat);
|
||||
break;
|
||||
case 0xD9:
|
||||
ops_sf_fpu_8087_d9[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_sf_fpu_8087_d9[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDA:
|
||||
ops_sf_fpu_8087_da[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_sf_fpu_8087_da[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDB:
|
||||
ops_sf_fpu_8087_db[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_sf_fpu_8087_db[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDC:
|
||||
ops_sf_fpu_8087_dc[(rmdat >> 3) & 0x1f]((uint32_t) rmdat);
|
||||
ops_sf_fpu_8087_dc[(rmdat >> 3) & 0x1f](rmdat);
|
||||
break;
|
||||
case 0xDD:
|
||||
ops_sf_fpu_8087_dd[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_sf_fpu_8087_dd[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDE:
|
||||
ops_sf_fpu_8087_de[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_sf_fpu_8087_de[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDF:
|
||||
ops_sf_fpu_8087_df[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_sf_fpu_8087_df[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (opcode) {
|
||||
case 0xD8:
|
||||
ops_fpu_8087_d8[(rmdat >> 3) & 0x1f]((uint32_t) rmdat);
|
||||
ops_fpu_8087_d8[(rmdat >> 3) & 0x1f](rmdat);
|
||||
break;
|
||||
case 0xD9:
|
||||
ops_fpu_8087_d9[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_fpu_8087_d9[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDA:
|
||||
ops_fpu_8087_da[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_fpu_8087_da[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDB:
|
||||
ops_fpu_8087_db[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_fpu_8087_db[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDC:
|
||||
ops_fpu_8087_dc[(rmdat >> 3) & 0x1f]((uint32_t) rmdat);
|
||||
ops_fpu_8087_dc[(rmdat >> 3) & 0x1f](rmdat);
|
||||
break;
|
||||
case 0xDD:
|
||||
ops_fpu_8087_dd[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_fpu_8087_dd[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDE:
|
||||
ops_fpu_8087_de[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_fpu_8087_de[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
case 0xDF:
|
||||
ops_fpu_8087_df[rmdat & 0xff]((uint32_t) rmdat);
|
||||
ops_fpu_8087_df[rmdat & 0xff](rmdat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3800,7 +3840,7 @@ execx86(int cycs)
|
||||
if (cpu_mod != 3)
|
||||
wait(1, 0);
|
||||
wait(4, 0);
|
||||
push((uint16_t *) &(cpu_data));
|
||||
push((uint16_t *) &cpu_data);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -44,8 +44,7 @@
|
||||
|
||||
/* NOTE: When porting from Rust to C, please use uintptr_t and not size_t,
|
||||
so it can be printed with PRIuPTR. */
|
||||
typedef struct queue_t
|
||||
{
|
||||
typedef struct queue_t {
|
||||
uintptr_t size;
|
||||
uintptr_t len;
|
||||
uintptr_t back;
|
||||
|
||||
@@ -17,27 +17,26 @@
|
||||
#ifndef EMU_QUEUE_H
|
||||
#define EMU_QUEUE_H
|
||||
|
||||
typedef enum queue_delay_t
|
||||
{
|
||||
typedef enum queue_delay_t {
|
||||
DELAY_READ,
|
||||
DELAY_WRITE,
|
||||
DELAY_NONE
|
||||
} queue_delay_t;
|
||||
|
||||
#define FLAG_PRELOADED 0x8000
|
||||
#define FLAG_PRELOADED 0x8000
|
||||
|
||||
extern void queue_set_size(uintptr_t size);
|
||||
extern uintptr_t queue_get_len(void);
|
||||
extern int queue_is_full(void);
|
||||
extern uint16_t queue_get_preload(void);
|
||||
extern int queue_has_preload(void);
|
||||
extern void queue_set_preload(void);
|
||||
extern void queue_push8(uint8_t byte);
|
||||
extern void queue_push16(uint16_t word);
|
||||
extern uint8_t queue_pop(void);
|
||||
extern queue_delay_t queue_get_delay(void);
|
||||
extern void queue_flush(void);
|
||||
extern void queue_set_size(uintptr_t size);
|
||||
extern uintptr_t queue_get_len(void);
|
||||
extern int queue_is_full(void);
|
||||
extern uint16_t queue_get_preload(void);
|
||||
extern int queue_has_preload(void);
|
||||
extern void queue_set_preload(void);
|
||||
extern void queue_push8(uint8_t byte);
|
||||
extern void queue_push16(uint16_t word);
|
||||
extern uint8_t queue_pop(void);
|
||||
extern queue_delay_t queue_get_delay(void);
|
||||
extern void queue_flush(void);
|
||||
|
||||
extern void queue_init(void);
|
||||
extern void queue_init(void);
|
||||
|
||||
#endif /*EMU_QUEUE_H*/
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/mem.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/mem.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
#include "x86.h"
|
||||
#include "x86_ops.h"
|
||||
#include "x87.h"
|
||||
@@ -12,11 +14,11 @@
|
||||
#include "codegen_ops.h"
|
||||
#include "codegen_timing_common.h"
|
||||
|
||||
#define CYCLES(c) (int *)c
|
||||
#define CYCLES2(c16, c32) (int *)((-1 & ~0xffff) | c16 | (c32 << 8))
|
||||
#define CYCLES(c) (int *) c
|
||||
#define CYCLES2(c16, c32) (int *) ((-1 & ~0xffff) | c16 | (c32 << 8))
|
||||
|
||||
static int *opcode_timings[256] =
|
||||
{
|
||||
static int *opcode_timings[256] = {
|
||||
// clang-format off
|
||||
/*00*/ &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3), &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(2), NULL,
|
||||
/*10*/ &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3), &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3),
|
||||
/*20*/ &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(4), CYCLES(3), &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(4), CYCLES(3),
|
||||
@@ -36,10 +38,11 @@ static int *opcode_timings[256] =
|
||||
/*d0*/ CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(15), CYCLES(14), CYCLES(2), CYCLES(4), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*e0*/ CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(5), CYCLES(14), CYCLES(14), CYCLES(16), CYCLES(16), CYCLES(3), CYCLES(3), CYCLES(17), CYCLES(3), CYCLES(14), CYCLES(14), CYCLES(14), CYCLES(14),
|
||||
/*f0*/ CYCLES(4), CYCLES(0), CYCLES(0), CYCLES(0), CYCLES(4), CYCLES(2), NULL, NULL, CYCLES(2), CYCLES(2), CYCLES(3), CYCLES(2), CYCLES(2), CYCLES(2), CYCLES(3), NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_mod3[256] =
|
||||
{
|
||||
static int *opcode_timings_mod3[256] = {
|
||||
// clang-format off
|
||||
/*00*/ &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3), &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(2), NULL,
|
||||
/*10*/ &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3), &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3),
|
||||
/*20*/ &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(4), CYCLES(3), &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(4), CYCLES(3),
|
||||
@@ -59,10 +62,11 @@ static int *opcode_timings_mod3[256] =
|
||||
/*d0*/ CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(15), CYCLES(14), CYCLES(2), CYCLES(4), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*e0*/ CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(5), CYCLES(14), CYCLES(14), CYCLES(16), CYCLES(16), CYCLES(3), CYCLES(3), CYCLES(17), CYCLES(3), CYCLES(14), CYCLES(14), CYCLES(14), CYCLES(14),
|
||||
/*f0*/ CYCLES(4), CYCLES(0), CYCLES(0), CYCLES(0), CYCLES(4), CYCLES(2), NULL, NULL, CYCLES(2), CYCLES(2), CYCLES(3), CYCLES(2), CYCLES(2), CYCLES(2), CYCLES(3), NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_0f[256] =
|
||||
{
|
||||
static int *opcode_timings_0f[256] = {
|
||||
// clang-format off
|
||||
/*00*/ CYCLES(20), CYCLES(11), CYCLES(11), CYCLES(10), NULL, CYCLES(195), CYCLES(7), NULL, CYCLES(1000), CYCLES(10000), NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*10*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*20*/ CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -82,9 +86,10 @@ static int *opcode_timings_0f[256] =
|
||||
/*d0*/ NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm, NULL, NULL, &timing_rm, &timing_rm, NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm,
|
||||
/*e0*/ NULL, &timing_rm, &timing_rm, NULL, NULL, &timing_rm, NULL, NULL, &timing_rm, &timing_rm, NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm,
|
||||
/*f0*/ NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm, NULL, NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm, &timing_rm, &timing_rm, NULL,
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_0f_mod3[256] =
|
||||
{
|
||||
static int *opcode_timings_0f_mod3[256] = {
|
||||
// clang-format off
|
||||
/*00*/ CYCLES(20), CYCLES(11), CYCLES(11), CYCLES(10), NULL, CYCLES(195), CYCLES(7), NULL, CYCLES(1000), CYCLES(10000), NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*10*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*20*/ CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -104,60 +109,69 @@ static int *opcode_timings_0f_mod3[256] =
|
||||
/*d0*/ NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr, NULL, NULL, &timing_rr, &timing_rr, NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr,
|
||||
/*e0*/ NULL, &timing_rr, &timing_rr, NULL, NULL, &timing_rr, NULL, NULL, &timing_rr, &timing_rr, NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr,
|
||||
/*f0*/ NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr, NULL, NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr, &timing_rr, &timing_rr, NULL,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_shift[8] =
|
||||
{
|
||||
static int *opcode_timings_shift[8] = {
|
||||
// clang-format off
|
||||
CYCLES(7), CYCLES(7), CYCLES(10), CYCLES(10), CYCLES(7), CYCLES(7), CYCLES(7), CYCLES(7)
|
||||
};
|
||||
static int *opcode_timings_shift_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_shift_mod3[8] = {
|
||||
// clang-format off
|
||||
CYCLES(3), CYCLES(3), CYCLES(9), CYCLES(9), CYCLES(3), CYCLES(3), CYCLES(3), CYCLES(3)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_f6[8] =
|
||||
{
|
||||
static int *opcode_timings_f6[8] = {
|
||||
// clang-format off
|
||||
&timing_rm, NULL, &timing_mm, &timing_mm, CYCLES(13), CYCLES(14), CYCLES(16), CYCLES(19)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_f6_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_f6_mod3[8] = {
|
||||
// clang-format off
|
||||
&timing_rr, NULL, &timing_rr, &timing_rr, CYCLES(13), CYCLES(14), CYCLES(16), CYCLES(19)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_f7[8] =
|
||||
{
|
||||
static int *opcode_timings_f7[8] = {
|
||||
// clang-format off
|
||||
&timing_rm, NULL, &timing_mm, &timing_mm, CYCLES(21), CYCLES2(22,38), CYCLES2(24,40), CYCLES2(27,43)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_f7_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_f7_mod3[8] = {
|
||||
// clang-format off
|
||||
&timing_rr, NULL, &timing_rr, &timing_rr, CYCLES(21), CYCLES2(22,38), CYCLES2(24,40), CYCLES2(27,43)
|
||||
};
|
||||
static int *opcode_timings_ff[8] =
|
||||
{
|
||||
static int *opcode_timings_ff[8] = {
|
||||
// clang-format off
|
||||
&timing_mm, &timing_mm, CYCLES(5), CYCLES(0), CYCLES(5), CYCLES(0), CYCLES(5), NULL
|
||||
};
|
||||
static int *opcode_timings_ff_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_ff_mod3[8] = {
|
||||
// clang-format off
|
||||
&timing_rr, &timing_rr, CYCLES(5), CYCLES(0), CYCLES(5), CYCLES(0), CYCLES(5), NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_d8[8] =
|
||||
{
|
||||
static int *opcode_timings_d8[8] = {
|
||||
// clang-format off
|
||||
/* FADDil FMULil FCOMil FCOMPil FSUBil FSUBRil FDIVil FDIVRil*/
|
||||
CYCLES(8), CYCLES(11), CYCLES(4), CYCLES(4), CYCLES(8), CYCLES(8), CYCLES(73), CYCLES(73)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_d8_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_d8_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FADD FMUL FCOM FCOMP FSUB FSUBR FDIV FDIVR*/
|
||||
CYCLES(8), CYCLES(16), CYCLES(4), CYCLES(4), CYCLES(8), CYCLES(8), CYCLES(73), CYCLES(73)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_d9[8] =
|
||||
{
|
||||
static int *opcode_timings_d9[8] = {
|
||||
// clang-format off
|
||||
/* FLDs FSTs FSTPs FLDENV FLDCW FSTENV FSTCW*/
|
||||
CYCLES(3), NULL, CYCLES(7), CYCLES(7), CYCLES(34), CYCLES(4), CYCLES(67), CYCLES(3)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_d9_mod3[64] =
|
||||
{
|
||||
static int *opcode_timings_d9_mod3[64] = {
|
||||
// clang-format off
|
||||
/*FLD*/
|
||||
CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4),
|
||||
/*FXCH*/
|
||||
@@ -174,26 +188,29 @@ static int *opcode_timings_d9_mod3[64] =
|
||||
CYCLES(140), CYCLES(196), CYCLES(200), CYCLES(218), NULL, NULL, CYCLES(3), CYCLES(3),
|
||||
/* opFPREM opFSQRT opFSINCOS opFRNDINT opFSCALE opFSIN opFCOS*/
|
||||
CYCLES(70), NULL, CYCLES(83), CYCLES(292), CYCLES(21), CYCLES(30), CYCLES(257), CYCLES(257)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_da[8] =
|
||||
{
|
||||
static int *opcode_timings_da[8] = {
|
||||
// clang-format off
|
||||
/* FADDil FMULil FCOMil FCOMPil FSUBil FSUBRil FDIVil FDIVRil*/
|
||||
CYCLES(8), CYCLES(11), CYCLES(4), CYCLES(4), CYCLES(8), CYCLES(8), CYCLES(73), CYCLES(73)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_da_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_da_mod3[8] = {
|
||||
// clang-format off
|
||||
NULL, NULL, NULL, NULL, NULL, CYCLES(5), NULL, NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
|
||||
static int *opcode_timings_db[8] =
|
||||
{
|
||||
static int *opcode_timings_db[8] = {
|
||||
// clang-format off
|
||||
/* FLDil FSTil FSTPil FLDe FSTPe*/
|
||||
CYCLES(9), NULL, CYCLES(28), CYCLES(28), NULL, CYCLES(5), NULL, CYCLES(6)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_db_mod3[64] =
|
||||
{
|
||||
static int *opcode_timings_db_mod3[64] = {
|
||||
// clang-format off
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -203,219 +220,242 @@ static int *opcode_timings_db_mod3[64] =
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_dc[8] =
|
||||
{
|
||||
static int *opcode_timings_dc[8] = {
|
||||
// clang-format off
|
||||
/* opFADDd_a16 opFMULd_a16 opFCOMd_a16 opFCOMPd_a16 opFSUBd_a16 opFSUBRd_a16 opFDIVd_a16 opFDIVRd_a16*/
|
||||
CYCLES(8), CYCLES(11), CYCLES(4), CYCLES(4), CYCLES(8), CYCLES(8), CYCLES(73), CYCLES(73)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_dc_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_dc_mod3[8] = {
|
||||
// clang-format off
|
||||
/* opFADDr opFMULr opFSUBRr opFSUBr opFDIVRr opFDIVr*/
|
||||
CYCLES(8), CYCLES(16), NULL, NULL, CYCLES(8), CYCLES(8), CYCLES(73), CYCLES(73)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_dd[8] =
|
||||
{
|
||||
static int *opcode_timings_dd[8] = {
|
||||
// clang-format off
|
||||
/* FLDd FSTd FSTPd FRSTOR FSAVE FSTSW*/
|
||||
CYCLES(3), NULL, CYCLES(8), CYCLES(8), CYCLES(131), NULL, CYCLES(154), CYCLES(3)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_dd_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_dd_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FFFREE FST FSTP FUCOM FUCOMP*/
|
||||
CYCLES(3), NULL, CYCLES(3), CYCLES(3), CYCLES(4), CYCLES(4), NULL, NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_de[8] =
|
||||
{
|
||||
static int *opcode_timings_de[8] = {
|
||||
// clang-format off
|
||||
/* FADDiw FMULiw FCOMiw FCOMPiw FSUBil FSUBRil FDIVil FDIVRil*/
|
||||
CYCLES(8), CYCLES(11), CYCLES(4), CYCLES(4), CYCLES(8), CYCLES(8), CYCLES(73), CYCLES(73)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_de_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_de_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FADD FMUL FCOMPP FSUB FSUBR FDIV FDIVR*/
|
||||
CYCLES(8), CYCLES(16), NULL, CYCLES(5), CYCLES(8), CYCLES(8), CYCLES(73), CYCLES(73)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_df[8] =
|
||||
{
|
||||
static int *opcode_timings_df[8] = {
|
||||
// clang-format off
|
||||
/* FILDiw FISTiw FISTPiw FILDiq FBSTP FISTPiq*/
|
||||
CYCLES(13), NULL, CYCLES(29), CYCLES(29), NULL, CYCLES(10), CYCLES(172), CYCLES(28)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_df_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_df_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FFREE FST FSTP FUCOM FUCOMP*/
|
||||
CYCLES(3), NULL, CYCLES(3), CYCLES(3), CYCLES(4), CYCLES(4), NULL, NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_8x[8] =
|
||||
{
|
||||
static int *opcode_timings_8x[8] = {
|
||||
// clang-format off
|
||||
&timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_rm
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_8x_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_8x_mod3[8] = {
|
||||
// clang-format off
|
||||
&timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_rm
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_81[8] =
|
||||
{
|
||||
static int *opcode_timings_81[8] = {
|
||||
// clang-format off
|
||||
&timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_rm
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_81_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_81_mod3[8] = {
|
||||
// clang-format off
|
||||
&timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_rm
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int timing_count;
|
||||
static uint8_t last_prefix;
|
||||
static int timing_count;
|
||||
static uint8_t last_prefix;
|
||||
static uint32_t regmask_modified;
|
||||
|
||||
static inline int COUNT(int *c, int op_32)
|
||||
static inline int
|
||||
COUNT(int *c, int op_32)
|
||||
{
|
||||
if ((uintptr_t)c <= 10000)
|
||||
return (int)(uintptr_t)c;
|
||||
if (((uintptr_t)c & ~0xffff) == (-1 & ~0xffff))
|
||||
{
|
||||
if (op_32 & 0x100)
|
||||
return ((uintptr_t)c >> 8) & 0xff;
|
||||
return (uintptr_t)c & 0xff;
|
||||
}
|
||||
return *c;
|
||||
if ((uintptr_t) c <= 10000)
|
||||
return (int) (uintptr_t) c;
|
||||
if (((uintptr_t) c & ~0xffff) == (-1 & ~0xffff)) {
|
||||
if (op_32 & 0x100)
|
||||
return ((uintptr_t) c >> 8) & 0xff;
|
||||
return (uintptr_t) c & 0xff;
|
||||
}
|
||||
return *c;
|
||||
}
|
||||
|
||||
void codegen_timing_486_block_start(void)
|
||||
void
|
||||
codegen_timing_486_block_start(void)
|
||||
{
|
||||
regmask_modified = 0;
|
||||
regmask_modified = 0;
|
||||
}
|
||||
|
||||
void codegen_timing_486_start(void)
|
||||
void
|
||||
codegen_timing_486_start(void)
|
||||
{
|
||||
timing_count = 0;
|
||||
last_prefix = 0;
|
||||
timing_count = 0;
|
||||
last_prefix = 0;
|
||||
}
|
||||
|
||||
void codegen_timing_486_prefix(uint8_t prefix, uint32_t fetchdat)
|
||||
void
|
||||
codegen_timing_486_prefix(uint8_t prefix, uint32_t fetchdat)
|
||||
{
|
||||
timing_count += COUNT(opcode_timings[prefix], 0);
|
||||
last_prefix = prefix;
|
||||
timing_count += COUNT(opcode_timings[prefix], 0);
|
||||
last_prefix = prefix;
|
||||
}
|
||||
|
||||
void codegen_timing_486_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uint32_t op_pc)
|
||||
void
|
||||
codegen_timing_486_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, UNUSED(uint32_t op_pc))
|
||||
{
|
||||
int **timings;
|
||||
uint64_t *deps;
|
||||
int mod3 = ((fetchdat & 0xc0) == 0xc0);
|
||||
int bit8 = !(opcode & 1);
|
||||
int **timings;
|
||||
const uint64_t *deps;
|
||||
int mod3 = ((fetchdat & 0xc0) == 0xc0);
|
||||
int bit8 = !(opcode & 1);
|
||||
|
||||
switch (last_prefix)
|
||||
{
|
||||
case 0x0f:
|
||||
timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f;
|
||||
deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f;
|
||||
break;
|
||||
switch (last_prefix) {
|
||||
case 0x0f:
|
||||
timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f;
|
||||
deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f;
|
||||
break;
|
||||
|
||||
case 0xd8:
|
||||
timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8;
|
||||
deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd9:
|
||||
timings = mod3 ? opcode_timings_d9_mod3 : opcode_timings_d9;
|
||||
deps = mod3 ? opcode_deps_d9_mod3 : opcode_deps_d9;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xda:
|
||||
timings = mod3 ? opcode_timings_da_mod3 : opcode_timings_da;
|
||||
deps = mod3 ? opcode_deps_da_mod3 : opcode_deps_da;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdb:
|
||||
timings = mod3 ? opcode_timings_db_mod3 : opcode_timings_db;
|
||||
deps = mod3 ? opcode_deps_db_mod3 : opcode_deps_db;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdc:
|
||||
timings = mod3 ? opcode_timings_dc_mod3 : opcode_timings_dc;
|
||||
deps = mod3 ? opcode_deps_dc_mod3 : opcode_deps_dc;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdd:
|
||||
timings = mod3 ? opcode_timings_dd_mod3 : opcode_timings_dd;
|
||||
deps = mod3 ? opcode_deps_dd_mod3 : opcode_deps_dd;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xde:
|
||||
timings = mod3 ? opcode_timings_de_mod3 : opcode_timings_de;
|
||||
deps = mod3 ? opcode_deps_de_mod3 : opcode_deps_de;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdf:
|
||||
timings = mod3 ? opcode_timings_df_mod3 : opcode_timings_df;
|
||||
deps = mod3 ? opcode_deps_df_mod3 : opcode_deps_df;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd8:
|
||||
timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8;
|
||||
deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd9:
|
||||
timings = mod3 ? opcode_timings_d9_mod3 : opcode_timings_d9;
|
||||
deps = mod3 ? opcode_deps_d9_mod3 : opcode_deps_d9;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xda:
|
||||
timings = mod3 ? opcode_timings_da_mod3 : opcode_timings_da;
|
||||
deps = mod3 ? opcode_deps_da_mod3 : opcode_deps_da;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdb:
|
||||
timings = mod3 ? opcode_timings_db_mod3 : opcode_timings_db;
|
||||
deps = mod3 ? opcode_deps_db_mod3 : opcode_deps_db;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdc:
|
||||
timings = mod3 ? opcode_timings_dc_mod3 : opcode_timings_dc;
|
||||
deps = mod3 ? opcode_deps_dc_mod3 : opcode_deps_dc;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdd:
|
||||
timings = mod3 ? opcode_timings_dd_mod3 : opcode_timings_dd;
|
||||
deps = mod3 ? opcode_deps_dd_mod3 : opcode_deps_dd;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xde:
|
||||
timings = mod3 ? opcode_timings_de_mod3 : opcode_timings_de;
|
||||
deps = mod3 ? opcode_deps_de_mod3 : opcode_deps_de;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdf:
|
||||
timings = mod3 ? opcode_timings_df_mod3 : opcode_timings_df;
|
||||
deps = mod3 ? opcode_deps_df_mod3 : opcode_deps_df;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (opcode) {
|
||||
case 0x80:
|
||||
case 0x82:
|
||||
case 0x83:
|
||||
timings = mod3 ? opcode_timings_8x_mod3 : opcode_timings_8x;
|
||||
deps = mod3 ? opcode_deps_8x_mod3 : opcode_deps_8x;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0x81:
|
||||
timings = mod3 ? opcode_timings_81_mod3 : opcode_timings_81;
|
||||
deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
case 0xc0:
|
||||
case 0xc1:
|
||||
case 0xd0:
|
||||
case 0xd1:
|
||||
case 0xd2:
|
||||
case 0xd3:
|
||||
timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift;
|
||||
deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
case 0xf6:
|
||||
timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6;
|
||||
deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xf7:
|
||||
timings = mod3 ? opcode_timings_f7_mod3 : opcode_timings_f7;
|
||||
deps = mod3 ? opcode_deps_f7_mod3 : opcode_deps_f7;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xff:
|
||||
timings = mod3 ? opcode_timings_ff_mod3 : opcode_timings_ff;
|
||||
deps = mod3 ? opcode_deps_ff_mod3 : opcode_deps_ff;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (opcode)
|
||||
{
|
||||
case 0x80: case 0x82: case 0x83:
|
||||
timings = mod3 ? opcode_timings_8x_mod3 : opcode_timings_8x;
|
||||
deps = mod3 ? opcode_deps_8x_mod3 : opcode_deps_8x;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0x81:
|
||||
timings = mod3 ? opcode_timings_81_mod3 : opcode_timings_81;
|
||||
deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
timings = mod3 ? opcode_timings_mod3 : opcode_timings;
|
||||
deps = mod3 ? opcode_deps_mod3 : opcode_deps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case 0xc0: case 0xc1: case 0xd0: case 0xd1: case 0xd2: case 0xd3:
|
||||
timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift;
|
||||
deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
timing_count += COUNT(timings[opcode], op_32);
|
||||
if (regmask_modified & get_addr_regmask(deps[opcode], fetchdat, op_32))
|
||||
timing_count++; /*AGI stall*/
|
||||
codegen_block_cycles += timing_count;
|
||||
|
||||
case 0xf6:
|
||||
timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6;
|
||||
deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xf7:
|
||||
timings = mod3 ? opcode_timings_f7_mod3 : opcode_timings_f7;
|
||||
deps = mod3 ? opcode_deps_f7_mod3 : opcode_deps_f7;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xff:
|
||||
timings = mod3 ? opcode_timings_ff_mod3 : opcode_timings_ff;
|
||||
deps = mod3 ? opcode_deps_ff_mod3 : opcode_deps_ff;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
timings = mod3 ? opcode_timings_mod3 : opcode_timings;
|
||||
deps = mod3 ? opcode_deps_mod3 : opcode_deps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
timing_count += COUNT(timings[opcode], op_32);
|
||||
if (regmask_modified & get_addr_regmask(deps[opcode], fetchdat, op_32))
|
||||
timing_count++; /*AGI stall*/
|
||||
codegen_block_cycles += timing_count;
|
||||
|
||||
regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8);
|
||||
regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8);
|
||||
}
|
||||
|
||||
void codegen_timing_486_block_end(void)
|
||||
void
|
||||
codegen_timing_486_block_end(void)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
codegen_timing_t codegen_timing_486 =
|
||||
{
|
||||
codegen_timing_486_start,
|
||||
codegen_timing_486_prefix,
|
||||
codegen_timing_486_opcode,
|
||||
codegen_timing_486_block_start,
|
||||
codegen_timing_486_block_end,
|
||||
NULL
|
||||
codegen_timing_t codegen_timing_486 = {
|
||||
codegen_timing_486_start,
|
||||
codegen_timing_486_prefix,
|
||||
codegen_timing_486_opcode,
|
||||
codegen_timing_486_block_start,
|
||||
codegen_timing_486_block_end,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/mem.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/mem.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
#include "x86.h"
|
||||
#include "x86_ops.h"
|
||||
#include "x87.h"
|
||||
@@ -22,7 +24,7 @@
|
||||
#include "codegen_timing_common.h"
|
||||
|
||||
/*Instruction has different execution time for 16 and 32 bit data. Does not pair */
|
||||
#define CYCLES_HAS_MULTI (1 << 31)
|
||||
#define CYCLES_HAS_MULTI (1 << 31)
|
||||
|
||||
#define CYCLES_MULTI(c16, c32) (CYCLES_HAS_MULTI | c16 | (c32 << 8))
|
||||
|
||||
@@ -31,39 +33,39 @@
|
||||
|
||||
/*Instruction follows either register timing, read-modify, or read-modify-write.
|
||||
May be pairable*/
|
||||
#define CYCLES_REG (1 << 0)
|
||||
#define CYCLES_RM (1 << 0)
|
||||
#define CYCLES_RMW (1 << 0)
|
||||
#define CYCLES_REG (1 << 0)
|
||||
#define CYCLES_RM (1 << 0)
|
||||
#define CYCLES_RMW (1 << 0)
|
||||
#define CYCLES_BRANCH (1 << 0)
|
||||
|
||||
#define CYCLES_MASK ((1 << 7) - 1)
|
||||
#define CYCLES_MASK ((1 << 7) - 1)
|
||||
|
||||
/*Instruction does not pair*/
|
||||
#define PAIR_NP (0 << 29)
|
||||
/*Instruction pairs in X pipe only*/
|
||||
#define PAIR_X (1 << 29)
|
||||
#define PAIR_X (1 << 29)
|
||||
/*Instruction pairs in X pipe only, and can not pair with a following instruction*/
|
||||
#define PAIR_X_BRANCH (2 << 29)
|
||||
#define PAIR_X_BRANCH (2 << 29)
|
||||
/*Instruction pairs in both X and Y pipes*/
|
||||
#define PAIR_XY (3 << 29)
|
||||
#define PAIR_XY (3 << 29)
|
||||
|
||||
#define PAIR_MASK (3 << 29)
|
||||
|
||||
#define INVALID 0
|
||||
#define INVALID 0
|
||||
|
||||
static int prev_full;
|
||||
static uint32_t prev_opcode;
|
||||
static int prev_full;
|
||||
static uint32_t prev_opcode;
|
||||
static uint32_t *prev_timings;
|
||||
static uint32_t prev_op_32;
|
||||
static uint32_t prev_regmask;
|
||||
static uint32_t prev_op_32;
|
||||
static uint32_t prev_regmask;
|
||||
static uint64_t *prev_deps;
|
||||
static uint32_t prev_fetchdat;
|
||||
static uint32_t prev_fetchdat;
|
||||
|
||||
static uint32_t last_regmask_modified;
|
||||
static uint32_t regmask_modified;
|
||||
|
||||
static uint32_t opcode_timings[256] =
|
||||
{
|
||||
static uint32_t opcode_timings[256] = {
|
||||
// clang-format off
|
||||
/* ADD ADD ADD ADD*/
|
||||
/*00*/ PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RM, PAIR_XY | CYCLES_RM,
|
||||
/* ADD ADD PUSH ES POP ES*/
|
||||
@@ -196,10 +198,11 @@ static uint32_t opcode_timings[256] =
|
||||
PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(7), PAIR_XY | CYCLES(7),
|
||||
/* CLD STD INCDEC*/
|
||||
PAIR_XY | CYCLES(7), PAIR_XY | CYCLES(7), PAIR_XY | CYCLES_RMW, INVALID
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_mod3[256] =
|
||||
{
|
||||
static uint32_t opcode_timings_mod3[256] = {
|
||||
// clang-format off
|
||||
/* ADD ADD ADD ADD*/
|
||||
/*00*/ PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG,
|
||||
/* ADD ADD PUSH ES POP ES*/
|
||||
@@ -333,10 +336,11 @@ static uint32_t opcode_timings_mod3[256] =
|
||||
PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(7), PAIR_XY | CYCLES(7),
|
||||
/* CLD STD INCDEC*/
|
||||
PAIR_XY | CYCLES(7), PAIR_XY | CYCLES(7), PAIR_XY | CYCLES_REG, INVALID
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_0f[256] =
|
||||
{
|
||||
static uint32_t opcode_timings_0f[256] = {
|
||||
// clang-format off
|
||||
/*00*/ PAIR_NP | CYCLES(20), PAIR_NP | CYCLES(11), PAIR_NP | CYCLES(11), PAIR_NP | CYCLES(10),
|
||||
INVALID, PAIR_NP | CYCLES(195), PAIR_NP | CYCLES(7), INVALID,
|
||||
PAIR_NP | CYCLES(1000), PAIR_NP | CYCLES(10000), INVALID, INVALID,
|
||||
@@ -416,9 +420,10 @@ static uint32_t opcode_timings_0f[256] =
|
||||
INVALID, PAIR_X | CYCLES_RM, INVALID, INVALID,
|
||||
PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID,
|
||||
PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, PAIR_X | CYCLES_RM, INVALID,
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_0f_mod3[256] =
|
||||
{
|
||||
static uint32_t opcode_timings_0f_mod3[256] = {
|
||||
// clang-format off
|
||||
/*00*/ PAIR_NP | CYCLES(20), PAIR_NP | CYCLES(11), PAIR_NP | CYCLES(11), PAIR_NP | CYCLES(10),
|
||||
INVALID, PAIR_NP | CYCLES(195), PAIR_NP | CYCLES(7), INVALID,
|
||||
PAIR_NP | CYCLES(1000), PAIR_NP | CYCLES(10000), INVALID, INVALID,
|
||||
@@ -497,106 +502,122 @@ static uint32_t opcode_timings_0f_mod3[256] =
|
||||
INVALID, PAIR_X | CYCLES_REG, INVALID, INVALID,
|
||||
PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID,
|
||||
PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, PAIR_X | CYCLES_REG, INVALID,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_shift[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_shift[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(4),
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW,
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_shift_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_shift_mod3[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(4),
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG,
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_shift_imm[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_shift_imm[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES(8), PAIR_XY | CYCLES(9),
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW,
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_shift_imm_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_shift_imm_mod3[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES(3), PAIR_XY | CYCLES(4),
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG,
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_shift_cl[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_shift_cl[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(8), PAIR_XY | CYCLES(9),
|
||||
PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2),
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_shift_cl_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_shift_cl_mod3[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(8), PAIR_XY | CYCLES(9),
|
||||
PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2), PAIR_XY | CYCLES(2),
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_f6[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_f6[8] = {
|
||||
// clang-format off
|
||||
/* TST NOT NEG*/
|
||||
PAIR_XY | CYCLES_RM, INVALID, PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1),
|
||||
/* MUL IMUL DIV IDIV*/
|
||||
PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(18), PAIR_NP | CYCLES(18)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_f6_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_f6_mod3[8] = {
|
||||
// clang-format off
|
||||
/* TST NOT NEG*/
|
||||
PAIR_XY | CYCLES_REG, INVALID, PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1),
|
||||
/* MUL IMUL DIV IDIV*/
|
||||
PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(4), PAIR_NP | CYCLES(18), PAIR_NP | CYCLES(18)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_f7[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_f7[8] = {
|
||||
// clang-format off
|
||||
/* TST NOT NEG*/
|
||||
PAIR_XY | CYCLES_REG, INVALID, PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1),
|
||||
/* MUL IMUL DIV IDIV*/
|
||||
PAIR_NP | CYCLES_MULTI(4,10), PAIR_NP | CYCLES_MULTI(4,10), PAIR_NP | CYCLES_MULTI(19,27), PAIR_NP | CYCLES_MULTI(22,30)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_f7_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_f7_mod3[8] = {
|
||||
// clang-format off
|
||||
/* TST NOT NEG*/
|
||||
PAIR_XY | CYCLES_REG, INVALID, PAIR_XY | CYCLES(1), PAIR_XY | CYCLES(1),
|
||||
/* MUL IMUL DIV IDIV*/
|
||||
PAIR_NP | CYCLES_MULTI(4,10), PAIR_NP | CYCLES_MULTI(4,10), PAIR_NP | CYCLES_MULTI(19,27), PAIR_NP | CYCLES_MULTI(22,30)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_ff[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_ff[8] = {
|
||||
// clang-format off
|
||||
/* INC DEC CALL CALL far*/
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_X_BRANCH | CYCLES(3), PAIR_NP | CYCLES(5),
|
||||
/* JMP JMP far PUSH*/
|
||||
PAIR_X_BRANCH | CYCLES(3), PAIR_NP | CYCLES(5), PAIR_XY | CYCLES(1), INVALID
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_ff_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_ff_mod3[8] = {
|
||||
// clang-format off
|
||||
/* INC DEC CALL CALL far*/
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_X_BRANCH | CYCLES(1), PAIR_XY | CYCLES(5),
|
||||
/* JMP JMP far PUSH*/
|
||||
PAIR_X_BRANCH | CYCLES(1), PAIR_XY | CYCLES(5), PAIR_XY | CYCLES(2), INVALID
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_d8[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_d8[8] = {
|
||||
// clang-format off
|
||||
/* FADDs FMULs FCOMs FCOMPs*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(6), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4),
|
||||
/* FSUBs FSUBRs FDIVs FDIVRs*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), PAIR_X | CYCLES(34), PAIR_X | CYCLES(34)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_d8_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_d8_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FADD FMUL FCOM FCOMP*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(6), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4),
|
||||
/* FSUB FSUBR FDIV FDIVR*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), PAIR_X | CYCLES(34), PAIR_X | CYCLES(34)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_d9[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_d9[8] = {
|
||||
// clang-format off
|
||||
/* FLDs FSTs FSTPs*/
|
||||
PAIR_X | CYCLES(2), INVALID, PAIR_X | CYCLES(2), PAIR_X | CYCLES(2),
|
||||
/* FLDENV FLDCW FSTENV FSTCW*/
|
||||
PAIR_X | CYCLES(30), PAIR_X | CYCLES(4), PAIR_X | CYCLES(24), PAIR_X | CYCLES(5)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_d9_mod3[64] =
|
||||
{
|
||||
static uint32_t opcode_timings_d9_mod3[64] = {
|
||||
// clang-format off
|
||||
/*FLD*/
|
||||
PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2),
|
||||
PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2), PAIR_X | CYCLES(2),
|
||||
@@ -625,31 +646,34 @@ static uint32_t opcode_timings_d9_mod3[64] =
|
||||
PAIR_X | CYCLES(91), INVALID, PAIR_X | CYCLES(60), PAIR_X | CYCLES(161),
|
||||
/* opFRNDINT opFSCALE opFSIN opFCOS*/
|
||||
PAIR_X | CYCLES(20), PAIR_X | CYCLES(14), PAIR_X | CYCLES(140), PAIR_X | CYCLES(141)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_da[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_da[8] = {
|
||||
// clang-format off
|
||||
/* FIADDl FIMULl FICOMl FICOMPl*/
|
||||
PAIR_X | CYCLES(12), PAIR_X | CYCLES(11), PAIR_X | CYCLES(10), PAIR_X | CYCLES(10),
|
||||
/* FISUBl FISUBRl FIDIVl FIDIVRl*/
|
||||
PAIR_X | CYCLES(29), PAIR_X | CYCLES(27), PAIR_X | CYCLES(38), PAIR_X | CYCLES(48)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_da_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_da_mod3[8] = {
|
||||
// clang-format off
|
||||
PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4),
|
||||
INVALID, PAIR_X | CYCLES(5), INVALID, INVALID
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
|
||||
static uint32_t opcode_timings_db[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_db[8] = {
|
||||
// clang-format off
|
||||
/* FLDil FSTil FSTPil*/
|
||||
PAIR_X | CYCLES(2), INVALID, PAIR_X | CYCLES(2), PAIR_X | CYCLES(2),
|
||||
/* FLDe FSTPe*/
|
||||
INVALID, PAIR_X | CYCLES(2), INVALID, PAIR_X | CYCLES(2)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_db_mod3[64] =
|
||||
{
|
||||
static uint32_t opcode_timings_db_mod3[64] = {
|
||||
// clang-format off
|
||||
PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4),
|
||||
PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), PAIR_X | CYCLES(4),
|
||||
|
||||
@@ -675,383 +699,387 @@ static uint32_t opcode_timings_db_mod3[64] =
|
||||
|
||||
INVALID, INVALID, INVALID, INVALID,
|
||||
INVALID, INVALID, INVALID, INVALID,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_dc[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_dc[8] = {
|
||||
// clang-format off
|
||||
/* FADDd FMULd FCOMd FCOMPd*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), PAIR_X | CYCLES(7),
|
||||
/* FSUBd FSUBRd FDIVd FDIVRd*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), PAIR_X | CYCLES(34), PAIR_X | CYCLES(34)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_dc_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_dc_mod3[8] = {
|
||||
// clang-format off
|
||||
/* opFADDr opFMULr*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), INVALID, INVALID,
|
||||
/* opFSUBRr opFSUBr opFDIVRr opFDIVr*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), PAIR_X | CYCLES(34), PAIR_X | CYCLES(34)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_dd[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_dd[8] = {
|
||||
// clang-format off
|
||||
/* FLDd FSTd FSTPd*/
|
||||
PAIR_X | CYCLES(2), INVALID, PAIR_X | CYCLES(2), PAIR_X | CYCLES(2),
|
||||
/* FRSTOR FSAVE FSTSW*/
|
||||
PAIR_X | CYCLES(72), INVALID, PAIR_X | CYCLES(67), PAIR_X | CYCLES(2)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_dd_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_dd_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FFFREE FST FSTP*/
|
||||
PAIR_X | CYCLES(3), INVALID, PAIR_X | CYCLES(2), PAIR_X | CYCLES(2),
|
||||
/* FUCOM FUCOMP*/
|
||||
PAIR_X | CYCLES(4), PAIR_X | CYCLES(4), INVALID, INVALID
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_de[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_de[8] = {
|
||||
// clang-format off
|
||||
/* FIADDw FIMULw FICOMw FICOMPw*/
|
||||
PAIR_X | CYCLES(12), PAIR_X | CYCLES(11), PAIR_X | CYCLES(10), PAIR_X | CYCLES(10),
|
||||
/* FISUBw FISUBRw FIDIVw FIDIVRw*/
|
||||
PAIR_X | CYCLES(27), PAIR_X | CYCLES(27), PAIR_X | CYCLES(38), PAIR_X | CYCLES(38)
|
||||
};
|
||||
static uint32_t opcode_timings_de_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_de_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FADD FMUL FCOMPP*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), INVALID, PAIR_X | CYCLES(7),
|
||||
/* FSUB FSUBR FDIV FDIVR*/
|
||||
PAIR_X | CYCLES(7), PAIR_X | CYCLES(7), PAIR_X | CYCLES(34), PAIR_X | CYCLES(34)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_df[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_df[8] = {
|
||||
// clang-format off
|
||||
/* FILDiw FISTiw FISTPiw*/
|
||||
PAIR_X | CYCLES(8), INVALID, PAIR_X | CYCLES(10), PAIR_X | CYCLES(13),
|
||||
/* FILDiq FBSTP FISTPiq*/
|
||||
INVALID, PAIR_X | CYCLES(8), PAIR_X | CYCLES(63), PAIR_X | CYCLES(13)
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_df_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_df_mod3[8] = {
|
||||
// clang-format off
|
||||
INVALID, INVALID, INVALID, INVALID,
|
||||
/* FSTSW AX*/
|
||||
PAIR_X | CYCLES(6), INVALID, INVALID, INVALID
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static uint32_t opcode_timings_8x[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_8x[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW,
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RM
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_8x_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_8x_mod3[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG,
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_81[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_81[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW,
|
||||
PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RMW, PAIR_XY | CYCLES_RM
|
||||
// clang-format on
|
||||
};
|
||||
static uint32_t opcode_timings_81_mod3[8] =
|
||||
{
|
||||
static uint32_t opcode_timings_81_mod3[8] = {
|
||||
// clang-format off
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG,
|
||||
PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG, PAIR_XY | CYCLES_REG
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int decode_delay;
|
||||
static int decode_delay;
|
||||
static uint8_t last_prefix;
|
||||
|
||||
static inline int COUNT(uint32_t c, int op_32)
|
||||
static inline int
|
||||
COUNT(uint32_t c, int op_32)
|
||||
{
|
||||
if (c & CYCLES_HAS_MULTI)
|
||||
{
|
||||
if (op_32 & 0x100)
|
||||
return ((uintptr_t)c >> 8) & 0xff;
|
||||
return (uintptr_t)c & 0xff;
|
||||
}
|
||||
if (!(c & PAIR_MASK))
|
||||
return c & 0xffff;
|
||||
if (c & CYCLES_HAS_MULTI) {
|
||||
if (op_32 & 0x100)
|
||||
return ((uintptr_t) c >> 8) & 0xff;
|
||||
return (uintptr_t) c & 0xff;
|
||||
}
|
||||
if (!(c & PAIR_MASK))
|
||||
return c & 0xffff;
|
||||
|
||||
return c & CYCLES_MASK;
|
||||
return c & CYCLES_MASK;
|
||||
}
|
||||
|
||||
void codegen_timing_686_block_start(void)
|
||||
void
|
||||
codegen_timing_686_block_start(void)
|
||||
{
|
||||
prev_full = decode_delay = 0;
|
||||
regmask_modified = last_regmask_modified = 0;
|
||||
prev_full = decode_delay = 0;
|
||||
regmask_modified = last_regmask_modified = 0;
|
||||
}
|
||||
|
||||
void codegen_timing_686_start(void)
|
||||
void
|
||||
codegen_timing_686_start(void)
|
||||
{
|
||||
decode_delay = 0;
|
||||
last_prefix = 0;
|
||||
decode_delay = 0;
|
||||
last_prefix = 0;
|
||||
}
|
||||
|
||||
void codegen_timing_686_prefix(uint8_t prefix, uint32_t fetchdat)
|
||||
void
|
||||
codegen_timing_686_prefix(uint8_t prefix, uint32_t fetchdat)
|
||||
{
|
||||
if ((prefix & 0xf8) == 0xd8)
|
||||
{
|
||||
last_prefix = prefix;
|
||||
return;
|
||||
}
|
||||
if (prefix == 0x0f && (fetchdat & 0xf0) == 0x80)
|
||||
{
|
||||
/*0fh prefix is 'free' when used on conditional jumps*/
|
||||
last_prefix = prefix;
|
||||
return;
|
||||
}
|
||||
|
||||
/*6x86 can decode 1 prefix per instruction per clock with no penalty. If
|
||||
either instruction has more than one prefix then decode is delayed by
|
||||
one cycle for each additional prefix*/
|
||||
decode_delay++;
|
||||
if ((prefix & 0xf8) == 0xd8) {
|
||||
last_prefix = prefix;
|
||||
return;
|
||||
}
|
||||
if (prefix == 0x0f && (fetchdat & 0xf0) == 0x80) {
|
||||
/*0fh prefix is 'free' when used on conditional jumps*/
|
||||
last_prefix = prefix;
|
||||
return;
|
||||
}
|
||||
|
||||
/*6x86 can decode 1 prefix per instruction per clock with no penalty. If
|
||||
either instruction has more than one prefix then decode is delayed by
|
||||
one cycle for each additional prefix*/
|
||||
decode_delay++;
|
||||
last_prefix = prefix;
|
||||
}
|
||||
|
||||
static int check_agi(uint64_t *deps, uint8_t opcode, uint32_t fetchdat, int op_32)
|
||||
static int
|
||||
check_agi(uint64_t *deps, uint8_t opcode, uint32_t fetchdat, int op_32)
|
||||
{
|
||||
uint32_t addr_regmask = get_addr_regmask(deps[opcode], fetchdat, op_32);
|
||||
uint32_t addr_regmask = get_addr_regmask(deps[opcode], fetchdat, op_32);
|
||||
|
||||
if (addr_regmask & IMPL_ESP)
|
||||
addr_regmask |= (1 << REG_ESP);
|
||||
if (addr_regmask & IMPL_ESP)
|
||||
addr_regmask |= (1 << REG_ESP);
|
||||
|
||||
if (regmask_modified & addr_regmask)
|
||||
{
|
||||
regmask_modified = 0;
|
||||
return 2;
|
||||
}
|
||||
if (regmask_modified & addr_regmask) {
|
||||
regmask_modified = 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (last_regmask_modified & addr_regmask)
|
||||
return 1;
|
||||
if (last_regmask_modified & addr_regmask)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uint32_t op_pc)
|
||||
void
|
||||
codegen_timing_686_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, UNUSED(uint32_t op_pc))
|
||||
{
|
||||
uint32_t *timings;
|
||||
uint64_t *deps;
|
||||
int mod3 = ((fetchdat & 0xc0) == 0xc0);
|
||||
int bit8 = !(opcode & 1);
|
||||
uint32_t *timings;
|
||||
uint64_t *deps;
|
||||
int mod3 = ((fetchdat & 0xc0) == 0xc0);
|
||||
int bit8 = !(opcode & 1);
|
||||
|
||||
switch (last_prefix)
|
||||
{
|
||||
case 0x0f:
|
||||
timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f;
|
||||
deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f;
|
||||
break;
|
||||
switch (last_prefix) {
|
||||
case 0x0f:
|
||||
timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f;
|
||||
deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f;
|
||||
break;
|
||||
|
||||
case 0xd8:
|
||||
timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8;
|
||||
deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd9:
|
||||
timings = mod3 ? opcode_timings_d9_mod3 : opcode_timings_d9;
|
||||
deps = mod3 ? opcode_deps_d9_mod3 : opcode_deps_d9;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xda:
|
||||
timings = mod3 ? opcode_timings_da_mod3 : opcode_timings_da;
|
||||
deps = mod3 ? opcode_deps_da_mod3 : opcode_deps_da;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdb:
|
||||
timings = mod3 ? opcode_timings_db_mod3 : opcode_timings_db;
|
||||
deps = mod3 ? opcode_deps_db_mod3 : opcode_deps_db;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdc:
|
||||
timings = mod3 ? opcode_timings_dc_mod3 : opcode_timings_dc;
|
||||
deps = mod3 ? opcode_deps_dc_mod3 : opcode_deps_dc;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdd:
|
||||
timings = mod3 ? opcode_timings_dd_mod3 : opcode_timings_dd;
|
||||
deps = mod3 ? opcode_deps_dd_mod3 : opcode_deps_dd;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xde:
|
||||
timings = mod3 ? opcode_timings_de_mod3 : opcode_timings_de;
|
||||
deps = mod3 ? opcode_deps_de_mod3 : opcode_deps_de;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdf:
|
||||
timings = mod3 ? opcode_timings_df_mod3 : opcode_timings_df;
|
||||
deps = mod3 ? opcode_deps_df_mod3 : opcode_deps_df;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd8:
|
||||
timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8;
|
||||
deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd9:
|
||||
timings = mod3 ? opcode_timings_d9_mod3 : opcode_timings_d9;
|
||||
deps = mod3 ? opcode_deps_d9_mod3 : opcode_deps_d9;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xda:
|
||||
timings = mod3 ? opcode_timings_da_mod3 : opcode_timings_da;
|
||||
deps = mod3 ? opcode_deps_da_mod3 : opcode_deps_da;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdb:
|
||||
timings = mod3 ? opcode_timings_db_mod3 : opcode_timings_db;
|
||||
deps = mod3 ? opcode_deps_db_mod3 : opcode_deps_db;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdc:
|
||||
timings = mod3 ? opcode_timings_dc_mod3 : opcode_timings_dc;
|
||||
deps = mod3 ? opcode_deps_dc_mod3 : opcode_deps_dc;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdd:
|
||||
timings = mod3 ? opcode_timings_dd_mod3 : opcode_timings_dd;
|
||||
deps = mod3 ? opcode_deps_dd_mod3 : opcode_deps_dd;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xde:
|
||||
timings = mod3 ? opcode_timings_de_mod3 : opcode_timings_de;
|
||||
deps = mod3 ? opcode_deps_de_mod3 : opcode_deps_de;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdf:
|
||||
timings = mod3 ? opcode_timings_df_mod3 : opcode_timings_df;
|
||||
deps = mod3 ? opcode_deps_df_mod3 : opcode_deps_df;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (opcode) {
|
||||
case 0x80:
|
||||
case 0x82:
|
||||
case 0x83:
|
||||
timings = mod3 ? opcode_timings_8x_mod3 : opcode_timings_8x;
|
||||
deps = mod3 ? opcode_deps_8x_mod3 : opcode_deps_8x;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0x81:
|
||||
timings = mod3 ? opcode_timings_81_mod3 : opcode_timings_81;
|
||||
deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
case 0xc0:
|
||||
case 0xc1:
|
||||
timings = mod3 ? opcode_timings_shift_imm_mod3 : opcode_timings_shift_imm;
|
||||
deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
case 0xd0:
|
||||
case 0xd1:
|
||||
timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift;
|
||||
deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
case 0xd2:
|
||||
case 0xd3:
|
||||
timings = mod3 ? opcode_timings_shift_cl_mod3 : opcode_timings_shift_cl;
|
||||
deps = mod3 ? opcode_deps_shift_cl_mod3 : opcode_deps_shift_cl;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
case 0xf6:
|
||||
timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6;
|
||||
deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xf7:
|
||||
timings = mod3 ? opcode_timings_f7_mod3 : opcode_timings_f7;
|
||||
deps = mod3 ? opcode_deps_f7_mod3 : opcode_deps_f7;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xff:
|
||||
timings = mod3 ? opcode_timings_ff_mod3 : opcode_timings_ff;
|
||||
deps = mod3 ? opcode_deps_ff_mod3 : opcode_deps_ff;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (opcode)
|
||||
{
|
||||
case 0x80: case 0x82: case 0x83:
|
||||
timings = mod3 ? opcode_timings_8x_mod3 : opcode_timings_8x;
|
||||
deps = mod3 ? opcode_deps_8x_mod3 : opcode_deps_8x;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0x81:
|
||||
timings = mod3 ? opcode_timings_81_mod3 : opcode_timings_81;
|
||||
deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
timings = mod3 ? opcode_timings_mod3 : opcode_timings;
|
||||
deps = mod3 ? opcode_deps_mod3 : opcode_deps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case 0xc0: case 0xc1:
|
||||
timings = mod3 ? opcode_timings_shift_imm_mod3 : opcode_timings_shift_imm;
|
||||
deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
/*One prefix per instruction is free*/
|
||||
decode_delay--;
|
||||
if (decode_delay < 0)
|
||||
decode_delay = 0;
|
||||
|
||||
case 0xd0: case 0xd1:
|
||||
timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift;
|
||||
deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
if (prev_full) {
|
||||
uint32_t regmask = get_srcdep_mask(deps[opcode], fetchdat, bit8, op_32);
|
||||
int agi_stall = 0;
|
||||
|
||||
case 0xd2: case 0xd3:
|
||||
timings = mod3 ? opcode_timings_shift_cl_mod3 : opcode_timings_shift_cl;
|
||||
deps = mod3 ? opcode_deps_shift_cl_mod3 : opcode_deps_shift_cl;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
if (regmask & IMPL_ESP)
|
||||
regmask |= SRCDEP_ESP | DSTDEP_ESP;
|
||||
|
||||
case 0xf6:
|
||||
timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6;
|
||||
deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xf7:
|
||||
timings = mod3 ? opcode_timings_f7_mod3 : opcode_timings_f7;
|
||||
deps = mod3 ? opcode_deps_f7_mod3 : opcode_deps_f7;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xff:
|
||||
timings = mod3 ? opcode_timings_ff_mod3 : opcode_timings_ff;
|
||||
deps = mod3 ? opcode_deps_ff_mod3 : opcode_deps_ff;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
agi_stall = check_agi(prev_deps, prev_opcode, prev_fetchdat, prev_op_32);
|
||||
|
||||
default:
|
||||
timings = mod3 ? opcode_timings_mod3 : opcode_timings;
|
||||
deps = mod3 ? opcode_deps_mod3 : opcode_deps;
|
||||
break;
|
||||
}
|
||||
/*Second instruction in the pair*/
|
||||
if ((timings[opcode] & PAIR_MASK) == PAIR_NP) {
|
||||
/*Instruction can not pair with previous*/
|
||||
/*Run previous now*/
|
||||
codegen_block_cycles += COUNT(prev_timings[prev_opcode], prev_op_32) + decode_delay + agi_stall;
|
||||
decode_delay = (-COUNT(prev_timings[prev_opcode], prev_op_32)) + 1 + agi_stall;
|
||||
prev_full = 0;
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = prev_regmask;
|
||||
} else if (((timings[opcode] & PAIR_MASK) == PAIR_X || (timings[opcode] & PAIR_MASK) == PAIR_X_BRANCH)
|
||||
&& (prev_timings[opcode] & PAIR_MASK) == PAIR_X) {
|
||||
/*Instruction can not pair with previous*/
|
||||
/*Run previous now*/
|
||||
codegen_block_cycles += COUNT(prev_timings[prev_opcode], prev_op_32) + decode_delay + agi_stall;
|
||||
decode_delay = (-COUNT(prev_timings[prev_opcode], prev_op_32)) + 1 + agi_stall;
|
||||
prev_full = 0;
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = prev_regmask;
|
||||
} else if (prev_regmask & regmask) {
|
||||
/*Instruction can not pair with previous*/
|
||||
/*Run previous now*/
|
||||
codegen_block_cycles += COUNT(prev_timings[prev_opcode], prev_op_32) + decode_delay + agi_stall;
|
||||
decode_delay = (-COUNT(prev_timings[prev_opcode], prev_op_32)) + 1 + agi_stall;
|
||||
prev_full = 0;
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = prev_regmask;
|
||||
} else {
|
||||
int t1 = COUNT(prev_timings[prev_opcode], prev_op_32);
|
||||
int t2 = COUNT(timings[opcode], op_32);
|
||||
int t_pair = (t1 > t2) ? t1 : t2;
|
||||
|
||||
if (!t_pair)
|
||||
fatal("Pairable 0 cycles! %02x %02x\n", opcode, prev_opcode);
|
||||
|
||||
agi_stall = check_agi(deps, opcode, fetchdat, op_32);
|
||||
|
||||
codegen_block_cycles += t_pair + agi_stall;
|
||||
decode_delay = (-t_pair) + 1 + agi_stall;
|
||||
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8) | prev_regmask;
|
||||
prev_full = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*One prefix per instruction is free*/
|
||||
decode_delay--;
|
||||
if (decode_delay < 0)
|
||||
decode_delay = 0;
|
||||
if (!prev_full) {
|
||||
/*First instruction in the pair*/
|
||||
if ((timings[opcode] & PAIR_MASK) == PAIR_NP || (timings[opcode] & PAIR_MASK) == PAIR_X_BRANCH) {
|
||||
/*Instruction not pairable*/
|
||||
int agi_stall = 0;
|
||||
|
||||
if (prev_full)
|
||||
{
|
||||
uint32_t regmask = get_srcdep_mask(deps[opcode], fetchdat, bit8, op_32);
|
||||
int agi_stall = 0;
|
||||
agi_stall = check_agi(deps, opcode, fetchdat, op_32);
|
||||
|
||||
if (regmask & IMPL_ESP)
|
||||
regmask |= SRCDEP_ESP | DSTDEP_ESP;
|
||||
|
||||
agi_stall = check_agi(prev_deps, prev_opcode, prev_fetchdat, prev_op_32);
|
||||
|
||||
/*Second instruction in the pair*/
|
||||
if ((timings[opcode] & PAIR_MASK) == PAIR_NP)
|
||||
{
|
||||
/*Instruction can not pair with previous*/
|
||||
/*Run previous now*/
|
||||
codegen_block_cycles += COUNT(prev_timings[prev_opcode], prev_op_32) + decode_delay + agi_stall;
|
||||
decode_delay = (-COUNT(prev_timings[prev_opcode], prev_op_32)) + 1 + agi_stall;
|
||||
prev_full = 0;
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = prev_regmask;
|
||||
}
|
||||
else if (((timings[opcode] & PAIR_MASK) == PAIR_X || (timings[opcode] & PAIR_MASK) == PAIR_X_BRANCH)
|
||||
&& (prev_timings[opcode] & PAIR_MASK) == PAIR_X)
|
||||
{
|
||||
/*Instruction can not pair with previous*/
|
||||
/*Run previous now*/
|
||||
codegen_block_cycles += COUNT(prev_timings[prev_opcode], prev_op_32) + decode_delay + agi_stall;
|
||||
decode_delay = (-COUNT(prev_timings[prev_opcode], prev_op_32)) + 1 + agi_stall;
|
||||
prev_full = 0;
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = prev_regmask;
|
||||
}
|
||||
else if (prev_regmask & regmask)
|
||||
{
|
||||
/*Instruction can not pair with previous*/
|
||||
/*Run previous now*/
|
||||
codegen_block_cycles += COUNT(prev_timings[prev_opcode], prev_op_32) + decode_delay + agi_stall;
|
||||
decode_delay = (-COUNT(prev_timings[prev_opcode], prev_op_32)) + 1 + agi_stall;
|
||||
prev_full = 0;
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = prev_regmask;
|
||||
}
|
||||
else
|
||||
{
|
||||
int t1 = COUNT(prev_timings[prev_opcode], prev_op_32);
|
||||
int t2 = COUNT(timings[opcode], op_32);
|
||||
int t_pair = (t1 > t2) ? t1 : t2;
|
||||
|
||||
if (!t_pair)
|
||||
fatal("Pairable 0 cycles! %02x %02x\n", opcode, prev_opcode);
|
||||
|
||||
agi_stall = check_agi(deps, opcode, fetchdat, op_32);
|
||||
|
||||
codegen_block_cycles += t_pair + agi_stall;
|
||||
decode_delay = (-t_pair) + 1 + agi_stall;
|
||||
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8) | prev_regmask;
|
||||
prev_full = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!prev_full)
|
||||
{
|
||||
/*First instruction in the pair*/
|
||||
if ((timings[opcode] & PAIR_MASK) == PAIR_NP || (timings[opcode] & PAIR_MASK) == PAIR_X_BRANCH)
|
||||
{
|
||||
/*Instruction not pairable*/
|
||||
int agi_stall = 0;
|
||||
|
||||
agi_stall = check_agi(deps, opcode, fetchdat, op_32);
|
||||
|
||||
codegen_block_cycles += COUNT(timings[opcode], op_32) + decode_delay + agi_stall;
|
||||
decode_delay = (-COUNT(timings[opcode], op_32)) + 1 + agi_stall;
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Instruction might pair with next*/
|
||||
prev_full = 1;
|
||||
prev_opcode = opcode;
|
||||
prev_timings = timings;
|
||||
prev_op_32 = op_32;
|
||||
prev_regmask = get_dstdep_mask(deps[opcode], fetchdat, bit8);
|
||||
if (prev_regmask & IMPL_ESP)
|
||||
prev_regmask |= SRCDEP_ESP | DSTDEP_ESP;
|
||||
prev_deps = deps;
|
||||
prev_fetchdat = fetchdat;
|
||||
return;
|
||||
}
|
||||
codegen_block_cycles += COUNT(timings[opcode], op_32) + decode_delay + agi_stall;
|
||||
decode_delay = (-COUNT(timings[opcode], op_32)) + 1 + agi_stall;
|
||||
last_regmask_modified = regmask_modified;
|
||||
regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8);
|
||||
} else {
|
||||
/*Instruction might pair with next*/
|
||||
prev_full = 1;
|
||||
prev_opcode = opcode;
|
||||
prev_timings = timings;
|
||||
prev_op_32 = op_32;
|
||||
prev_regmask = get_dstdep_mask(deps[opcode], fetchdat, bit8);
|
||||
if (prev_regmask & IMPL_ESP)
|
||||
prev_regmask |= SRCDEP_ESP | DSTDEP_ESP;
|
||||
prev_deps = deps;
|
||||
prev_fetchdat = fetchdat;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void codegen_timing_686_block_end(void)
|
||||
void
|
||||
codegen_timing_686_block_end(void)
|
||||
{
|
||||
if (prev_full)
|
||||
{
|
||||
/*Run previous now*/
|
||||
codegen_block_cycles += COUNT(prev_timings[prev_opcode], prev_op_32) + decode_delay;
|
||||
prev_full = 0;
|
||||
}
|
||||
if (prev_full) {
|
||||
/*Run previous now*/
|
||||
codegen_block_cycles += COUNT(prev_timings[prev_opcode], prev_op_32) + decode_delay;
|
||||
prev_full = 0;
|
||||
}
|
||||
}
|
||||
|
||||
codegen_timing_t codegen_timing_686 =
|
||||
{
|
||||
codegen_timing_686_start,
|
||||
codegen_timing_686_prefix,
|
||||
codegen_timing_686_opcode,
|
||||
codegen_timing_686_block_start,
|
||||
codegen_timing_686_block_end,
|
||||
NULL
|
||||
codegen_timing_t codegen_timing_686 = {
|
||||
codegen_timing_686_start,
|
||||
codegen_timing_686_prefix,
|
||||
codegen_timing_686_opcode,
|
||||
codegen_timing_686_block_start,
|
||||
codegen_timing_686_block_end,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
#include "codegen_timing_common.h"
|
||||
|
||||
uint64_t opcode_deps[256] =
|
||||
{
|
||||
uint64_t opcode_deps[256] = {
|
||||
// clang-format off
|
||||
/* ADD ADD ADD ADD*/
|
||||
/*00*/ SRCDEP_REG | MODRM, SRCDEP_REG | MODRM, SRCDEP_REG | DSTDEP_REG | MODRM, SRCDEP_REG | DSTDEP_REG | MODRM,
|
||||
/* ADD ADD PUSH ES POP ES*/
|
||||
@@ -140,10 +140,11 @@ uint64_t opcode_deps[256] =
|
||||
0, 0, 0, 0,
|
||||
/* CLD STD INCDEC*/
|
||||
0, 0, MODRM, 0
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_mod3[256] =
|
||||
{
|
||||
uint64_t opcode_deps_mod3[256] = {
|
||||
// clang-format off
|
||||
/* ADD ADD ADD ADD*/
|
||||
/*00*/ SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM, SRCDEP_REG | DSTDEP_REG | SRCDEP_RM | MODRM,
|
||||
/* ADD ADD PUSH ES POP ES*/
|
||||
@@ -274,10 +275,11 @@ uint64_t opcode_deps_mod3[256] =
|
||||
0, 0, 0, 0,
|
||||
/* CLD STD INCDEC*/
|
||||
0, 0, SRCDEP_RM | DSTDEP_RM | MODRM, 0
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_0f[256] =
|
||||
{
|
||||
uint64_t opcode_deps_0f[256] = {
|
||||
// clang-format off
|
||||
/*00*/ MODRM, MODRM, MODRM, MODRM,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
@@ -357,9 +359,10 @@ uint64_t opcode_deps_0f[256] =
|
||||
0, MODRM | MMX_MULTIPLY, 0, 0,
|
||||
MODRM, MODRM, MODRM, 0,
|
||||
MODRM, MODRM, MODRM, 0,
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_0f_mod3[256] =
|
||||
{
|
||||
uint64_t opcode_deps_0f_mod3[256] = {
|
||||
// clang-format off
|
||||
/*00*/ MODRM, MODRM, MODRM, MODRM,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
@@ -439,10 +442,11 @@ uint64_t opcode_deps_0f_mod3[256] =
|
||||
0, MODRM | MMX_MULTIPLY, 0, 0,
|
||||
MODRM, MODRM, MODRM, 0,
|
||||
MODRM, MODRM, MODRM, 0,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_0f0f[256] =
|
||||
{
|
||||
uint64_t opcode_deps_0f0f[256] = {
|
||||
// clang-format off
|
||||
/*00*/ 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
@@ -522,9 +526,10 @@ uint64_t opcode_deps_0f0f[256] =
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_0f0f_mod3[256] =
|
||||
{
|
||||
uint64_t opcode_deps_0f0f_mod3[256] = {
|
||||
// clang-format off
|
||||
/*00*/ 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
@@ -604,97 +609,111 @@ uint64_t opcode_deps_0f0f_mod3[256] =
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_shift[8] =
|
||||
{
|
||||
uint64_t opcode_deps_shift[8] = {
|
||||
// clang-format off
|
||||
MODRM, MODRM, MODRM, MODRM,
|
||||
MODRM, MODRM, MODRM, MODRM,
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_shift_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_shift_mod3[8] = {
|
||||
// clang-format off
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM,
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_shift_cl[8] =
|
||||
{
|
||||
uint64_t opcode_deps_shift_cl[8] = {
|
||||
// clang-format off
|
||||
MODRM | SRCDEP_ECX, MODRM | SRCDEP_ECX, MODRM | SRCDEP_ECX, MODRM | SRCDEP_ECX,
|
||||
MODRM | SRCDEP_ECX, MODRM | SRCDEP_ECX, MODRM | SRCDEP_ECX, MODRM | SRCDEP_ECX,
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_shift_cl_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_shift_cl_mod3[8] = {
|
||||
// clang-format off
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM | SRCDEP_ECX, SRCDEP_RM | DSTDEP_RM | MODRM | SRCDEP_ECX, SRCDEP_RM | DSTDEP_RM | MODRM | SRCDEP_ECX, SRCDEP_RM | DSTDEP_RM | MODRM | SRCDEP_ECX,
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM | SRCDEP_ECX, SRCDEP_RM | DSTDEP_RM | MODRM | SRCDEP_ECX, SRCDEP_RM | DSTDEP_RM | MODRM | SRCDEP_ECX, SRCDEP_RM | DSTDEP_RM | MODRM | SRCDEP_ECX,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_f6[8] =
|
||||
{
|
||||
uint64_t opcode_deps_f6[8] = {
|
||||
// clang-format off
|
||||
/* TST NOT NEG*/
|
||||
MODRM, 0, MODRM, MODRM,
|
||||
/* MUL IMUL DIV IDIV*/
|
||||
SRCDEP_EAX | DSTDEP_EAX | DSTDEP_EDX | MODRM, SRCDEP_EAX | DSTDEP_EAX | DSTDEP_EDX | MODRM, SRCDEP_EAX | SRCDEP_EDX | DSTDEP_EAX | DSTDEP_EDX | MODRM, SRCDEP_EAX | SRCDEP_EDX | DSTDEP_EAX | DSTDEP_EDX | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_f6_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_f6_mod3[8] = {
|
||||
// clang-format off
|
||||
/* TST NOT NEG*/
|
||||
SRCDEP_RM | MODRM, 0, SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM,
|
||||
/* MUL IMUL DIV IDIV*/
|
||||
SRCDEP_EAX | DSTDEP_EAX | DSTDEP_EDX | SRCDEP_RM | MODRM, SRCDEP_EAX | DSTDEP_EAX | DSTDEP_EDX | SRCDEP_RM | MODRM, SRCDEP_EAX | SRCDEP_EDX | DSTDEP_EAX | DSTDEP_EDX | SRCDEP_RM | MODRM, SRCDEP_EAX | SRCDEP_EDX | DSTDEP_EAX | DSTDEP_EDX | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_f7[8] =
|
||||
{
|
||||
uint64_t opcode_deps_f7[8] = {
|
||||
// clang-format off
|
||||
/* TST NOT NEG*/
|
||||
MODRM, 0, MODRM, MODRM,
|
||||
/* MUL IMUL DIV IDIV*/
|
||||
SRCDEP_EAX | DSTDEP_EAX | DSTDEP_EDX | MODRM, SRCDEP_EAX | DSTDEP_EAX | DSTDEP_EDX | MODRM, SRCDEP_EAX | SRCDEP_EDX | DSTDEP_EAX | DSTDEP_EDX | MODRM, SRCDEP_EAX | SRCDEP_EDX | DSTDEP_EAX | DSTDEP_EDX | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_f7_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_f7_mod3[8] = {
|
||||
// clang-format off
|
||||
/* TST NOT NEG*/
|
||||
SRCDEP_RM | MODRM, 0, SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM,
|
||||
/* MUL IMUL DIV IDIV*/
|
||||
SRCDEP_EAX | DSTDEP_EAX | DSTDEP_EDX | SRCDEP_RM | MODRM, SRCDEP_EAX | DSTDEP_EAX | DSTDEP_EDX | SRCDEP_RM | MODRM, SRCDEP_EAX | SRCDEP_EDX | DSTDEP_EAX | DSTDEP_EDX | SRCDEP_RM | MODRM, SRCDEP_EAX | SRCDEP_EDX | DSTDEP_EAX | DSTDEP_EDX | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_ff[8] =
|
||||
{
|
||||
uint64_t opcode_deps_ff[8] = {
|
||||
// clang-format off
|
||||
/* INC DEC CALL CALL far*/
|
||||
MODRM, MODRM, MODRM | IMPL_ESP, MODRM,
|
||||
/* JMP JMP far PUSH*/
|
||||
MODRM, MODRM, MODRM | IMPL_ESP, 0
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_ff_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_ff_mod3[8] = {
|
||||
// clang-format off
|
||||
/* INC DEC CALL CALL far*/
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | DSTDEP_RM | MODRM, SRCDEP_RM | MODRM | IMPL_ESP, MODRM,
|
||||
/* JMP JMP far PUSH*/
|
||||
SRCDEP_RM | MODRM, MODRM, SRCDEP_RM | MODRM | IMPL_ESP, 0
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_d8[8] =
|
||||
{
|
||||
uint64_t opcode_deps_d8[8] = {
|
||||
// clang-format off
|
||||
/* FADDs FMULs FCOMs FCOMPs*/
|
||||
FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_READ_ST0 | MODRM, FPU_POP | FPU_READ_ST0 | MODRM,
|
||||
/* FSUBs FSUBRs FDIVs FDIVRs*/
|
||||
FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_d8_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_d8_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FADD FMUL FCOM FCOMP*/
|
||||
FPU_RW_ST0 | FPU_READ_STREG, FPU_RW_ST0 | FPU_READ_STREG, FPU_READ_ST0 | FPU_READ_STREG, FPU_POP | FPU_READ_ST0 | FPU_READ_STREG,
|
||||
/* FSUB FSUBR FDIV FDIVR*/
|
||||
FPU_RW_ST0 | FPU_READ_STREG, FPU_RW_ST0 | FPU_READ_STREG, FPU_RW_ST0 | FPU_READ_STREG, FPU_RW_ST0 | FPU_READ_STREG
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_d9[8] =
|
||||
{
|
||||
uint64_t opcode_deps_d9[8] = {
|
||||
// clang-format off
|
||||
/* FLDs FSTs FSTPs*/
|
||||
FPU_PUSH | MODRM, 0, FPU_READ_ST0 | MODRM, FPU_POP | MODRM,
|
||||
/* FLDENV FLDCW FSTENV FSTCW*/
|
||||
MODRM, MODRM, MODRM, MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_d9_mod3[64] =
|
||||
{
|
||||
uint64_t opcode_deps_d9_mod3[64] = {
|
||||
// clang-format off
|
||||
/*FLD*/
|
||||
FPU_PUSH | FPU_READ_STREG, FPU_PUSH | FPU_READ_STREG, FPU_PUSH | FPU_READ_STREG, FPU_PUSH | FPU_READ_STREG,
|
||||
FPU_PUSH | FPU_READ_STREG, FPU_PUSH | FPU_READ_STREG, FPU_PUSH | FPU_READ_STREG, FPU_PUSH | FPU_READ_STREG,
|
||||
@@ -722,32 +741,35 @@ uint64_t opcode_deps_d9_mod3[64] =
|
||||
0, 0, 0, 0,
|
||||
/* opFRNDINT opFSCALE opFSIN opFCOS*/
|
||||
0, 0, 0, 0
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_da[8] =
|
||||
{
|
||||
uint64_t opcode_deps_da[8] = {
|
||||
// clang-format off
|
||||
/* FIADDl FIMULl FICOMl FICOMPl*/
|
||||
FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_READ_ST0 | MODRM, FPU_READ_ST0 | FPU_POP | MODRM,
|
||||
/* FISUBl FISUBRl FIDIVl FIDIVRl*/
|
||||
FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_da_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_da_mod3[8] = {
|
||||
// clang-format off
|
||||
0, 0, 0, 0,
|
||||
/* FCOMPP*/
|
||||
0, FPU_POP2, 0, 0
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
|
||||
uint64_t opcode_deps_db[8] =
|
||||
{
|
||||
uint64_t opcode_deps_db[8] = {
|
||||
// clang-format off
|
||||
/* FLDil FSTil FSTPil*/
|
||||
FPU_PUSH | MODRM, 0, FPU_READ_ST0 | MODRM, FPU_READ_ST0 | FPU_POP | MODRM,
|
||||
/* FLDe FSTPe*/
|
||||
0, FPU_PUSH | MODRM, 0, FPU_READ_ST0 | FPU_POP | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_db_mod3[64] =
|
||||
{
|
||||
uint64_t opcode_deps_db_mod3[64] = {
|
||||
// clang-format off
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -767,84 +789,97 @@ uint64_t opcode_deps_db_mod3[64] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_dc[8] =
|
||||
{
|
||||
uint64_t opcode_deps_dc[8] = {
|
||||
// clang-format off
|
||||
/* FADDd FMULd FCOMd FCOMPd*/
|
||||
FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_READ_ST0 | MODRM, FPU_READ_ST0 | FPU_POP | MODRM,
|
||||
/* FSUBd FSUBRd FDIVd FDIVRd*/
|
||||
FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_dc_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_dc_mod3[8] = {
|
||||
// clang-format off
|
||||
/* opFADDr opFMULr*/
|
||||
FPU_READ_ST0 | FPU_RW_STREG, FPU_READ_ST0 | FPU_RW_STREG, 0, 0,
|
||||
/* opFSUBRr opFSUBr opFDIVRr opFDIVr*/
|
||||
FPU_READ_ST0 | FPU_RW_STREG, FPU_READ_ST0 | FPU_RW_STREG, FPU_READ_ST0 | FPU_RW_STREG, FPU_READ_ST0 | FPU_RW_STREG
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_dd[8] =
|
||||
{
|
||||
uint64_t opcode_deps_dd[8] = {
|
||||
// clang-format off
|
||||
/* FLDd FSTd FSTPd*/
|
||||
FPU_PUSH | MODRM, 0, FPU_READ_ST0 | MODRM, FPU_READ_ST0 | FPU_POP | MODRM,
|
||||
/* FRSTOR FSAVE FSTSW*/
|
||||
MODRM, 0, MODRM, MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_dd_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_dd_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FFFREE FST FSTP*/
|
||||
0, 0, FPU_READ_ST0 | FPU_WRITE_STREG, FPU_READ_ST0 | FPU_WRITE_STREG | FPU_POP,
|
||||
/* FUCOM FUCOMP*/
|
||||
FPU_READ_ST0 | FPU_READ_STREG, FPU_READ_ST0 | FPU_READ_STREG | FPU_POP, 0, 0
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_de[8] =
|
||||
{
|
||||
uint64_t opcode_deps_de[8] = {
|
||||
// clang-format off
|
||||
/* FIADDw FIMULw FICOMw FICOMPw*/
|
||||
FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_READ_ST0 | MODRM, FPU_READ_ST0 | FPU_POP | MODRM,
|
||||
/* FISUBw FISUBRw FIDIVw FIDIVRw*/
|
||||
FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM, FPU_RW_ST0 | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_de_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_de_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FADDP FMULP FCOMPP*/
|
||||
FPU_READ_ST0 | FPU_RW_STREG | FPU_POP, FPU_READ_ST0 | FPU_RW_STREG | FPU_POP, 0, FPU_READ_ST0 | FPU_READ_ST1 | FPU_POP2,
|
||||
/* FSUBP FSUBRP FDIVP FDIVRP*/
|
||||
FPU_READ_ST0 | FPU_RW_STREG | FPU_POP, FPU_READ_ST0 | FPU_RW_STREG | FPU_POP, FPU_READ_ST0 | FPU_RW_STREG | FPU_POP, FPU_READ_ST0 | FPU_RW_STREG | FPU_POP
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_df[8] =
|
||||
{
|
||||
uint64_t opcode_deps_df[8] = {
|
||||
// clang-format off
|
||||
/* FILDiw FISTiw FISTPiw*/
|
||||
FPU_PUSH | MODRM, 0, FPU_READ_ST0 | MODRM, FPU_READ_ST0 | FPU_POP | MODRM,
|
||||
/* FILDiq FBSTP FISTPiq*/
|
||||
0, FPU_PUSH | MODRM, FPU_READ_ST0 | FPU_POP | MODRM, FPU_READ_ST0 | FPU_POP | MODRM
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_df_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_df_mod3[8] = {
|
||||
// clang-format off
|
||||
0, 0, 0, 0,
|
||||
/* FSTSW AX*/
|
||||
0, 0, 0, 0
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
uint64_t opcode_deps_81[8] =
|
||||
{
|
||||
uint64_t opcode_deps_81[8] = {
|
||||
// clang-format off
|
||||
MODRM | HAS_IMM1632, MODRM | HAS_IMM1632, MODRM | HAS_IMM1632, MODRM | HAS_IMM1632,
|
||||
MODRM | HAS_IMM1632, MODRM | HAS_IMM1632, MODRM | HAS_IMM1632, MODRM | HAS_IMM1632
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_81_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_81_mod3[8] = {
|
||||
// clang-format off
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM1632, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM1632, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM1632, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM1632,
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM1632, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM1632, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM1632, SRCDEP_RM | MODRM | HAS_IMM1632
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_8x[8] =
|
||||
{
|
||||
uint64_t opcode_deps_8x[8] = {
|
||||
// clang-format off
|
||||
MODRM | HAS_IMM8, MODRM | HAS_IMM8, MODRM | HAS_IMM8, MODRM | HAS_IMM8,
|
||||
MODRM | HAS_IMM8, MODRM | HAS_IMM8, MODRM | HAS_IMM8, MODRM | HAS_IMM8
|
||||
// clang-format on
|
||||
};
|
||||
uint64_t opcode_deps_8x_mod3[8] =
|
||||
{
|
||||
uint64_t opcode_deps_8x_mod3[8] = {
|
||||
// clang-format off
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM8, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM8, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM8, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM8,
|
||||
SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM8, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM8, SRCDEP_RM | DSTDEP_RM | MODRM | HAS_IMM8, SRCDEP_RM | MODRM | HAS_IMM8
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -1,79 +1,79 @@
|
||||
#include "codegen_ops.h"
|
||||
|
||||
/*Instruction has input dependency on register in REG field*/
|
||||
#define SRCDEP_REG (1ull << 0)
|
||||
#define SRCDEP_REG (1ULL << 0)
|
||||
/*Instruction has input dependency on register in R/M field*/
|
||||
#define SRCDEP_RM (1ull << 1)
|
||||
#define SRCDEP_RM (1ULL << 1)
|
||||
/*Instruction modifies register in REG field*/
|
||||
#define DSTDEP_REG (1ull << 2)
|
||||
#define DSTDEP_REG (1ULL<< 2)
|
||||
/*Instruction modifies register in R/M field*/
|
||||
#define DSTDEP_RM (1ull << 3)
|
||||
#define DSTDEP_RM (1ULL << 3)
|
||||
|
||||
#define SRCDEP_SHIFT 4
|
||||
#define DSTDEP_SHIFT 12
|
||||
|
||||
/*Instruction has input dependency on given register*/
|
||||
#define SRCDEP_EAX (1ull << 4)
|
||||
#define SRCDEP_ECX (1ull << 5)
|
||||
#define SRCDEP_EDX (1ull << 6)
|
||||
#define SRCDEP_EBX (1ull << 7)
|
||||
#define SRCDEP_ESP (1ull << 8)
|
||||
#define SRCDEP_EBP (1ull << 9)
|
||||
#define SRCDEP_ESI (1ull << 10)
|
||||
#define SRCDEP_EDI (1ull << 11)
|
||||
#define SRCDEP_EAX (1ULL << 4)
|
||||
#define SRCDEP_ECX (1ULL << 5)
|
||||
#define SRCDEP_EDX (1ULL << 6)
|
||||
#define SRCDEP_EBX (1ULL << 7)
|
||||
#define SRCDEP_ESP (1ULL << 8)
|
||||
#define SRCDEP_EBP (1ULL << 9)
|
||||
#define SRCDEP_ESI (1ULL << 10)
|
||||
#define SRCDEP_EDI (1ULL << 11)
|
||||
|
||||
/*Instruction modifies given register*/
|
||||
#define DSTDEP_EAX (1ull << 12)
|
||||
#define DSTDEP_ECX (1ull << 13)
|
||||
#define DSTDEP_EDX (1ull << 14)
|
||||
#define DSTDEP_EBX (1ull << 15)
|
||||
#define DSTDEP_ESP (1ull << 16)
|
||||
#define DSTDEP_EBP (1ull << 17)
|
||||
#define DSTDEP_ESI (1ull << 18)
|
||||
#define DSTDEP_EDI (1ull << 19)
|
||||
#define DSTDEP_EAX (1ULL << 12)
|
||||
#define DSTDEP_ECX (1ULL << 13)
|
||||
#define DSTDEP_EDX (1ULL << 14)
|
||||
#define DSTDEP_EBX (1ULL << 15)
|
||||
#define DSTDEP_ESP (1ULL << 16)
|
||||
#define DSTDEP_EBP (1ULL << 17)
|
||||
#define DSTDEP_ESI (1ULL << 18)
|
||||
#define DSTDEP_EDI (1ULL << 19)
|
||||
|
||||
/*Instruction has ModR/M byte*/
|
||||
#define MODRM (1ull << 20)
|
||||
#define MODRM (1ULL << 20)
|
||||
/*Instruction implicitly uses ESP*/
|
||||
#define IMPL_ESP (1ull << 21)
|
||||
#define IMPL_ESP (1ULL << 21)
|
||||
|
||||
/*Instruction is MMX shift or pack/unpack instruction*/
|
||||
#define MMX_SHIFTPACK (1ull << 22)
|
||||
#define MMX_SHIFTPACK (1ULL << 22)
|
||||
/*Instruction is MMX multiply instruction*/
|
||||
#define MMX_MULTIPLY (1ull << 23)
|
||||
#define MMX_MULTIPLY (1ULL << 23)
|
||||
|
||||
/*Instruction pops the FPU stack*/
|
||||
#define FPU_POP (1ull << 24)
|
||||
#define FPU_POP (1ULL << 24)
|
||||
/*Instruction pops the FPU stack twice*/
|
||||
#define FPU_POP2 (1ull << 25)
|
||||
#define FPU_POP2 (1ULL << 25)
|
||||
/*Instruction pushes onto the FPU stack*/
|
||||
#define FPU_PUSH (1ull << 26)
|
||||
#define FPU_PUSH (1ULL << 26)
|
||||
|
||||
/*Instruction writes to ST(0)*/
|
||||
#define FPU_WRITE_ST0 (1ull << 27)
|
||||
#define FPU_WRITE_ST0 (1ULL << 27)
|
||||
/*Instruction reads from ST(0)*/
|
||||
#define FPU_READ_ST0 (1ull << 28)
|
||||
#define FPU_READ_ST0 (1ULL << 28)
|
||||
/*Instruction reads from and writes to ST(0)*/
|
||||
#define FPU_RW_ST0 (3ull << 27)
|
||||
#define FPU_RW_ST0 (3ULL << 27)
|
||||
|
||||
/*Instruction reads from ST(1)*/
|
||||
#define FPU_READ_ST1 (1ull << 29)
|
||||
#define FPU_READ_ST1 (1ULL << 29)
|
||||
/*Instruction writes to ST(1)*/
|
||||
#define FPU_WRITE_ST1 (1ull << 30)
|
||||
#define FPU_WRITE_ST1 (1ULL << 30)
|
||||
/*Instruction reads from and writes to ST(1)*/
|
||||
#define FPU_RW_ST1 (3ull << 29)
|
||||
#define FPU_RW_ST1 (3ULL << 29)
|
||||
|
||||
/*Instruction reads from ST(reg)*/
|
||||
#define FPU_READ_STREG (1ull << 31)
|
||||
#define FPU_READ_STREG (1ULL << 31)
|
||||
/*Instruction writes to ST(reg)*/
|
||||
#define FPU_WRITE_STREG (1ull << 32)
|
||||
#define FPU_WRITE_STREG (1ULL << 32)
|
||||
/*Instruction reads from and writes to ST(reg)*/
|
||||
#define FPU_RW_STREG (3ull << 31)
|
||||
#define FPU_RW_STREG (3ULL << 31)
|
||||
|
||||
#define FPU_FXCH (1ull << 33)
|
||||
#define FPU_FXCH (1ULL << 33)
|
||||
|
||||
#define HAS_IMM8 (1ull << 34)
|
||||
#define HAS_IMM1632 (1ull << 35)
|
||||
#define HAS_IMM8 (1ULL << 34)
|
||||
#define HAS_IMM1632 (1ULL << 35)
|
||||
|
||||
#define REGMASK_IMPL_ESP (1 << 8)
|
||||
#define REGMASK_SHIFTPACK (1 << 9)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,19 +4,21 @@
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/mem.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
#include "x86.h"
|
||||
#include "x86_ops.h"
|
||||
#include "x87.h"
|
||||
#include <86box/mem.h>
|
||||
#include "codegen.h"
|
||||
#include "codegen_ops.h"
|
||||
#include "codegen_timing_common.h"
|
||||
|
||||
#define CYCLES(c) (int *)c
|
||||
#define CYCLES2(c16, c32) (int *)((-1 & ~0xffff) | c16 | (c32 << 8))
|
||||
#define CYCLES(c) (int *) c
|
||||
#define CYCLES2(c16, c32) (int *) ((-1 & ~0xffff) | c16 | (c32 << 8))
|
||||
|
||||
static int *opcode_timings[256] =
|
||||
{
|
||||
static int *opcode_timings[256] = {
|
||||
// clang-format off
|
||||
/*00*/ &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3), &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(2), NULL,
|
||||
/*10*/ &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3), &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3),
|
||||
/*20*/ &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(4), CYCLES(3), &timing_mr, &timing_mr, &timing_rm, &timing_rm, &timing_rr, &timing_rr, CYCLES(4), CYCLES(3),
|
||||
@@ -36,10 +38,11 @@ static int *opcode_timings[256] =
|
||||
/*d0*/ CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(15), CYCLES(14), CYCLES(2), CYCLES(4), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*e0*/ CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(5), CYCLES(14), CYCLES(14), CYCLES(16), CYCLES(16), CYCLES(3), CYCLES(3), CYCLES(17), CYCLES(3), CYCLES(14), CYCLES(14), CYCLES(14), CYCLES(14),
|
||||
/*f0*/ CYCLES(4), CYCLES(0), CYCLES(0), CYCLES(0), CYCLES(4), CYCLES(2), NULL, NULL, CYCLES(2), CYCLES(2), CYCLES(3), CYCLES(2), CYCLES(2), CYCLES(2), CYCLES(3), NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_mod3[256] =
|
||||
{
|
||||
static int *opcode_timings_mod3[256] = {
|
||||
// clang-format off
|
||||
/*00*/ &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3), &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(2), NULL,
|
||||
/*10*/ &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3), &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(2), CYCLES(3),
|
||||
/*20*/ &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(4), CYCLES(3), &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, &timing_rr, CYCLES(4), CYCLES(3),
|
||||
@@ -59,10 +62,11 @@ static int *opcode_timings_mod3[256] =
|
||||
/*d0*/ CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(4), CYCLES(15), CYCLES(14), CYCLES(2), CYCLES(4), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*e0*/ CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(5), CYCLES(14), CYCLES(14), CYCLES(16), CYCLES(16), CYCLES(3), CYCLES(3), CYCLES(17), CYCLES(3), CYCLES(14), CYCLES(14), CYCLES(14), CYCLES(14),
|
||||
/*f0*/ CYCLES(4), CYCLES(0), CYCLES(0), CYCLES(0), CYCLES(4), CYCLES(2), NULL, NULL, CYCLES(2), CYCLES(2), CYCLES(3), CYCLES(2), CYCLES(2), CYCLES(2), CYCLES(3), NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_0f[256] =
|
||||
{
|
||||
static int *opcode_timings_0f[256] = {
|
||||
// clang-format off
|
||||
/*00*/ CYCLES(20), CYCLES(11), CYCLES(11), CYCLES(10), NULL, CYCLES(195), CYCLES(7), NULL, CYCLES(1000), CYCLES(10000), NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*10*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*20*/ CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -82,9 +86,10 @@ static int *opcode_timings_0f[256] =
|
||||
/*d0*/ NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm, NULL, NULL, &timing_rm, &timing_rm, NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm,
|
||||
/*e0*/ NULL, &timing_rm, &timing_rm, NULL, NULL, &timing_rm, NULL, NULL, &timing_rm, &timing_rm, NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm,
|
||||
/*f0*/ NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm, NULL, NULL, &timing_rm, &timing_rm, &timing_rm, NULL, &timing_rm, &timing_rm, &timing_rm, NULL,
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_0f_mod3[256] =
|
||||
{
|
||||
static int *opcode_timings_0f_mod3[256] = {
|
||||
// clang-format off
|
||||
/*00*/ CYCLES(20), CYCLES(11), CYCLES(11), CYCLES(10), NULL, CYCLES(195), CYCLES(7), NULL, CYCLES(1000), CYCLES(10000), NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*10*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
/*20*/ CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), CYCLES(6), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -104,60 +109,72 @@ static int *opcode_timings_0f_mod3[256] =
|
||||
/*d0*/ NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr, NULL, NULL, &timing_rr, &timing_rr, NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr,
|
||||
/*e0*/ NULL, &timing_rr, &timing_rr, NULL, NULL, &timing_rr, NULL, NULL, &timing_rr, &timing_rr, NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr,
|
||||
/*f0*/ NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr, NULL, NULL, &timing_rr, &timing_rr, &timing_rr, NULL, &timing_rr, &timing_rr, &timing_rr, NULL,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_shift[8] =
|
||||
{
|
||||
static int *opcode_timings_shift[8] = {
|
||||
// clang-format off
|
||||
CYCLES(7), CYCLES(7), CYCLES(10), CYCLES(10), CYCLES(7), CYCLES(7), CYCLES(7), CYCLES(7)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_shift_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_shift_mod3[8] = {
|
||||
// clang-format off
|
||||
CYCLES(3), CYCLES(3), CYCLES(9), CYCLES(9), CYCLES(3), CYCLES(3), CYCLES(3), CYCLES(3)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_f6[8] =
|
||||
{
|
||||
static int *opcode_timings_f6[8] = {
|
||||
// clang-format off
|
||||
&timing_rm, NULL, &timing_mm, &timing_mm, CYCLES(13), CYCLES(14), CYCLES(16), CYCLES(19)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_f6_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_f6_mod3[8] = {
|
||||
// clang-format off
|
||||
&timing_rr, NULL, &timing_rr, &timing_rr, CYCLES(13), CYCLES(14), CYCLES(16), CYCLES(19)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_f7[8] =
|
||||
{
|
||||
static int *opcode_timings_f7[8] = {
|
||||
// clang-format off
|
||||
&timing_rm, NULL, &timing_mm, &timing_mm, CYCLES(21), CYCLES2(22,38), CYCLES2(24,40), CYCLES2(27,43)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_f7_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_f7_mod3[8] = {
|
||||
// clang-format off
|
||||
&timing_rr, NULL, &timing_rr, &timing_rr, CYCLES(21), CYCLES2(22,38), CYCLES2(24,40), CYCLES2(27,43)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_ff[8] =
|
||||
{
|
||||
static int *opcode_timings_ff[8] = {
|
||||
// clang-format off
|
||||
&timing_mm, &timing_mm, CYCLES(5), CYCLES(0), CYCLES(5), CYCLES(0), CYCLES(5), NULL
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_ff_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_ff_mod3[8] = {
|
||||
// clang-format off
|
||||
&timing_rr, &timing_rr, CYCLES(5), CYCLES(0), CYCLES(5), CYCLES(0), CYCLES(5), NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_d8[8] =
|
||||
{
|
||||
static int *opcode_timings_d8[8] = {
|
||||
// clang-format off
|
||||
/* FADDil FMULil FCOMil FCOMPil FSUBil FSUBRil FDIVil FDIVRil*/
|
||||
CYCLES(10), CYCLES(12), CYCLES(9), CYCLES(9), CYCLES(10), CYCLES(10), CYCLES(78), CYCLES(78)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_d8_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_d8_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FADD FMUL FCOM FCOMP FSUB FSUBR FDIV FDIVR*/
|
||||
CYCLES(4), CYCLES(6), CYCLES(3), CYCLES(3), CYCLES(4), CYCLES(4), CYCLES(72), CYCLES(72)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_d9[8] =
|
||||
{
|
||||
static int *opcode_timings_d9[8] = {
|
||||
// clang-format off
|
||||
/* FLDs FSTs FSTPs FLDENV FLDCW FSTENV FSTCW*/
|
||||
CYCLES(2), NULL, CYCLES(7), CYCLES(7), CYCLES(34), CYCLES(4), CYCLES(67), CYCLES(3)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_d9_mod3[64] =
|
||||
{
|
||||
static int *opcode_timings_d9_mod3[64] = {
|
||||
// clang-format off
|
||||
/*FLD*/
|
||||
CYCLES(1), CYCLES(1), CYCLES(1), CYCLES(1), CYCLES(1), CYCLES(1), CYCLES(1), CYCLES(1),
|
||||
/*FXCH*/
|
||||
@@ -174,26 +191,29 @@ static int *opcode_timings_d9_mod3[64] =
|
||||
CYCLES(300), CYCLES(58), CYCLES(676), CYCLES(355), NULL, NULL, CYCLES(3), CYCLES(3),
|
||||
/* opFPREM opFSQRT opFSINCOS opFRNDINT opFSCALE opFSIN opFCOS*/
|
||||
CYCLES(70), NULL, CYCLES(72), CYCLES(292), CYCLES(21), CYCLES(30), CYCLES(474), CYCLES(474)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_da[8] =
|
||||
{
|
||||
static int *opcode_timings_da[8] = {
|
||||
// clang-format off
|
||||
/* FADDil FMULil FCOMil FCOMPil FSUBil FSUBRil FDIVil FDIVRil*/
|
||||
CYCLES(10), CYCLES(12), CYCLES(9), CYCLES(9), CYCLES(10), CYCLES(10), CYCLES(78), CYCLES(78)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_da_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_da_mod3[8] = {
|
||||
// clang-format off
|
||||
NULL, NULL, NULL, NULL, NULL, CYCLES(5), NULL, NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
|
||||
static int *opcode_timings_db[8] =
|
||||
{
|
||||
static int *opcode_timings_db[8] = {
|
||||
// clang-format off
|
||||
/* FLDil FSTil FSTPil FLDe FSTPe*/
|
||||
CYCLES(6), NULL, CYCLES(7), CYCLES(7), NULL, CYCLES(8), NULL, CYCLES(8)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_db_mod3[64] =
|
||||
{
|
||||
static int *opcode_timings_db_mod3[64] = {
|
||||
// clang-format off
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -203,54 +223,63 @@ static int *opcode_timings_db_mod3[64] =
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_dc[8] =
|
||||
{
|
||||
static int *opcode_timings_dc[8] = {
|
||||
// clang-format off
|
||||
/* opFADDd_a16 opFMULd_a16 opFCOMd_a16 opFCOMPd_a16 opFSUBd_a16 opFSUBRd_a16 opFDIVd_a16 opFDIVRd_a16*/
|
||||
CYCLES(6), CYCLES(8), CYCLES(5), CYCLES(5), CYCLES(6), CYCLES(6), CYCLES(74), CYCLES(74)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_dc_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_dc_mod3[8] = {
|
||||
// clang-format off
|
||||
/* opFADDr opFMULr opFSUBRr opFSUBr opFDIVRr opFDIVr*/
|
||||
CYCLES(4), CYCLES(6), NULL, NULL, CYCLES(4), CYCLES(4), CYCLES(72), CYCLES(72)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_dd[8] =
|
||||
{
|
||||
static int *opcode_timings_dd[8] = {
|
||||
// clang-format off
|
||||
/* FLDd FSTd FSTPd FRSTOR FSAVE FSTSW*/
|
||||
CYCLES(2), NULL, CYCLES(8), CYCLES(8), CYCLES(131), NULL, CYCLES(154), CYCLES(5)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_dd_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_dd_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FFFREE FST FSTP FUCOM FUCOMP*/
|
||||
CYCLES(3), NULL, CYCLES(1), CYCLES(1), CYCLES(3), CYCLES(3), NULL, NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_de[8] =
|
||||
{
|
||||
static int *opcode_timings_de[8] = {
|
||||
// clang-format off
|
||||
/* FADDiw FMULiw FCOMiw FCOMPiw FSUBil FSUBRil FDIVil FDIVRil*/
|
||||
CYCLES(10), CYCLES(12), CYCLES(9), CYCLES(9), CYCLES(10), CYCLES(10), CYCLES(78), CYCLES(78)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_de_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_de_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FADD FMUL FCOMPP FSUB FSUBR FDIV FDIVR*/
|
||||
CYCLES(4), CYCLES(6), NULL, CYCLES(3), CYCLES(4), CYCLES(4), CYCLES(72), CYCLES(72)
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_df[8] =
|
||||
{
|
||||
static int *opcode_timings_df[8] = {
|
||||
// clang-format off
|
||||
/* FILDiw FISTiw FISTPiw FILDiq FBSTP FISTPiq*/
|
||||
CYCLES(6), NULL, CYCLES(7), CYCLES(7), NULL, CYCLES(8), CYCLES(172), CYCLES(8)
|
||||
// clang-format on
|
||||
};
|
||||
static int *opcode_timings_df_mod3[8] =
|
||||
{
|
||||
static int *opcode_timings_df_mod3[8] = {
|
||||
// clang-format off
|
||||
/* FFREE FST FSTP FUCOM FUCOMP*/
|
||||
CYCLES(3), NULL, CYCLES(1), CYCLES(1), CYCLES(3), CYCLES(3), NULL, NULL
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int *opcode_timings_8x[8] =
|
||||
{
|
||||
static int *opcode_timings_8x[8] = {
|
||||
// clang-format off
|
||||
&timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_rm
|
||||
};
|
||||
static int *opcode_timings_8x_mod3[8] =
|
||||
@@ -264,158 +293,169 @@ static int *opcode_timings_81[8] =
|
||||
static int *opcode_timings_81_mod3[8] =
|
||||
{
|
||||
&timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_mr, &timing_rm
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static int timing_count;
|
||||
static uint8_t last_prefix;
|
||||
static int timing_count;
|
||||
static uint8_t last_prefix;
|
||||
static uint32_t regmask_modified;
|
||||
|
||||
static inline int COUNT(int *c, int op_32)
|
||||
static inline int
|
||||
COUNT(int *c, int op_32)
|
||||
{
|
||||
if ((uintptr_t)c <= 10000)
|
||||
return (int)(uintptr_t)c;
|
||||
if (((uintptr_t)c & ~0xffff) == (-1 & ~0xffff))
|
||||
{
|
||||
if (op_32 & 0x100)
|
||||
return ((uintptr_t)c >> 8) & 0xff;
|
||||
return (uintptr_t)c & 0xff;
|
||||
}
|
||||
return *c;
|
||||
if ((uintptr_t) c <= 10000)
|
||||
return (int) (uintptr_t) c;
|
||||
if (((uintptr_t) c & ~0xffff) == (-1 & ~0xffff)) {
|
||||
if (op_32 & 0x100)
|
||||
return ((uintptr_t) c >> 8) & 0xff;
|
||||
return (uintptr_t) c & 0xff;
|
||||
}
|
||||
return *c;
|
||||
}
|
||||
|
||||
void codegen_timing_winchip_block_start(void)
|
||||
void
|
||||
codegen_timing_winchip_block_start(void)
|
||||
{
|
||||
regmask_modified = 0;
|
||||
regmask_modified = 0;
|
||||
}
|
||||
|
||||
void codegen_timing_winchip_start(void)
|
||||
void
|
||||
codegen_timing_winchip_start(void)
|
||||
{
|
||||
timing_count = 0;
|
||||
last_prefix = 0;
|
||||
timing_count = 0;
|
||||
last_prefix = 0;
|
||||
}
|
||||
|
||||
void codegen_timing_winchip_prefix(uint8_t prefix, uint32_t fetchdat)
|
||||
void
|
||||
codegen_timing_winchip_prefix(uint8_t prefix, uint32_t fetchdat)
|
||||
{
|
||||
timing_count += COUNT(opcode_timings[prefix], 0);
|
||||
last_prefix = prefix;
|
||||
timing_count += COUNT(opcode_timings[prefix], 0);
|
||||
last_prefix = prefix;
|
||||
}
|
||||
|
||||
void codegen_timing_winchip_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, uint32_t op_pc)
|
||||
void
|
||||
codegen_timing_winchip_opcode(uint8_t opcode, uint32_t fetchdat, int op_32, UNUSED(uint32_t op_pc))
|
||||
{
|
||||
int **timings;
|
||||
uint64_t *deps;
|
||||
int mod3 = ((fetchdat & 0xc0) == 0xc0);
|
||||
int bit8 = !(opcode & 1);
|
||||
int **timings;
|
||||
const uint64_t *deps;
|
||||
int mod3 = ((fetchdat & 0xc0) == 0xc0);
|
||||
int bit8 = !(opcode & 1);
|
||||
|
||||
switch (last_prefix)
|
||||
{
|
||||
case 0x0f:
|
||||
timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f;
|
||||
deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f;
|
||||
break;
|
||||
switch (last_prefix) {
|
||||
case 0x0f:
|
||||
timings = mod3 ? opcode_timings_0f_mod3 : opcode_timings_0f;
|
||||
deps = mod3 ? opcode_deps_0f_mod3 : opcode_deps_0f;
|
||||
break;
|
||||
|
||||
case 0xd8:
|
||||
timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8;
|
||||
deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd9:
|
||||
timings = mod3 ? opcode_timings_d9_mod3 : opcode_timings_d9;
|
||||
deps = mod3 ? opcode_deps_d9_mod3 : opcode_deps_d9;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xda:
|
||||
timings = mod3 ? opcode_timings_da_mod3 : opcode_timings_da;
|
||||
deps = mod3 ? opcode_deps_da_mod3 : opcode_deps_da;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdb:
|
||||
timings = mod3 ? opcode_timings_db_mod3 : opcode_timings_db;
|
||||
deps = mod3 ? opcode_deps_db_mod3 : opcode_deps_db;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdc:
|
||||
timings = mod3 ? opcode_timings_dc_mod3 : opcode_timings_dc;
|
||||
deps = mod3 ? opcode_deps_dc_mod3 : opcode_deps_dc;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdd:
|
||||
timings = mod3 ? opcode_timings_dd_mod3 : opcode_timings_dd;
|
||||
deps = mod3 ? opcode_deps_dd_mod3 : opcode_deps_dd;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xde:
|
||||
timings = mod3 ? opcode_timings_de_mod3 : opcode_timings_de;
|
||||
deps = mod3 ? opcode_deps_de_mod3 : opcode_deps_de;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdf:
|
||||
timings = mod3 ? opcode_timings_df_mod3 : opcode_timings_df;
|
||||
deps = mod3 ? opcode_deps_df_mod3 : opcode_deps_df;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd8:
|
||||
timings = mod3 ? opcode_timings_d8_mod3 : opcode_timings_d8;
|
||||
deps = mod3 ? opcode_deps_d8_mod3 : opcode_deps_d8;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xd9:
|
||||
timings = mod3 ? opcode_timings_d9_mod3 : opcode_timings_d9;
|
||||
deps = mod3 ? opcode_deps_d9_mod3 : opcode_deps_d9;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xda:
|
||||
timings = mod3 ? opcode_timings_da_mod3 : opcode_timings_da;
|
||||
deps = mod3 ? opcode_deps_da_mod3 : opcode_deps_da;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdb:
|
||||
timings = mod3 ? opcode_timings_db_mod3 : opcode_timings_db;
|
||||
deps = mod3 ? opcode_deps_db_mod3 : opcode_deps_db;
|
||||
opcode = mod3 ? opcode & 0x3f : (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdc:
|
||||
timings = mod3 ? opcode_timings_dc_mod3 : opcode_timings_dc;
|
||||
deps = mod3 ? opcode_deps_dc_mod3 : opcode_deps_dc;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdd:
|
||||
timings = mod3 ? opcode_timings_dd_mod3 : opcode_timings_dd;
|
||||
deps = mod3 ? opcode_deps_dd_mod3 : opcode_deps_dd;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xde:
|
||||
timings = mod3 ? opcode_timings_de_mod3 : opcode_timings_de;
|
||||
deps = mod3 ? opcode_deps_de_mod3 : opcode_deps_de;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
case 0xdf:
|
||||
timings = mod3 ? opcode_timings_df_mod3 : opcode_timings_df;
|
||||
deps = mod3 ? opcode_deps_df_mod3 : opcode_deps_df;
|
||||
opcode = (opcode >> 3) & 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (opcode) {
|
||||
case 0x80:
|
||||
case 0x82:
|
||||
case 0x83:
|
||||
timings = mod3 ? opcode_timings_8x_mod3 : opcode_timings_8x;
|
||||
deps = mod3 ? opcode_deps_8x_mod3 : opcode_deps_8x;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0x81:
|
||||
timings = mod3 ? opcode_timings_81_mod3 : opcode_timings_81;
|
||||
deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
case 0xc0:
|
||||
case 0xc1:
|
||||
case 0xd0:
|
||||
case 0xd1:
|
||||
case 0xd2:
|
||||
case 0xd3:
|
||||
timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift;
|
||||
deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
case 0xf6:
|
||||
timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6;
|
||||
deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xf7:
|
||||
timings = mod3 ? opcode_timings_f7_mod3 : opcode_timings_f7;
|
||||
deps = mod3 ? opcode_deps_f7_mod3 : opcode_deps_f7;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xff:
|
||||
timings = mod3 ? opcode_timings_ff_mod3 : opcode_timings_ff;
|
||||
deps = mod3 ? opcode_deps_ff_mod3 : opcode_deps_ff;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (opcode)
|
||||
{
|
||||
case 0x80: case 0x82: case 0x83:
|
||||
timings = mod3 ? opcode_timings_8x_mod3 : opcode_timings_8x;
|
||||
deps = mod3 ? opcode_deps_8x_mod3 : opcode_deps_8x;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0x81:
|
||||
timings = mod3 ? opcode_timings_81_mod3 : opcode_timings_81;
|
||||
deps = mod3 ? opcode_deps_81_mod3 : opcode_deps_81;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
timings = mod3 ? opcode_timings_mod3 : opcode_timings;
|
||||
deps = mod3 ? opcode_deps_mod3 : opcode_deps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case 0xc0: case 0xc1: case 0xd0: case 0xd1: case 0xd2: case 0xd3:
|
||||
timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift;
|
||||
deps = mod3 ? opcode_deps_shift_mod3 : opcode_deps_shift;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
timing_count += COUNT(timings[opcode], op_32);
|
||||
if (regmask_modified & get_addr_regmask(deps[opcode], fetchdat, op_32))
|
||||
timing_count++; /*AGI stall*/
|
||||
codegen_block_cycles += timing_count;
|
||||
|
||||
case 0xf6:
|
||||
timings = mod3 ? opcode_timings_f6_mod3 : opcode_timings_f6;
|
||||
deps = mod3 ? opcode_deps_f6_mod3 : opcode_deps_f6;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xf7:
|
||||
timings = mod3 ? opcode_timings_f7_mod3 : opcode_timings_f7;
|
||||
deps = mod3 ? opcode_deps_f7_mod3 : opcode_deps_f7;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
case 0xff:
|
||||
timings = mod3 ? opcode_timings_ff_mod3 : opcode_timings_ff;
|
||||
deps = mod3 ? opcode_deps_ff_mod3 : opcode_deps_ff;
|
||||
opcode = (fetchdat >> 3) & 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
timings = mod3 ? opcode_timings_mod3 : opcode_timings;
|
||||
deps = mod3 ? opcode_deps_mod3 : opcode_deps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
timing_count += COUNT(timings[opcode], op_32);
|
||||
if (regmask_modified & get_addr_regmask(deps[opcode], fetchdat, op_32))
|
||||
timing_count++; /*AGI stall*/
|
||||
codegen_block_cycles += timing_count;
|
||||
|
||||
regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8);
|
||||
regmask_modified = get_dstdep_mask(deps[opcode], fetchdat, bit8);
|
||||
}
|
||||
|
||||
void codegen_timing_winchip_block_end(void)
|
||||
void
|
||||
codegen_timing_winchip_block_end(void)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
codegen_timing_t codegen_timing_winchip =
|
||||
{
|
||||
codegen_timing_winchip_start,
|
||||
codegen_timing_winchip_prefix,
|
||||
codegen_timing_winchip_opcode,
|
||||
codegen_timing_winchip_block_start,
|
||||
codegen_timing_winchip_block_end,
|
||||
NULL
|
||||
codegen_timing_t codegen_timing_winchip = {
|
||||
codegen_timing_winchip_start,
|
||||
codegen_timing_winchip_prefix,
|
||||
codegen_timing_winchip_opcode,
|
||||
codegen_timing_winchip_block_start,
|
||||
codegen_timing_winchip_block_end,
|
||||
NULL
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,6 +38,9 @@
|
||||
#include <86box/pic.h>
|
||||
#include <86box/pci.h>
|
||||
#include <86box/gdbstub.h>
|
||||
#include <86box/plat_fallthrough.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
#ifdef USE_DYNAREC
|
||||
# include "codegen.h"
|
||||
#endif
|
||||
@@ -903,7 +906,7 @@ cpu_set(void)
|
||||
#endif
|
||||
x86_setopcodes_2386(ops_2386_386, ops_2386_ibm486_0f);
|
||||
cpu_features = CPU_FEATURE_MSR;
|
||||
/* FALLTHROUGH */
|
||||
fallthrough;
|
||||
case CPU_386SX:
|
||||
case CPU_386DX:
|
||||
/* In case we get Deskpro 386 emulation */
|
||||
@@ -1126,7 +1129,7 @@ cpu_set(void)
|
||||
case CPU_i486DX_SLENH:
|
||||
cpu_features = CPU_FEATURE_CR4 | CPU_FEATURE_VME;
|
||||
cpu_CR4_mask = CR4_VME | CR4_PVI | CR4_VME;
|
||||
/* FALLTHROUGH */
|
||||
fallthrough;
|
||||
case CPU_RAPIDCAD:
|
||||
case CPU_i486SX:
|
||||
case CPU_i486DX:
|
||||
@@ -1439,7 +1442,9 @@ cpu_set(void)
|
||||
x86_setopcodes(ops_386, ops_pentium_0f, dynarec_ops_386, dynarec_ops_pentium_0f);
|
||||
else
|
||||
x86_setopcodes(ops_386, ops_c6x86mx_0f, dynarec_ops_386, dynarec_ops_c6x86mx_0f);
|
||||
// x86_setopcodes(ops_386, ops_c6x86_0f, dynarec_ops_386, dynarec_ops_c6x86_0f);
|
||||
#if 0
|
||||
x86_setopcodes(ops_386, ops_c6x86_0f, dynarec_ops_386, dynarec_ops_c6x86_0f);
|
||||
#endif
|
||||
# else
|
||||
if (cpu_s->cpu_type == CPU_Cx6x86MX)
|
||||
x86_setopcodes(ops_386, ops_c6x86mx_0f);
|
||||
@@ -1447,7 +1452,9 @@ cpu_set(void)
|
||||
x86_setopcodes(ops_386, ops_pentium_0f);
|
||||
else
|
||||
x86_setopcodes(ops_386, ops_c6x86mx_0f);
|
||||
// x86_setopcodes(ops_386, ops_c6x86_0f);
|
||||
#if 0
|
||||
x86_setopcodes(ops_386, ops_c6x86_0f);
|
||||
#endif
|
||||
# endif
|
||||
|
||||
timing_rr = 1; /* register dest - register src */
|
||||
@@ -2465,7 +2472,7 @@ cpu_ven_reset(void)
|
||||
case CPU_K6_3:
|
||||
case CPU_K6_2C:
|
||||
msr.amd_psor = (cpu_s->cpu_type >= CPU_K6_3) ? 0x008cULL : 0x018cULL;
|
||||
/* FALLTHROUGH */
|
||||
fallthrough;
|
||||
case CPU_K6_2:
|
||||
#if defined(DEV_BRANCH) && defined(USE_AMD_K5)
|
||||
case CPU_K5:
|
||||
@@ -2479,7 +2486,6 @@ cpu_ven_reset(void)
|
||||
case CPU_PENTIUM2:
|
||||
case CPU_PENTIUM2D:
|
||||
msr.mtrr_cap = 0x00000508ULL;
|
||||
/* FALLTHROUGH */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3252,7 +3258,9 @@ amd_k_invalid_wrmsr:
|
||||
break;
|
||||
case 0x1b:
|
||||
cpu_log("APIC_BASE write: %08X%08X\n", EDX, EAX);
|
||||
// msr.apic_base = EAX | ((uint64_t) EDX << 32);
|
||||
#if 0
|
||||
msr.apic_base = EAX | ((uint64_t) EDX << 32);
|
||||
#endif
|
||||
break;
|
||||
case 0x2a:
|
||||
break;
|
||||
@@ -3421,7 +3429,7 @@ i686_invalid_wrmsr:
|
||||
}
|
||||
|
||||
static void
|
||||
cpu_write(uint16_t addr, uint8_t val, void *priv)
|
||||
cpu_write(uint16_t addr, uint8_t val, UNUSED(void *priv))
|
||||
{
|
||||
if (addr == 0xf0) {
|
||||
/* Writes to F0 clear FPU error and deassert the interrupt. */
|
||||
@@ -3503,7 +3511,7 @@ cpu_write(uint16_t addr, uint8_t val, void *priv)
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
cpu_read(uint16_t addr, void *priv)
|
||||
cpu_read(uint16_t addr, UNUSED(void *priv))
|
||||
{
|
||||
if (addr == 0xf007)
|
||||
return 0x7f;
|
||||
|
||||
@@ -432,15 +432,15 @@ typedef struct {
|
||||
} cpu_state_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t cwd;
|
||||
uint16_t swd;
|
||||
uint16_t tag;
|
||||
uint16_t foo;
|
||||
uint32_t fip;
|
||||
uint32_t fdp;
|
||||
uint16_t fcs;
|
||||
uint16_t fds;
|
||||
floatx80 st_space[8];
|
||||
uint16_t cwd;
|
||||
uint16_t swd;
|
||||
uint16_t tag;
|
||||
uint16_t foo;
|
||||
uint32_t fip;
|
||||
uint32_t fdp;
|
||||
uint16_t fcs;
|
||||
uint16_t fds;
|
||||
floatx80 st_space[8];
|
||||
unsigned char tos;
|
||||
unsigned char align1;
|
||||
unsigned char align2;
|
||||
|
||||
@@ -59,10 +59,12 @@ uint32_t rmdat;
|
||||
uint64_t xt_cpu_multi;
|
||||
|
||||
/* Variables for handling the non-maskable interrupts. */
|
||||
int nmi = 0, nmi_auto_clear = 0;
|
||||
int nmi = 0;
|
||||
int nmi_auto_clear = 0;
|
||||
|
||||
/* Was the CPU ever reset? */
|
||||
int x86_was_reset = 0, soft_reset_pci = 0;
|
||||
int x86_was_reset = 0;
|
||||
int soft_reset_pci = 0;
|
||||
|
||||
/* Is the TRAP flag on? */
|
||||
int trap = 0;
|
||||
@@ -71,7 +73,8 @@ int trap = 0;
|
||||
uint32_t easeg;
|
||||
|
||||
/* This is for the OPTI 283 special reset handling mode. */
|
||||
int reset_on_hlt, hlt_reset_pending;
|
||||
int reset_on_hlt;
|
||||
int hlt_reset_pending;
|
||||
|
||||
#ifdef ENABLE_X86_LOG
|
||||
void dumpregs(int);
|
||||
@@ -171,7 +174,10 @@ makemod1table(void)
|
||||
static void
|
||||
makeznptable(void)
|
||||
{
|
||||
int c, d, e;
|
||||
int c;
|
||||
int d;
|
||||
int e;
|
||||
|
||||
for (c = 0; c < 256; c++) {
|
||||
d = 0;
|
||||
for (e = 0; e < 8; e++) {
|
||||
|
||||
@@ -9,30 +9,44 @@
|
||||
that we don't end up with an unnecessarily short block*/
|
||||
#define ABRT_EXPECTED 0x80
|
||||
|
||||
extern uint8_t opcode, opcode2;
|
||||
extern uint8_t opcode;
|
||||
extern uint8_t opcode2;
|
||||
extern uint8_t flags_p;
|
||||
extern uint8_t znptable8[256];
|
||||
|
||||
extern uint16_t zero, oldcs;
|
||||
extern uint16_t lastcs, lastpc;
|
||||
extern uint16_t zero;
|
||||
extern uint16_t oldcs;
|
||||
extern uint16_t lastcs;
|
||||
extern uint16_t lastpc;
|
||||
extern uint16_t *mod1add[2][8];
|
||||
extern uint16_t znptable16[65536];
|
||||
|
||||
extern int x86_was_reset, trap;
|
||||
extern int codegen_flat_ss, codegen_flat_ds;
|
||||
extern int timetolive, keyboardtimer, trap;
|
||||
extern int optype, stack32;
|
||||
extern int oldcpl, cgate32, cpl_override;
|
||||
extern int x86_was_reset;
|
||||
extern int trap;
|
||||
extern int codegen_flat_ss;
|
||||
extern int codegen_flat_ds;
|
||||
extern int timetolive;
|
||||
extern int keyboardtimer;
|
||||
extern int trap;
|
||||
extern int optype;
|
||||
extern int stack32;
|
||||
extern int oldcpl;
|
||||
extern int cgate32;
|
||||
extern int cpl_override;
|
||||
extern int nmi_enable;
|
||||
extern int oddeven, inttype;
|
||||
extern int oddeven;
|
||||
extern int inttype;
|
||||
|
||||
extern uint32_t use32;
|
||||
extern uint32_t rmdat, easeg;
|
||||
extern uint32_t oxpc, flags_zn;
|
||||
extern uint32_t rmdat;
|
||||
extern uint32_t easeg;
|
||||
extern uint32_t oxpc;
|
||||
extern uint32_t flags_zn;
|
||||
extern uint32_t abrt_error;
|
||||
extern uint32_t backupregs[16];
|
||||
extern uint32_t *mod1seg[8];
|
||||
extern uint32_t *eal_r, *eal_w;
|
||||
extern uint32_t *eal_r;
|
||||
extern uint32_t *eal_w;
|
||||
|
||||
#define fetchdat rmdat
|
||||
|
||||
@@ -68,13 +82,13 @@ extern uint32_t *eal_r, *eal_w;
|
||||
|
||||
enum {
|
||||
ABRT_NONE = 0,
|
||||
ABRT_GEN,
|
||||
ABRT_TS = 0xA,
|
||||
ABRT_NP = 0xB,
|
||||
ABRT_SS = 0xC,
|
||||
ABRT_GPF = 0xD,
|
||||
ABRT_PF = 0xE,
|
||||
ABRT_DE = 0x40 /* INT 0, but we have to distinguish it from ABRT_NONE. */
|
||||
ABRT_GEN = 1,
|
||||
ABRT_TS = 0xA,
|
||||
ABRT_NP = 0xB,
|
||||
ABRT_SS = 0xC,
|
||||
ABRT_GPF = 0xD,
|
||||
ABRT_PF = 0xE,
|
||||
ABRT_DE = 0x40 /* INT 0, but we have to distinguish it from ABRT_NONE. */
|
||||
};
|
||||
|
||||
extern void x86_doabrt(int x86_abrt);
|
||||
|
||||
@@ -139,7 +139,8 @@ opPSWAPD(uint32_t fetchdat)
|
||||
{
|
||||
MMX_REG src;
|
||||
MMX_REG *dst = MMX_GETREGP(cpu_reg);
|
||||
float tempf, tempf2;
|
||||
float tempf;
|
||||
float tempf2;
|
||||
|
||||
MMX_GETSRC();
|
||||
|
||||
|
||||
@@ -340,6 +340,7 @@ static int
|
||||
opCMP_b_rmw_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -359,6 +360,7 @@ static int
|
||||
opCMP_b_rmw_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -379,6 +381,7 @@ static int
|
||||
opCMP_w_rmw_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -398,6 +401,7 @@ static int
|
||||
opCMP_w_rmw_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -418,6 +422,7 @@ static int
|
||||
opCMP_l_rmw_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -437,6 +442,7 @@ static int
|
||||
opCMP_l_rmw_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -457,6 +463,7 @@ static int
|
||||
opCMP_b_rm_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -472,6 +479,7 @@ static int
|
||||
opCMP_b_rm_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -488,6 +496,7 @@ static int
|
||||
opCMP_w_rm_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -503,6 +512,7 @@ static int
|
||||
opCMP_w_rm_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -519,6 +529,7 @@ static int
|
||||
opCMP_l_rm_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -534,6 +545,7 @@ static int
|
||||
opCMP_l_rm_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -550,6 +562,7 @@ static int
|
||||
opCMP_AL_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src = getbytef();
|
||||
|
||||
setsub8(AL, src);
|
||||
CLOCK_CYCLES(timing_rr);
|
||||
PREFETCH_RUN(timing_rr, 2, -1, 0, 0, 0, 0, 0);
|
||||
@@ -560,6 +573,7 @@ static int
|
||||
opCMP_AX_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src = getwordf();
|
||||
|
||||
setsub16(AX, src);
|
||||
CLOCK_CYCLES(timing_rr);
|
||||
PREFETCH_RUN(timing_rr, 3, -1, 0, 0, 0, 0, 0);
|
||||
@@ -570,6 +584,7 @@ static int
|
||||
opCMP_EAX_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src = getlong();
|
||||
|
||||
if (cpu_state.abrt)
|
||||
return 1;
|
||||
setsub32(EAX, src);
|
||||
@@ -581,7 +596,9 @@ opCMP_EAX_imm(uint32_t fetchdat)
|
||||
static int
|
||||
opTEST_b_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t temp, temp2;
|
||||
uint8_t temp;
|
||||
uint8_t temp2;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -601,7 +618,9 @@ opTEST_b_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opTEST_b_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t temp, temp2;
|
||||
uint8_t temp;
|
||||
uint8_t temp2;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -622,7 +641,9 @@ opTEST_b_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opTEST_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t temp, temp2;
|
||||
uint16_t temp;
|
||||
uint16_t temp2;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -642,7 +663,9 @@ opTEST_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opTEST_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t temp, temp2;
|
||||
uint16_t temp;
|
||||
uint16_t temp2;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -663,7 +686,9 @@ opTEST_w_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opTEST_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t temp, temp2;
|
||||
uint32_t temp;
|
||||
uint16_t temp2;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -683,7 +708,9 @@ opTEST_l_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opTEST_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t temp, temp2;
|
||||
uint32_t temp;
|
||||
uint16_t temp2;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
@@ -803,7 +830,8 @@ opTEST_EAX(uint32_t fetchdat)
|
||||
static int
|
||||
op80_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src, dst;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -823,7 +851,8 @@ op80_a16(uint32_t fetchdat)
|
||||
static int
|
||||
op80_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src, dst;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -843,7 +872,8 @@ op80_a32(uint32_t fetchdat)
|
||||
static int
|
||||
op81_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -863,7 +893,8 @@ op81_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
op81_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -883,7 +914,8 @@ op81_w_a32(uint32_t fetchdat)
|
||||
static int
|
||||
op81_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -903,7 +935,8 @@ op81_l_a16(uint32_t fetchdat)
|
||||
static int
|
||||
op81_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -924,7 +957,8 @@ op81_l_a32(uint32_t fetchdat)
|
||||
static int
|
||||
op83_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -946,7 +980,8 @@ op83_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
op83_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -969,7 +1004,8 @@ op83_w_a32(uint32_t fetchdat)
|
||||
static int
|
||||
op83_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint16_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -991,7 +1027,8 @@ op83_l_a16(uint32_t fetchdat)
|
||||
static int
|
||||
op83_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
static int
|
||||
opCMPXCHG_b_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t temp, temp2 = AL;
|
||||
uint8_t temp;
|
||||
uint8_t temp2 = AL;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
temp = geteab();
|
||||
@@ -20,7 +22,9 @@ opCMPXCHG_b_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPXCHG_b_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t temp, temp2 = AL;
|
||||
uint8_t temp;
|
||||
uint8_t temp2 = AL;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
temp = geteab();
|
||||
@@ -40,7 +44,9 @@ opCMPXCHG_b_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPXCHG_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t temp, temp2 = AX;
|
||||
uint16_t temp;
|
||||
uint16_t temp2 = AX;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
temp = geteaw();
|
||||
@@ -59,7 +65,9 @@ opCMPXCHG_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPXCHG_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t temp, temp2 = AX;
|
||||
uint16_t temp;
|
||||
uint16_t temp2 = AX;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
temp = geteaw();
|
||||
@@ -79,7 +87,9 @@ opCMPXCHG_w_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPXCHG_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t temp, temp2 = EAX;
|
||||
uint32_t temp;
|
||||
uint32_t temp2 = EAX;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
temp = geteal();
|
||||
@@ -98,7 +108,9 @@ opCMPXCHG_l_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPXCHG_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t temp, temp2 = EAX;
|
||||
uint32_t temp;
|
||||
uint32_t temp2 = EAX;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
temp = geteal();
|
||||
@@ -119,7 +131,11 @@ opCMPXCHG_l_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPXCHG8B_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t temp, temp_hi, temp2 = EAX, temp2_hi = EDX;
|
||||
uint32_t temp;
|
||||
uint32_t temp_hi;
|
||||
uint32_t temp2 = EAX;
|
||||
uint32_t temp2_hi = EDX;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
temp = geteal();
|
||||
@@ -146,7 +162,11 @@ opCMPXCHG8B_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPXCHG8B_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t temp, temp_hi, temp2 = EAX, temp2_hi = EDX;
|
||||
uint32_t temp;
|
||||
uint32_t temp_hi;
|
||||
uint32_t temp2 = EAX;
|
||||
uint32_t temp2_hi = EDX;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
temp = geteal();
|
||||
@@ -177,7 +197,9 @@ static int
|
||||
opXADD_b_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t temp;
|
||||
uint8_t src, dest;
|
||||
uint8_t src;
|
||||
uint8_t dest;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getr8(cpu_reg);
|
||||
@@ -197,7 +219,9 @@ static int
|
||||
opXADD_b_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t temp;
|
||||
uint8_t src, dest;
|
||||
uint8_t src;
|
||||
uint8_t dest;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getr8(cpu_reg);
|
||||
@@ -218,7 +242,9 @@ static int
|
||||
opXADD_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t temp;
|
||||
uint16_t src, dest;
|
||||
uint16_t src;
|
||||
uint16_t dest;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = cpu_state.regs[cpu_reg].w;
|
||||
@@ -238,7 +264,9 @@ static int
|
||||
opXADD_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t temp;
|
||||
uint16_t src, dest;
|
||||
uint16_t src;
|
||||
uint16_t dest;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = cpu_state.regs[cpu_reg].w;
|
||||
@@ -259,7 +287,9 @@ static int
|
||||
opXADD_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t temp;
|
||||
uint32_t src, dest;
|
||||
uint32_t src;
|
||||
uint32_t dest;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = cpu_state.regs[cpu_reg].l;
|
||||
@@ -279,7 +309,9 @@ static int
|
||||
opXADD_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t temp;
|
||||
uint32_t src, dest;
|
||||
uint32_t src;
|
||||
uint32_t dest;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = cpu_state.regs[cpu_reg].l;
|
||||
|
||||
@@ -19,6 +19,7 @@ static int
|
||||
opAAD(uint32_t fetchdat)
|
||||
{
|
||||
int base = getbytef();
|
||||
|
||||
if (!cpu_isintel)
|
||||
base = 10;
|
||||
AL = (AH * base) + AL;
|
||||
@@ -33,6 +34,7 @@ static int
|
||||
opAAM(uint32_t fetchdat)
|
||||
{
|
||||
int base = getbytef();
|
||||
|
||||
if (!base || !cpu_isintel)
|
||||
base = 10;
|
||||
AH = AL / base;
|
||||
@@ -63,7 +65,9 @@ opAAS(uint32_t fetchdat)
|
||||
static int
|
||||
opDAA(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t tempw, old_AL, old_CF;
|
||||
uint16_t tempw;
|
||||
uint16_t old_AL;
|
||||
uint16_t old_CF;
|
||||
|
||||
flags_rebuild();
|
||||
old_AL = AL;
|
||||
@@ -98,7 +102,9 @@ opDAA(uint32_t fetchdat)
|
||||
static int
|
||||
opDAS(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t tempw, old_AL, old_CF;
|
||||
uint16_t tempw;
|
||||
uint16_t old_AL;
|
||||
uint16_t old_CF;
|
||||
|
||||
flags_rebuild();
|
||||
old_AL = AL;
|
||||
|
||||
@@ -201,13 +201,17 @@ opBT_l_r_a32(uint32_t fetchdat)
|
||||
return 0; \
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
opBT(C, ^=)
|
||||
opBT(R, &= ~)
|
||||
opBT(S, |=)
|
||||
opBT(R, &= ~)
|
||||
opBT(S, |=)
|
||||
// clang-format on
|
||||
|
||||
static int opBA_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opBA_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
int tempc, count;
|
||||
int tempc;
|
||||
int count;
|
||||
uint16_t temp;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
@@ -258,7 +262,8 @@ opBT(C, ^=)
|
||||
static int
|
||||
opBA_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
int tempc, count;
|
||||
int tempc;
|
||||
int count;
|
||||
uint16_t temp;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
@@ -310,7 +315,8 @@ opBA_w_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opBA_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
int tempc, count;
|
||||
int tempc;
|
||||
int count;
|
||||
uint32_t temp;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
@@ -361,7 +367,8 @@ opBA_l_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opBA_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
int tempc, count;
|
||||
int tempc;
|
||||
int count;
|
||||
uint32_t temp;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
|
||||
@@ -189,8 +189,10 @@
|
||||
static int
|
||||
opCALL_far_w(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t old_cs, old_pc;
|
||||
uint16_t new_cs, new_pc;
|
||||
uint32_t old_cs;
|
||||
uint32_t old_pc;
|
||||
uint16_t new_cs;
|
||||
uint16_t new_pc;
|
||||
int cycles_old = cycles;
|
||||
UN_USED(cycles_old);
|
||||
|
||||
@@ -209,8 +211,10 @@ opCALL_far_w(uint32_t fetchdat)
|
||||
static int
|
||||
opCALL_far_l(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t old_cs, old_pc;
|
||||
uint32_t new_cs, new_pc;
|
||||
uint32_t old_cs;
|
||||
uint32_t old_pc;
|
||||
uint32_t new_cs;
|
||||
uint32_t new_pc;
|
||||
int cycles_old = cycles;
|
||||
UN_USED(cycles_old);
|
||||
|
||||
@@ -230,8 +234,10 @@ opCALL_far_l(uint32_t fetchdat)
|
||||
static int
|
||||
opFF_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t old_cs, new_cs;
|
||||
uint32_t old_pc, new_pc;
|
||||
uint16_t old_cs;
|
||||
uint16_t new_cs;
|
||||
uint32_t old_pc;
|
||||
uint32_t new_pc;
|
||||
int cycles_old = cycles;
|
||||
UN_USED(cycles_old);
|
||||
|
||||
@@ -392,8 +398,10 @@ opFF_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opFF_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t old_cs, new_cs;
|
||||
uint32_t old_pc, new_pc;
|
||||
uint16_t old_cs;
|
||||
uint16_t new_cs;
|
||||
uint32_t old_pc;
|
||||
uint32_t new_pc;
|
||||
int cycles_old = cycles;
|
||||
UN_USED(cycles_old);
|
||||
|
||||
@@ -555,8 +563,10 @@ opFF_w_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opFF_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t old_cs, new_cs;
|
||||
uint32_t old_pc, new_pc;
|
||||
uint16_t old_cs;
|
||||
uint16_t new_cs;
|
||||
uint32_t old_pc;
|
||||
uint32_t new_pc;
|
||||
int cycles_old = cycles;
|
||||
UN_USED(cycles_old);
|
||||
|
||||
@@ -717,8 +727,10 @@ opFF_l_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opFF_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t old_cs, new_cs;
|
||||
uint32_t old_pc, new_pc;
|
||||
uint16_t old_cs;
|
||||
uint16_t new_cs;
|
||||
uint32_t old_pc;
|
||||
uint32_t new_pc;
|
||||
int cycles_old = cycles;
|
||||
UN_USED(cycles_old);
|
||||
|
||||
|
||||
@@ -97,7 +97,9 @@ opWAIT(uint32_t fetchdat)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// if (!cpu_use_dynarec && fpu_softfloat) {
|
||||
#if 0
|
||||
if (!cpu_use_dynarec && fpu_softfloat) {
|
||||
#endif
|
||||
if (fpu_softfloat) {
|
||||
if (fpu_state.swd & FPU_SW_Summary) {
|
||||
if (cr0 & 0x20) {
|
||||
|
||||
@@ -178,11 +178,13 @@ fx_save_stor_common(uint32_t fetchdat, int bits)
|
||||
uint8_t ftwb = 0;
|
||||
uint16_t rec_ftw = 0;
|
||||
uint16_t fpus = 0;
|
||||
int i, mmx_tags = 0;
|
||||
int i;
|
||||
int mmx_tags = 0;
|
||||
uint16_t exp = 0x0000;
|
||||
uint64_t mant = 0x0000000000000000ULL;
|
||||
uint64_t fraction;
|
||||
uint8_t jm, valid;
|
||||
uint8_t jm;
|
||||
uint8_t valid;
|
||||
/* Exp_all_1 Exp_all_0 Frac_all_0 J M FTW_Valid | Ent
|
||||
----------------------------------------------+------ */
|
||||
uint8_t ftw_table_idx;
|
||||
|
||||
@@ -88,7 +88,8 @@ opJ(LE)
|
||||
opJ(NLE)
|
||||
// clang-format on
|
||||
|
||||
static int opLOOPNE_w(uint32_t fetchdat)
|
||||
static int
|
||||
opLOOPNE_w(uint32_t fetchdat)
|
||||
{
|
||||
int8_t offset = (int8_t) getbytef();
|
||||
CX--;
|
||||
@@ -271,8 +272,10 @@ opJMP_r32(uint32_t fetchdat)
|
||||
static int
|
||||
opJMP_far_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t addr, seg;
|
||||
uint16_t addr;
|
||||
uint16_t seg;
|
||||
uint32_t old_pc;
|
||||
|
||||
addr = getwordf();
|
||||
seg = getword();
|
||||
if (cpu_state.abrt)
|
||||
@@ -289,7 +292,9 @@ static int
|
||||
opJMP_far_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t seg;
|
||||
uint32_t addr, old_pc;
|
||||
uint32_t addr;
|
||||
uint32_t old_pc;
|
||||
|
||||
addr = getlong();
|
||||
seg = getword();
|
||||
if (cpu_state.abrt)
|
||||
@@ -307,6 +312,7 @@ static int
|
||||
opCALL_r16(uint32_t fetchdat)
|
||||
{
|
||||
int16_t addr = (int16_t) getwordf();
|
||||
|
||||
PUSH_W(cpu_state.pc);
|
||||
cpu_state.pc += addr;
|
||||
cpu_state.pc &= 0xffff;
|
||||
@@ -320,6 +326,7 @@ static int
|
||||
opCALL_r32(uint32_t fetchdat)
|
||||
{
|
||||
int32_t addr = getlong();
|
||||
|
||||
if (cpu_state.abrt)
|
||||
return 1;
|
||||
PUSH_L(cpu_state.pc);
|
||||
|
||||
@@ -55,7 +55,8 @@ opF6_a16(uint32_t fetchdat)
|
||||
int tempws2 = 0;
|
||||
uint16_t tempw = 0;
|
||||
uint16_t src16;
|
||||
uint8_t src, dst;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
int8_t temps;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
@@ -173,7 +174,8 @@ opF6_a32(uint32_t fetchdat)
|
||||
int tempws2 = 0;
|
||||
uint16_t tempw = 0;
|
||||
uint16_t src16;
|
||||
uint8_t src, dst;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
int8_t temps;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
@@ -404,7 +406,8 @@ opF7_w_a32(uint32_t fetchdat)
|
||||
int tempws;
|
||||
int tempws2 = 1;
|
||||
int16_t temps16;
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -514,7 +517,8 @@ static int
|
||||
opF7_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint64_t temp64;
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -606,7 +610,8 @@ static int
|
||||
opF7_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint64_t temp64;
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -739,7 +744,8 @@ opLOCK(uint32_t fetchdat)
|
||||
static int
|
||||
opBOUND_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
int16_t low, high;
|
||||
int16_t low;
|
||||
int16_t high;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
ILLEGAL_ON(cpu_mod == 3);
|
||||
@@ -761,7 +767,8 @@ opBOUND_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opBOUND_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
int16_t low, high;
|
||||
int16_t low;
|
||||
int16_t high;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
ILLEGAL_ON(cpu_mod == 3);
|
||||
@@ -784,7 +791,8 @@ opBOUND_w_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opBOUND_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
int32_t low, high;
|
||||
int32_t low;
|
||||
int32_t high;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
ILLEGAL_ON(cpu_mod == 3);
|
||||
@@ -806,7 +814,8 @@ opBOUND_l_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opBOUND_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
int32_t low, high;
|
||||
int32_t low;
|
||||
int32_t high;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
ILLEGAL_ON(cpu_mod == 3);
|
||||
|
||||
@@ -115,7 +115,7 @@ opMOVD_mm_l_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opMOVD_mm_l_a16_cx(uint32_t fetchdat)
|
||||
{
|
||||
MMX_REG *op;
|
||||
const MMX_REG *op;
|
||||
|
||||
if (in_smm)
|
||||
return opSMINT(fetchdat);
|
||||
@@ -144,7 +144,7 @@ opMOVD_mm_l_a16_cx(uint32_t fetchdat)
|
||||
static int
|
||||
opMOVD_mm_l_a32_cx(uint32_t fetchdat)
|
||||
{
|
||||
MMX_REG *op;
|
||||
const MMX_REG *op;
|
||||
|
||||
if (in_smm)
|
||||
return opSMINT(fetchdat);
|
||||
|
||||
@@ -251,12 +251,17 @@ opMOV_DRx_r_a32(uint32_t fetchdat)
|
||||
static void
|
||||
opMOV_r_TRx(void)
|
||||
{
|
||||
// uint32_t base;
|
||||
#if 0
|
||||
uint32_t base;
|
||||
|
||||
base = _tr[4] & 0xfffff800;
|
||||
#endif
|
||||
|
||||
// base = _tr[4] & 0xfffff800;
|
||||
switch (cpu_reg) {
|
||||
case 3:
|
||||
// pclog("[R] %08X cache = %08X\n", base + cache_index, _tr[3]);
|
||||
#if 0
|
||||
pclog("[R] %08X cache = %08X\n", base + cache_index, _tr[3]);
|
||||
#endif
|
||||
_tr[3] = *(uint32_t *) &(_cache[cache_index]);
|
||||
cache_index = (cache_index + 4) & 0xf;
|
||||
break;
|
||||
@@ -293,42 +298,57 @@ static void
|
||||
opMOV_TRx_r(void)
|
||||
{
|
||||
uint32_t base;
|
||||
int i, ctl;
|
||||
int i;
|
||||
int ctl;
|
||||
|
||||
_tr[cpu_reg] = cpu_state.regs[cpu_rm].l;
|
||||
base = _tr[4] & 0xfffff800;
|
||||
ctl = _tr[5] & 3;
|
||||
switch (cpu_reg) {
|
||||
case 3:
|
||||
// pclog("[W] %08X cache = %08X\n", base + cache_index, _tr[3]);
|
||||
#if 0
|
||||
pclog("[W] %08X cache = %08X\n", base + cache_index, _tr[3]);
|
||||
#endif
|
||||
*(uint32_t *) &(_cache[cache_index]) = _tr[3];
|
||||
cache_index = (cache_index + 4) & 0xf;
|
||||
break;
|
||||
case 4:
|
||||
// if (!(cr0 & 1) && !(_tr[5] & (1 << 19)))
|
||||
// pclog("TAG = %08X, DEST = %08X\n", base, base + cache_index - 16);
|
||||
#if 0
|
||||
if (!(cr0 & 1) && !(_tr[5] & (1 << 19)))
|
||||
pclog("TAG = %08X, DEST = %08X\n", base, base + cache_index - 16);
|
||||
#endif
|
||||
break;
|
||||
case 5:
|
||||
// pclog("[16] EXT = %i (%i), SET = %04X\n", !!(_tr[5] & (1 << 19)), _tr[5] & 0x03, _tr[5] & 0x7f0);
|
||||
#if 0
|
||||
pclog("[16] EXT = %i (%i), SET = %04X\n", !!(_tr[5] & (1 << 19)), _tr[5] & 0x03, _tr[5] & 0x7f0);
|
||||
#endif
|
||||
if (!(_tr[5] & (1 << 19))) {
|
||||
switch (ctl) {
|
||||
case 0:
|
||||
// pclog(" Cache fill or read...\n", base);
|
||||
#if 0
|
||||
pclog(" Cache fill or read...\n", base);
|
||||
#endif
|
||||
break;
|
||||
case 1:
|
||||
base += (_tr[5] & 0x7f0);
|
||||
// pclog(" Writing 16 bytes to %08X...\n", base);
|
||||
#if 0
|
||||
pclog(" Writing 16 bytes to %08X...\n", base);
|
||||
#endif
|
||||
for (i = 0; i < 16; i += 4)
|
||||
mem_writel_phys(base + i, *(uint32_t *) &(_cache[i]));
|
||||
break;
|
||||
case 2:
|
||||
base += (_tr[5] & 0x7f0);
|
||||
// pclog(" Reading 16 bytes from %08X...\n", base);
|
||||
#if 0
|
||||
pclog(" Reading 16 bytes from %08X...\n", base);
|
||||
#endif
|
||||
for (i = 0; i < 16; i += 4)
|
||||
*(uint32_t *) &(_cache[i]) = mem_readl_phys(base + i);
|
||||
break;
|
||||
case 3:
|
||||
// pclog(" Cache invalidate/flush...\n", base);
|
||||
#if 0
|
||||
pclog(" Cache invalidate/flush...\n", base);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,8 @@ opMOV_seg_w_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opLDS_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t addr, seg;
|
||||
uint16_t addr;
|
||||
uint16_t seg;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
ILLEGAL_ON(cpu_mod == 3);
|
||||
@@ -280,7 +281,8 @@ opLDS_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opLDS_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t addr, seg;
|
||||
uint16_t addr;
|
||||
uint16_t seg;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
ILLEGAL_ON(cpu_mod == 3);
|
||||
@@ -349,7 +351,8 @@ opLDS_l_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opLSS_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t addr, seg;
|
||||
uint16_t addr;
|
||||
uint16_t seg;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
ILLEGAL_ON(cpu_mod == 3);
|
||||
@@ -371,7 +374,8 @@ opLSS_w_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opLSS_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t addr, seg;
|
||||
uint16_t addr;
|
||||
uint16_t seg;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
ILLEGAL_ON(cpu_mod == 3);
|
||||
|
||||
@@ -2,7 +2,8 @@ static int
|
||||
opIMUL_w_iw_a16(uint32_t fetchdat)
|
||||
{
|
||||
int32_t templ;
|
||||
int16_t tempw, tempw2;
|
||||
int16_t tempw;
|
||||
int16_t tempw2;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -31,7 +32,8 @@ static int
|
||||
opIMUL_w_iw_a32(uint32_t fetchdat)
|
||||
{
|
||||
int32_t templ;
|
||||
int16_t tempw, tempw2;
|
||||
int16_t tempw;
|
||||
int16_t tempw2;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -61,7 +63,8 @@ static int
|
||||
opIMUL_l_il_a16(uint32_t fetchdat)
|
||||
{
|
||||
int64_t temp64;
|
||||
int32_t templ, templ2;
|
||||
int32_t templ;
|
||||
int32_t templ2;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -90,7 +93,8 @@ static int
|
||||
opIMUL_l_il_a32(uint32_t fetchdat)
|
||||
{
|
||||
int64_t temp64;
|
||||
int32_t templ, templ2;
|
||||
int32_t templ;
|
||||
int32_t templ2;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -120,7 +124,8 @@ static int
|
||||
opIMUL_w_ib_a16(uint32_t fetchdat)
|
||||
{
|
||||
int32_t templ;
|
||||
int16_t tempw, tempw2;
|
||||
int16_t tempw;
|
||||
int16_t tempw2;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -151,7 +156,8 @@ static int
|
||||
opIMUL_w_ib_a32(uint32_t fetchdat)
|
||||
{
|
||||
int32_t templ;
|
||||
int16_t tempw, tempw2;
|
||||
int16_t tempw;
|
||||
int16_t tempw2;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -183,7 +189,8 @@ static int
|
||||
opIMUL_l_ib_a16(uint32_t fetchdat)
|
||||
{
|
||||
int64_t temp64;
|
||||
int32_t templ, templ2;
|
||||
int32_t templ;
|
||||
int32_t templ2;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -214,7 +221,8 @@ static int
|
||||
opIMUL_l_ib_a32(uint32_t fetchdat)
|
||||
{
|
||||
int64_t temp64;
|
||||
int32_t templ, templ2;
|
||||
int32_t templ;
|
||||
int32_t templ2;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
|
||||
@@ -179,10 +179,16 @@ opLAR(w_a16, fetch_ea_16, 0, 0)
|
||||
|
||||
static int op0F00_common(uint32_t fetchdat, int ea32)
|
||||
{
|
||||
int dpl, valid, granularity;
|
||||
uint32_t addr, base, limit;
|
||||
uint16_t desc, sel;
|
||||
uint8_t access, ar_high;
|
||||
int dpl;
|
||||
int valid;
|
||||
int granularity;
|
||||
uint32_t addr;
|
||||
uint32_t base;
|
||||
uint32_t limit;
|
||||
uint16_t desc;
|
||||
uint16_t sel;
|
||||
uint8_t access;
|
||||
uint8_t ar_high;
|
||||
|
||||
switch (rmdat & 0x38) {
|
||||
case 0x00: /*SLDT*/
|
||||
@@ -356,7 +362,9 @@ static int
|
||||
op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32)
|
||||
{
|
||||
uint32_t base;
|
||||
uint16_t limit, tempw;
|
||||
uint16_t limit;
|
||||
uint16_t tempw;
|
||||
|
||||
switch (rmdat & 0x38) {
|
||||
case 0x00: /*SGDT*/
|
||||
if (cpu_mod != 3)
|
||||
|
||||
@@ -90,7 +90,8 @@ op_seg(GS_REPNE, cpu_state.seg_gs, x86_opcodes_REPNE, x86_opcodes)
|
||||
op_seg(SS_REPNE, cpu_state.seg_ss, x86_opcodes_REPNE, x86_opcodes)
|
||||
// clang-format on
|
||||
|
||||
static int op_66(uint32_t fetchdat) /*Data size select*/
|
||||
static int
|
||||
op_66(uint32_t fetchdat) /*Data size select*/
|
||||
{
|
||||
fetchdat = fastreadl(cs + cpu_state.pc);
|
||||
if (cpu_state.abrt)
|
||||
|
||||
@@ -190,7 +190,9 @@ opIRET(uint32_t fetchdat)
|
||||
|
||||
if ((cr0 & 1) && (cpu_state.eflags & VM_FLAG) && (IOPL != 3)) {
|
||||
if (cr4 & CR4_VME) {
|
||||
uint16_t new_pc, new_cs, new_flags;
|
||||
uint16_t new_pc;
|
||||
uint16_t new_cs;
|
||||
uint16_t new_flags;
|
||||
|
||||
new_pc = readmemw(ss, SP);
|
||||
new_cs = readmemw(ss, ((SP + 2) & 0xffff));
|
||||
|
||||
@@ -605,7 +605,8 @@ opC0_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint8_t temp, temp2 = 0;
|
||||
uint8_t temp;
|
||||
uint8_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -624,7 +625,8 @@ opC0_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint8_t temp, temp2 = 0;
|
||||
uint8_t temp;
|
||||
uint8_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -643,7 +645,8 @@ opC1_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint16_t temp, temp2 = 0;
|
||||
uint16_t temp;
|
||||
uint16_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -662,7 +665,8 @@ opC1_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint16_t temp, temp2 = 0;
|
||||
uint16_t temp;
|
||||
uint16_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -681,7 +685,8 @@ opC1_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint32_t temp, temp2 = 0;
|
||||
uint32_t temp;
|
||||
uint32_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -700,7 +705,8 @@ opC1_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint32_t temp, temp2 = 0;
|
||||
uint32_t temp;
|
||||
uint32_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -720,7 +726,8 @@ opD0_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c = 1;
|
||||
int tempc;
|
||||
uint8_t temp, temp2 = 0;
|
||||
uint8_t temp;
|
||||
uint8_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -736,7 +743,8 @@ opD0_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c = 1;
|
||||
int tempc;
|
||||
uint8_t temp, temp2 = 0;
|
||||
uint8_t temp;
|
||||
uint8_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -752,7 +760,8 @@ opD1_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c = 1;
|
||||
int tempc;
|
||||
uint16_t temp, temp2 = 0;
|
||||
uint16_t temp;
|
||||
uint16_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -768,7 +777,8 @@ opD1_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c = 1;
|
||||
int tempc;
|
||||
uint16_t temp, temp2 = 0;
|
||||
uint16_t temp;
|
||||
uint16_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -784,7 +794,8 @@ opD1_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c = 1;
|
||||
int tempc;
|
||||
uint32_t temp, temp2 = 0;
|
||||
uint32_t temp;
|
||||
uint32_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -800,7 +811,8 @@ opD1_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c = 1;
|
||||
int tempc;
|
||||
uint32_t temp, temp2 = 0;
|
||||
uint32_t temp;
|
||||
uint32_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -817,7 +829,8 @@ opD2_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint8_t temp, temp2 = 0;
|
||||
uint8_t temp;
|
||||
uint8_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -834,7 +847,8 @@ opD2_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint8_t temp, temp2 = 0;
|
||||
uint8_t temp;
|
||||
uint8_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -851,7 +865,8 @@ opD3_w_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint16_t temp, temp2 = 0;
|
||||
uint16_t temp;
|
||||
uint16_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -868,7 +883,8 @@ opD3_w_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint16_t temp, temp2 = 0;
|
||||
uint16_t temp;
|
||||
uint16_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -885,7 +901,8 @@ opD3_l_a16(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint32_t temp, temp2 = 0;
|
||||
uint32_t temp;
|
||||
uint32_t temp2 = 0;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
@@ -902,7 +919,8 @@ opD3_l_a32(uint32_t fetchdat)
|
||||
{
|
||||
int c;
|
||||
int tempc;
|
||||
uint32_t temp, temp2 = 0;
|
||||
uint32_t temp;
|
||||
uint32_t temp2 = 0;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
|
||||
@@ -379,9 +379,13 @@ opENTER_w(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t offset;
|
||||
int count;
|
||||
uint32_t tempEBP, tempESP, frame_ptr;
|
||||
uint32_t tempEBP;
|
||||
uint32_t tempESP;
|
||||
uint32_t frame_ptr;
|
||||
#ifndef IS_DYNAREC
|
||||
int reads = 0, writes = 1, instr_cycles = 0;
|
||||
int reads = 0;
|
||||
int writes = 1;
|
||||
int instr_cycles = 0;
|
||||
#endif
|
||||
uint16_t tempw;
|
||||
|
||||
@@ -448,9 +452,13 @@ opENTER_l(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t offset;
|
||||
int count;
|
||||
uint32_t tempEBP, tempESP, frame_ptr;
|
||||
uint32_t tempEBP;
|
||||
uint32_t tempESP;
|
||||
uint32_t frame_ptr;
|
||||
#ifndef IS_DYNAREC
|
||||
int reads = 0, writes = 1, instr_cycles = 0;
|
||||
int reads = 0;
|
||||
int writes = 1;
|
||||
int instr_cycles = 0;
|
||||
#endif
|
||||
uint32_t templ;
|
||||
|
||||
|
||||
@@ -219,7 +219,8 @@ opMOVSL_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSB_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src, dst;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
|
||||
addr64 = addr64_2 = 0x00000000;
|
||||
|
||||
@@ -259,7 +260,8 @@ opCMPSB_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSB_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src, dst;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
|
||||
addr64 = addr64_2 = 0x00000000;
|
||||
|
||||
@@ -300,7 +302,8 @@ opCMPSB_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSW_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
addr64a[0] = addr64a[1] = 0x00000000;
|
||||
addr64a_2[0] = addr64a_2[1] = 0x00000000;
|
||||
@@ -341,7 +344,8 @@ opCMPSW_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSW_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
addr64a[0] = addr64a[1] = 0x00000000;
|
||||
addr64a_2[0] = addr64a_2[1] = 0x00000000;
|
||||
@@ -383,7 +387,8 @@ opCMPSW_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSL_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
addr64a[0] = addr64a[1] = addr64a[2] = addr64a[3] = 0x00000000;
|
||||
addr64a_2[0] = addr64a_2[1] = addr64a_2[2] = addr64a_2[3] = 0x00000000;
|
||||
@@ -424,7 +429,8 @@ opCMPSL_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSL_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
addr64a[0] = addr64a[1] = addr64a[2] = addr64a[3] = 0x00000000;
|
||||
addr64a_2[0] = addr64a_2[1] = addr64a_2[2] = addr64a_2[3] = 0x00000000;
|
||||
|
||||
@@ -219,7 +219,8 @@ opMOVSL_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSB_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src, dst;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
|
||||
addr64 = addr64_2 = 0x00000000;
|
||||
|
||||
@@ -255,7 +256,8 @@ opCMPSB_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSB_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint8_t src, dst;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
|
||||
addr64 = addr64_2 = 0x00000000;
|
||||
|
||||
@@ -292,7 +294,8 @@ opCMPSB_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSW_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
addr64a[0] = addr64a[1] = 0x00000000;
|
||||
addr64a_2[0] = addr64a_2[1] = 0x00000000;
|
||||
@@ -329,7 +332,8 @@ opCMPSW_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSW_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t src, dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
addr64a[0] = addr64a[1] = 0x00000000;
|
||||
addr64a_2[0] = addr64a_2[1] = 0x00000000;
|
||||
@@ -367,7 +371,8 @@ opCMPSW_a32(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSL_a16(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
addr64a[0] = addr64a[1] = addr64a[2] = addr64a[3] = 0x00000000;
|
||||
addr64a_2[0] = addr64a_2[1] = addr64a_2[2] = addr64a_2[3] = 0x00000000;
|
||||
@@ -404,7 +409,8 @@ opCMPSL_a16(uint32_t fetchdat)
|
||||
static int
|
||||
opCMPSL_a32(uint32_t fetchdat)
|
||||
{
|
||||
uint32_t src, dst;
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
|
||||
addr64a[0] = addr64a[1] = addr64a[2] = addr64a[3] = 0x00000000;
|
||||
addr64a_2[0] = addr64a_2[1] = addr64a_2[2] = addr64a_2[3] = 0x00000000;
|
||||
|
||||
194
src/cpu/x86seg.c
194
src/cpu/x86seg.c
@@ -31,13 +31,17 @@
|
||||
#include <86box/machine.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/nvr.h>
|
||||
#include <86box/plat_fallthrough.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
#include "x86.h"
|
||||
#include "x86_flags.h"
|
||||
#include "386_common.h"
|
||||
|
||||
uint8_t opcode2;
|
||||
|
||||
int cgate16, cgate32;
|
||||
int cgate16;
|
||||
int cgate32;
|
||||
int intgatesize;
|
||||
|
||||
void taskswitch286(uint16_t seg, uint16_t *segdat, int is32);
|
||||
@@ -157,7 +161,7 @@ x86_doabrt(int x86_abrt)
|
||||
}
|
||||
|
||||
void
|
||||
x86de(char *s, uint16_t error)
|
||||
x86de(UNUSED(char *s), UNUSED(uint16_t error))
|
||||
{
|
||||
#ifdef BAD_CODE
|
||||
cpu_state.abrt = ABRT_DE;
|
||||
@@ -168,35 +172,35 @@ x86de(char *s, uint16_t error)
|
||||
}
|
||||
|
||||
void
|
||||
x86gpf(char *s, uint16_t error)
|
||||
x86gpf(UNUSED(char *s), uint16_t error)
|
||||
{
|
||||
cpu_state.abrt = ABRT_GPF;
|
||||
abrt_error = error;
|
||||
}
|
||||
|
||||
void
|
||||
x86gpf_expected(char *s, uint16_t error)
|
||||
x86gpf_expected(UNUSED(char *s), uint16_t error)
|
||||
{
|
||||
cpu_state.abrt = ABRT_GPF | ABRT_EXPECTED;
|
||||
abrt_error = error;
|
||||
}
|
||||
|
||||
void
|
||||
x86ss(char *s, uint16_t error)
|
||||
x86ss(UNUSED(char *s), uint16_t error)
|
||||
{
|
||||
cpu_state.abrt = ABRT_SS;
|
||||
abrt_error = error;
|
||||
}
|
||||
|
||||
void
|
||||
x86ts(char *s, uint16_t error)
|
||||
x86ts(UNUSED(char *s), uint16_t error)
|
||||
{
|
||||
cpu_state.abrt = ABRT_TS;
|
||||
abrt_error = error;
|
||||
}
|
||||
|
||||
void
|
||||
x86np(char *s, uint16_t error)
|
||||
x86np(UNUSED(char *s), uint16_t error)
|
||||
{
|
||||
cpu_state.abrt = ABRT_NP;
|
||||
abrt_error = error;
|
||||
@@ -272,9 +276,9 @@ do_seg_v86_init(x86seg *s)
|
||||
static void
|
||||
check_seg_valid(x86seg *s)
|
||||
{
|
||||
int dpl = (s->access >> 5) & 3;
|
||||
int valid = 1;
|
||||
x86seg *dt = (s->seg & 0x0004) ? &ldt : &gdt;
|
||||
int dpl = (s->access >> 5) & 3;
|
||||
int valid = 1;
|
||||
const x86seg *dt = (s->seg & 0x0004) ? &ldt : &gdt;
|
||||
|
||||
if (((s->seg & 0xfff8UL) + 7UL) > dt->limit)
|
||||
valid = 0;
|
||||
@@ -334,10 +338,11 @@ void
|
||||
#endif
|
||||
loadseg(uint16_t seg, x86seg *s)
|
||||
{
|
||||
uint16_t segdat[4];
|
||||
uint32_t addr, *segdat32 = (uint32_t *) segdat;
|
||||
int dpl;
|
||||
x86seg *dt;
|
||||
uint16_t segdat[4];
|
||||
uint32_t addr;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
int dpl;
|
||||
const x86seg *dt;
|
||||
|
||||
if ((msw & 1) && !(cpu_state.eflags & VM_FLAG)) {
|
||||
if (!(seg & 0xfffc)) {
|
||||
@@ -531,9 +536,10 @@ loadseg(uint16_t seg, x86seg *s)
|
||||
void
|
||||
loadcs(uint16_t seg)
|
||||
{
|
||||
uint16_t segdat[4];
|
||||
uint32_t addr, *segdat32 = (uint32_t *) segdat;
|
||||
x86seg *dt;
|
||||
uint16_t segdat[4];
|
||||
uint32_t addr;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
const x86seg *dt;
|
||||
|
||||
x86seg_log("Load CS %04X\n", seg);
|
||||
|
||||
@@ -619,11 +625,13 @@ loadcs(uint16_t seg)
|
||||
void
|
||||
loadcsjmp(uint16_t seg, uint32_t old_pc)
|
||||
{
|
||||
uint16_t type, seg2;
|
||||
uint16_t segdat[4];
|
||||
uint32_t addr, newpc;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
x86seg *dt;
|
||||
uint16_t type;
|
||||
uint16_t seg2;
|
||||
uint16_t segdat[4];
|
||||
uint32_t addr;
|
||||
uint32_t newpc;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
const x86seg *dt;
|
||||
|
||||
if ((msw & 1) && !(cpu_state.eflags & VM_FLAG)) {
|
||||
if (!(seg & 0xfffc)) {
|
||||
@@ -743,7 +751,7 @@ loadcsjmp(uint16_t seg, uint32_t old_pc)
|
||||
x86gpf("loadcsjmp(): Non-conforming DPL > CPL", seg2 & 0xfffc);
|
||||
return;
|
||||
}
|
||||
/*FALLTHROUGH*/
|
||||
fallthrough;
|
||||
case 0x1c00:
|
||||
case 0x1d00:
|
||||
case 0x1e00:
|
||||
@@ -890,16 +898,24 @@ void
|
||||
loadcscall(uint16_t seg)
|
||||
#endif
|
||||
{
|
||||
uint16_t seg2, newss;
|
||||
uint16_t segdat[4], segdat2[4];
|
||||
uint32_t addr, oldssbase = ss;
|
||||
uint32_t oaddr, newpc;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
int count, type;
|
||||
uint32_t oldss, oldsp, newsp, oldsp2;
|
||||
uint16_t tempw;
|
||||
x86seg *dt;
|
||||
uint16_t seg2;
|
||||
uint16_t newss;
|
||||
uint16_t segdat[4];
|
||||
uint16_t segdat2[4];
|
||||
uint32_t addr;
|
||||
uint32_t oldssbase = ss;
|
||||
uint32_t oaddr;
|
||||
uint32_t newpc;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
int count;
|
||||
int type;
|
||||
uint32_t oldss;
|
||||
uint32_t oldsp;
|
||||
uint32_t newsp;
|
||||
uint32_t oldsp2;
|
||||
uint16_t tempw;
|
||||
const x86seg *dt;
|
||||
|
||||
if ((msw & 1) && !(cpu_state.eflags & VM_FLAG)) {
|
||||
x86seg_log("Protected mode CS load! %04X\n", seg);
|
||||
@@ -1174,7 +1190,7 @@ loadcscall(uint16_t seg)
|
||||
x86gpf("loadcscall(): Call PM Gate Inner DPL > CPL", seg2 & 0xfffc);
|
||||
return;
|
||||
}
|
||||
/*FALLTHROUGH*/
|
||||
fallthrough;
|
||||
case 0x1c00:
|
||||
case 0x1d00:
|
||||
case 0x1e00:
|
||||
@@ -1237,12 +1253,18 @@ loadcscall(uint16_t seg)
|
||||
void
|
||||
pmoderetf(int is32, uint16_t off)
|
||||
{
|
||||
uint16_t segdat[4], segdat2[4], seg, newss;
|
||||
uint32_t newpc, newsp, addr, oaddr;
|
||||
uint32_t oldsp = ESP;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
x86seg *dt;
|
||||
uint16_t segdat[4];
|
||||
uint16_t segdat2[4];
|
||||
uint16_t seg;
|
||||
uint16_t newss;
|
||||
uint32_t newpc;
|
||||
uint32_t newsp;
|
||||
uint32_t addr;
|
||||
uint32_t oaddr;
|
||||
uint32_t oldsp = ESP;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
const x86seg *dt;
|
||||
|
||||
x86seg_log("RETF %i %04X:%04X %08X %04X\n", is32, CS, cpu_state.pc, cr0, cpu_state.eflags);
|
||||
if (is32) {
|
||||
@@ -1467,17 +1489,22 @@ pmoderetf(int is32, uint16_t off)
|
||||
void
|
||||
pmodeint(int num, int soft)
|
||||
{
|
||||
uint16_t segdat[4], segdat2[4];
|
||||
uint16_t segdat3[4];
|
||||
uint16_t newss, seg = 0;
|
||||
int type, new_cpl;
|
||||
uint32_t addr, oaddr;
|
||||
uint32_t oldss, oldsp;
|
||||
uint32_t newsp;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
uint32_t *segdat332 = (uint32_t *) segdat3;
|
||||
x86seg *dt;
|
||||
uint16_t segdat[4];
|
||||
uint16_t segdat2[4];
|
||||
uint16_t segdat3[4];
|
||||
uint16_t newss;
|
||||
uint16_t seg = 0;
|
||||
int type;
|
||||
int new_cpl;
|
||||
uint32_t addr;
|
||||
uint32_t oaddr;
|
||||
uint32_t oldss;
|
||||
uint32_t oldsp;
|
||||
uint32_t newsp;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
uint32_t *segdat332 = (uint32_t *) segdat3;
|
||||
const x86seg *dt;
|
||||
|
||||
if ((cpu_state.eflags & VM_FLAG) && (IOPL != 3) && soft) {
|
||||
x86seg_log("V86 banned int\n");
|
||||
@@ -1661,7 +1688,7 @@ pmodeint(int num, int soft)
|
||||
x86gpf("pmodeint(): DPL != CPL", seg & 0xfffc);
|
||||
return;
|
||||
}
|
||||
/*FALLTHROUGH*/
|
||||
fallthrough;
|
||||
case 0x1c00:
|
||||
case 0x1d00:
|
||||
case 0x1e00:
|
||||
@@ -1750,16 +1777,21 @@ pmodeint(int num, int soft)
|
||||
void
|
||||
pmodeiret(int is32)
|
||||
{
|
||||
uint16_t newss, seg = 0;
|
||||
uint16_t segdat[4], segdat2[4];
|
||||
uint16_t segs[4];
|
||||
uint32_t tempflags, flagmask;
|
||||
uint32_t newpc, newsp;
|
||||
uint32_t addr, oaddr;
|
||||
uint32_t oldsp = ESP;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
x86seg *dt;
|
||||
uint16_t newss;
|
||||
uint16_t seg = 0;
|
||||
uint16_t segdat[4];
|
||||
uint16_t segdat2[4];
|
||||
uint16_t segs[4];
|
||||
uint32_t tempflags;
|
||||
uint32_t flagmask;
|
||||
uint32_t newpc;
|
||||
uint32_t newsp;
|
||||
uint32_t addr;
|
||||
uint32_t oaddr;
|
||||
uint32_t oldsp = ESP;
|
||||
uint32_t *segdat32 = (uint32_t *) segdat;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
const x86seg *dt;
|
||||
|
||||
if (is386 && (cpu_state.eflags & VM_FLAG)) {
|
||||
if (IOPL != 3) {
|
||||
@@ -2058,15 +2090,32 @@ pmodeiret(int is32)
|
||||
void
|
||||
taskswitch286(uint16_t seg, uint16_t *segdat, int is32)
|
||||
{
|
||||
uint16_t tempw, new_ldt;
|
||||
uint16_t new_es, new_cs, new_ss, new_ds, new_fs, new_gs;
|
||||
uint16_t segdat2[4];
|
||||
uint32_t base, limit;
|
||||
uint32_t templ, new_cr3 = 0;
|
||||
uint32_t new_eax, new_ebx, new_ecx, new_edx, new_esp, new_ebp;
|
||||
uint32_t new_esi, new_edi, new_pc, new_flags, addr;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
x86seg *dt;
|
||||
uint16_t tempw;
|
||||
uint16_t new_ldt;
|
||||
uint16_t new_es;
|
||||
uint16_t new_cs;
|
||||
uint16_t new_ss;
|
||||
uint16_t new_ds;
|
||||
uint16_t new_fs;
|
||||
uint16_t new_gs;
|
||||
uint16_t segdat2[4];
|
||||
uint32_t base;
|
||||
uint32_t limit;
|
||||
uint32_t templ;
|
||||
uint32_t new_cr3 = 0;
|
||||
uint32_t new_eax;
|
||||
uint32_t new_ebx;
|
||||
uint32_t new_ecx;
|
||||
uint32_t new_edx;
|
||||
uint32_t new_esp;
|
||||
uint32_t new_ebp;
|
||||
uint32_t new_esi;
|
||||
uint32_t new_edi;
|
||||
uint32_t new_pc;
|
||||
uint32_t new_flags;
|
||||
uint32_t addr;
|
||||
uint32_t *segdat232 = (uint32_t *) segdat2;
|
||||
const x86seg *dt;
|
||||
|
||||
base = segdat[1] | ((segdat[2] & 0x00ff) << 16);
|
||||
limit = segdat[0];
|
||||
@@ -2447,7 +2496,8 @@ cyrix_write_seg_descriptor(uint32_t addr, x86seg *seg)
|
||||
void
|
||||
cyrix_load_seg_descriptor(uint32_t addr, x86seg *seg)
|
||||
{
|
||||
uint16_t segdat[4], selector;
|
||||
uint16_t segdat[4];
|
||||
uint16_t selector;
|
||||
|
||||
segdat[0] = readmemw(0, addr);
|
||||
segdat[1] = readmemw(0, addr + 2);
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
#include "386_common.h"
|
||||
#include "softfloat/softfloat-specialize.h"
|
||||
|
||||
uint32_t x87_pc_off, x87_op_off;
|
||||
uint16_t x87_pc_seg, x87_op_seg;
|
||||
uint32_t x87_pc_off;
|
||||
uint32_t x87_op_off;
|
||||
uint16_t x87_pc_seg;
|
||||
uint16_t x87_op_seg;
|
||||
|
||||
#ifdef ENABLE_FPU_LOG
|
||||
int fpu_do_log = ENABLE_FPU_LOG;
|
||||
@@ -43,9 +45,8 @@ uint16_t
|
||||
x87_gettag(void)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
int c;
|
||||
|
||||
for (c = 0; c < 8; c++) {
|
||||
for (uint8_t c = 0; c < 8; c++) {
|
||||
if (cpu_state.tag[c] == TAG_EMPTY)
|
||||
ret |= X87_TAG_EMPTY << (c * 2);
|
||||
else if (cpu_state.tag[c] & TAG_UINT64)
|
||||
@@ -62,9 +63,7 @@ x87_gettag(void)
|
||||
void
|
||||
x87_settag(uint16_t new_tag)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < 8; c++) {
|
||||
for (uint8_t c = 0; c < 8; c++) {
|
||||
int tag = (new_tag >> (c * 2)) & 3;
|
||||
|
||||
if (tag == X87_TAG_EMPTY)
|
||||
@@ -152,7 +151,8 @@ FPU_handle_NaN32(floatx80 a, float32 b, floatx80 *r, struct float_status_t *stat
|
||||
return 1;
|
||||
}
|
||||
|
||||
int aIsNaN = floatx80_is_nan(a), bIsNaN = float32_is_nan(b);
|
||||
int aIsNaN = floatx80_is_nan(a);
|
||||
int bIsNaN = float32_is_nan(b);
|
||||
if (aIsNaN | bIsNaN) {
|
||||
*r = FPU_handle_NaN32_Func(a, aIsNaN, b, bIsNaN, status);
|
||||
return 1;
|
||||
@@ -205,7 +205,8 @@ FPU_handle_NaN64(floatx80 a, float64 b, floatx80 *r, struct float_status_t *stat
|
||||
return 1;
|
||||
}
|
||||
|
||||
int aIsNaN = floatx80_is_nan(a), bIsNaN = float64_is_nan(b);
|
||||
int aIsNaN = floatx80_is_nan(a);
|
||||
int bIsNaN = float64_is_nan(b);
|
||||
if (aIsNaN | bIsNaN) {
|
||||
*r = FPU_handle_NaN64_Func(a, aIsNaN, b, bIsNaN, status);
|
||||
return 1;
|
||||
@@ -256,13 +257,13 @@ FPU_status_word_flags_fpu_compare(int float_relation)
|
||||
return (C0 | C2 | C3);
|
||||
|
||||
case float_relation_greater:
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
case float_relation_less:
|
||||
return (C0);
|
||||
return C0;
|
||||
|
||||
case float_relation_equal:
|
||||
return (C3);
|
||||
return C3;
|
||||
}
|
||||
|
||||
return (-1); // should never get here
|
||||
@@ -280,11 +281,11 @@ FPU_write_eflags_fpu_compare(int float_relation)
|
||||
break;
|
||||
|
||||
case float_relation_less:
|
||||
cpu_state.flags |= (C_FLAG);
|
||||
cpu_state.flags |= C_FLAG;
|
||||
break;
|
||||
|
||||
case float_relation_equal:
|
||||
cpu_state.flags |= (Z_FLAG);
|
||||
cpu_state.flags |= Z_FLAG;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
#define X87_TAG_INVALID 2
|
||||
#define X87_TAG_EMPTY 3
|
||||
|
||||
extern uint32_t x87_pc_off, x87_op_off;
|
||||
extern uint16_t x87_pc_seg, x87_op_seg;
|
||||
extern uint32_t x87_pc_off;
|
||||
extern uint32_t x87_op_off;
|
||||
extern uint16_t x87_pc_seg;
|
||||
extern uint16_t x87_op_seg;
|
||||
|
||||
static __inline void
|
||||
x87_set_mmx(void)
|
||||
@@ -16,7 +18,7 @@ x87_set_mmx(void)
|
||||
} else {
|
||||
cpu_state.TOP = 0;
|
||||
p = (uint64_t *) cpu_state.tag;
|
||||
*p = 0x0101010101010101ull;
|
||||
*p = 0x0101010101010101ULL;
|
||||
}
|
||||
cpu_state.ismmx = 1;
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ typedef union
|
||||
static __inline void
|
||||
x87_checkexceptions(void)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
static __inline void
|
||||
@@ -169,7 +170,8 @@ x87_pop(void)
|
||||
static __inline int16_t
|
||||
x87_fround16(double b)
|
||||
{
|
||||
int16_t a, c;
|
||||
int16_t a;
|
||||
int16_t c;
|
||||
|
||||
switch ((cpu_state.npxc >> 10) & 3) {
|
||||
case 0: /*Nearest*/
|
||||
@@ -201,7 +203,8 @@ x87_fround16_64(double b)
|
||||
static __inline int32_t
|
||||
x87_fround32(double b)
|
||||
{
|
||||
int32_t a, c;
|
||||
int32_t a;
|
||||
int32_t c;
|
||||
|
||||
switch ((cpu_state.npxc >> 10) & 3) {
|
||||
case 0: /*Nearest*/
|
||||
@@ -233,7 +236,8 @@ x87_fround32_64(double b)
|
||||
static __inline int64_t
|
||||
x87_fround(double b)
|
||||
{
|
||||
int64_t a, c;
|
||||
int64_t a;
|
||||
int64_t c;
|
||||
|
||||
switch ((cpu_state.npxc >> 10) & 3) {
|
||||
case 0: /*Nearest*/
|
||||
@@ -338,9 +342,10 @@ x87_compare(double a, double b)
|
||||
{
|
||||
#ifdef X87_INLINE_ASM
|
||||
uint32_t result;
|
||||
double ea = a, eb = b;
|
||||
const uint64_t ia = 0x3fec1a6ff866a936ull;
|
||||
const uint64_t ib = 0x3fec1a6ff866a938ull;
|
||||
double ea = a;
|
||||
double eb = b;
|
||||
const uint64_t ia = 0x3fec1a6ff866a936ULL;
|
||||
const uint64_t ib = 0x3fec1a6ff866a938ULL;
|
||||
|
||||
/* Hack to make CHKCOP happy. */
|
||||
if (!memcmp(&ea, &ia, 8) && !memcmp(&eb, &ib, 8))
|
||||
|
||||
@@ -37,16 +37,17 @@ static int
|
||||
opFXTRACT(uint32_t fetchdat)
|
||||
{
|
||||
x87_conv_t test;
|
||||
int64_t exp80, exp80final;
|
||||
double mant;
|
||||
int64_t exp80;
|
||||
int64_t exp80final;
|
||||
double mant;
|
||||
|
||||
FP_ENTER();
|
||||
cpu_state.pc++;
|
||||
test.eind.d = ST(0);
|
||||
exp80 = test.eind.ll & (0x7ff0000000000000ll);
|
||||
exp80final = (exp80 >> 52) - BIAS64;
|
||||
mant = test.eind.d / (pow(2.0, (double)exp80final));
|
||||
ST(0) = (double)exp80final;
|
||||
exp80 = test.eind.ll & 0x7ff0000000000000LL;
|
||||
exp80final = (exp80 >> 52) - BIAS64;
|
||||
mant = test.eind.d / (pow(2.0, (double) exp80final));
|
||||
ST(0) = (double) exp80final;
|
||||
FP_TAG_VALID;
|
||||
x87_push(mant);
|
||||
CLOCK_CYCLES_FPU((fpu_type >= FPU_487SX) ? (x87_timings.fxtract) : (x87_timings.fxtract * cpu_multi));
|
||||
@@ -82,7 +83,7 @@ opFINIT(uint32_t fetchdat)
|
||||
#ifdef USE_NEW_DYNAREC
|
||||
*p = 0;
|
||||
#else
|
||||
*p = 0x0303030303030303ll;
|
||||
*p = 0x0303030303030303LL;
|
||||
#endif
|
||||
cpu_state.TOP = 0;
|
||||
cpu_state.ismmx = 0;
|
||||
@@ -410,7 +411,7 @@ FSAVE(void)
|
||||
#ifdef USE_NEW_DYNAREC
|
||||
*p = 0;
|
||||
#else
|
||||
*p = 0x0303030303030303ll;
|
||||
*p = 0x0303030303030303LL;
|
||||
#endif
|
||||
cpu_state.TOP = 0;
|
||||
cpu_state.ismmx = 0;
|
||||
@@ -629,7 +630,7 @@ opFLDLN2(uint32_t fetchdat)
|
||||
{
|
||||
FP_ENTER();
|
||||
cpu_state.pc++;
|
||||
x87_push_u64(0x3fe62e42fefa39f0ull);
|
||||
x87_push_u64(0x3fe62e42fefa39f0ULL);
|
||||
CLOCK_CYCLES_FPU((fpu_type >= FPU_487SX) ? (x87_timings.fld_const) : (x87_timings.fld_const * cpu_multi));
|
||||
CONCURRENCY_CYCLES((fpu_type >= FPU_487SX) ? (x87_concurrency.fld_const) : (x87_concurrency.fld_const * cpu_multi));
|
||||
return 0;
|
||||
|
||||
@@ -18,7 +18,8 @@ fpu_save_environment(void)
|
||||
switch ((cr0 & 1) | (cpu_state.op32 & 0x100)) {
|
||||
case 0x000: { /*16-bit real mode*/
|
||||
uint16_t tmp;
|
||||
uint32_t fp_ip, fp_dp;
|
||||
uint32_t fp_ip;
|
||||
uint32_t fp_dp;
|
||||
|
||||
fp_ip = ((uint32_t)(fpu_state.fcs << 4)) | fpu_state.fip;
|
||||
fp_dp = ((uint32_t)(fpu_state.fds << 4)) | fpu_state.fdp;
|
||||
@@ -60,7 +61,9 @@ fpu_save_environment(void)
|
||||
}
|
||||
break;
|
||||
case 0x100: { /*32-bit real mode*/
|
||||
uint32_t tmp, fp_ip, fp_dp;
|
||||
uint32_t tmp;
|
||||
uint32_t fp_ip;
|
||||
uint32_t fp_dp;
|
||||
|
||||
fp_ip = ((uint32_t)(fpu_state.fcs << 4)) | fpu_state.fip;
|
||||
fp_dp = ((uint32_t)(fpu_state.fds << 4)) | fpu_state.fdp;
|
||||
@@ -114,7 +117,9 @@ fpu_load_environment(void)
|
||||
switch ((cr0 & 1) | (cpu_state.op32 & 0x100)) {
|
||||
case 0x000: { /*16-bit real mode*/
|
||||
uint16_t tmp;
|
||||
uint32_t fp_ip, fp_dp;
|
||||
uint32_t fp_ip;
|
||||
uint32_t fp_dp;
|
||||
|
||||
tmp = readmemw(easeg, cpu_state.eaaddr + 0x0c);
|
||||
fp_dp = (tmp & 0xf000) << 4;
|
||||
tmp = readmemw(easeg, cpu_state.eaaddr + 0x0a);
|
||||
@@ -156,7 +161,10 @@ fpu_load_environment(void)
|
||||
}
|
||||
break;
|
||||
case 0x100: { /*32-bit real mode*/
|
||||
uint32_t tmp, fp_ip, fp_dp;
|
||||
uint32_t tmp;
|
||||
uint32_t fp_ip;
|
||||
uint32_t fp_dp;
|
||||
|
||||
tmp = readmeml(easeg, cpu_state.eaaddr + 0x18);
|
||||
fp_dp = (tmp & 0x0ffff000) << 4;
|
||||
tmp = readmeml(easeg, cpu_state.eaaddr + 0x14);
|
||||
|
||||
@@ -203,7 +203,9 @@ sf_FPU(il, uint32_t, 32, temp, geteal(), int32_to_floatx80((int32_t)temp), 0, _i
|
||||
static int
|
||||
sf_FADD_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -230,7 +232,9 @@ next_ins:
|
||||
static int
|
||||
sf_FADD_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -258,7 +262,9 @@ next_ins:
|
||||
static int
|
||||
sf_FADDP_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -288,7 +294,9 @@ next_ins:
|
||||
static int
|
||||
sf_FDIV_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -315,7 +323,9 @@ next_ins:
|
||||
static int
|
||||
sf_FDIV_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -341,7 +351,9 @@ next_ins:
|
||||
static int
|
||||
sf_FDIVP_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -370,7 +382,9 @@ next_ins:
|
||||
static int
|
||||
sf_FDIVR_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -396,7 +410,9 @@ next_ins:
|
||||
static int
|
||||
sf_FDIVR_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -422,7 +438,9 @@ next_ins:
|
||||
static int
|
||||
sf_FDIVRP_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -451,7 +469,9 @@ next_ins:
|
||||
static int
|
||||
sf_FMUL_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -478,7 +498,9 @@ next_ins:
|
||||
static int
|
||||
sf_FMUL_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -505,7 +527,9 @@ next_ins:
|
||||
static int
|
||||
sf_FMULP_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -534,7 +558,9 @@ next_ins:
|
||||
static int
|
||||
sf_FSUB_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -561,7 +587,9 @@ next_ins:
|
||||
static int
|
||||
sf_FSUB_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -588,7 +616,9 @@ next_ins:
|
||||
static int
|
||||
sf_FSUBP_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -617,7 +647,9 @@ next_ins:
|
||||
static int
|
||||
sf_FSUBR_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -644,7 +676,9 @@ next_ins:
|
||||
static int
|
||||
sf_FSUBR_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -671,7 +705,9 @@ next_ins:
|
||||
static int
|
||||
sf_FSUBRP_sti_st0(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
|
||||
@@ -95,7 +95,8 @@ cmp_FPU(il, int32_t, 32, temp, (int32_t)geteal(), int32_to_floatx80(temp), 0, _i
|
||||
static int
|
||||
sf_FCOM_sti(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -123,7 +124,8 @@ next_ins:
|
||||
static int
|
||||
sf_FCOMP_sti(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -156,7 +158,8 @@ next_ins:
|
||||
static int
|
||||
sf_FCOMPP(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -192,7 +195,8 @@ next_ins:
|
||||
static int
|
||||
sf_FUCOMPP(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -228,7 +232,8 @@ next_ins:
|
||||
static int
|
||||
sf_FCOMI_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -256,7 +261,8 @@ next_ins:
|
||||
static int
|
||||
sf_FCOMIP_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -291,7 +297,8 @@ next_ins:
|
||||
static int
|
||||
sf_FUCOM_sti(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -319,7 +326,8 @@ next_ins:
|
||||
static int
|
||||
sf_FUCOMP_sti(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -352,7 +360,8 @@ next_ins:
|
||||
static int
|
||||
sf_FUCOMI_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
@@ -380,7 +389,8 @@ next_ins:
|
||||
static int
|
||||
sf_FUCOMIP_st0_stj(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
struct float_status_t status;
|
||||
int rc;
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@ static int
|
||||
sf_FXCH_sti(uint32_t fetchdat)
|
||||
{
|
||||
const floatx80 floatx80_default_nan = packFloatx80(0, floatx80_default_nan_exp, floatx80_default_nan_fraction);
|
||||
floatx80 st0_reg, sti_reg;
|
||||
int st0_tag, sti_tag;
|
||||
floatx80 st0_reg;
|
||||
floatx80 sti_reg;
|
||||
int st0_tag;
|
||||
int sti_tag;
|
||||
|
||||
FP_ENTER();
|
||||
FPU_check_pending_exceptions();
|
||||
|
||||
@@ -104,7 +104,9 @@ next_ins:
|
||||
static int
|
||||
sf_FPATAN(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
|
||||
FP_ENTER();
|
||||
@@ -132,7 +134,8 @@ static int
|
||||
sf_FXTRACT(uint32_t fetchdat)
|
||||
{
|
||||
struct float_status_t status;
|
||||
floatx80 a, b;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
|
||||
FP_ENTER();
|
||||
cpu_state.pc++;
|
||||
@@ -175,10 +178,13 @@ next_ins:
|
||||
static int
|
||||
sf_FPREM1(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
uint64_t quotient = 0;
|
||||
int flags, cc;
|
||||
uint64_t quotient = 0;
|
||||
int flags;
|
||||
int cc;
|
||||
|
||||
FP_ENTER();
|
||||
cpu_state.pc++;
|
||||
@@ -219,10 +225,13 @@ next_ins:
|
||||
static int
|
||||
sf_FPREM(uint32_t fetchdat)
|
||||
{
|
||||
floatx80 a, b, result;
|
||||
floatx80 a;
|
||||
floatx80 b;
|
||||
floatx80 result;
|
||||
struct float_status_t status;
|
||||
uint64_t quotient = 0;
|
||||
int flags, cc;
|
||||
uint64_t quotient = 0;
|
||||
int flags;
|
||||
int cc;
|
||||
|
||||
FP_ENTER();
|
||||
cpu_state.pc++;
|
||||
@@ -291,9 +300,11 @@ next_ins:
|
||||
static int
|
||||
sf_FSINCOS(uint32_t fetchdat)
|
||||
{
|
||||
const floatx80 floatx80_default_nan = packFloatx80(0, floatx80_default_nan_exp, floatx80_default_nan_fraction);
|
||||
const floatx80 floatx80_default_nan = packFloatx80(0, floatx80_default_nan_exp, floatx80_default_nan_fraction);
|
||||
struct float_status_t status;
|
||||
floatx80 y, sin_y, cos_y;
|
||||
floatx80 y;
|
||||
floatx80 sin_y;
|
||||
floatx80 cos_y;
|
||||
|
||||
FP_ENTER();
|
||||
cpu_state.pc++;
|
||||
|
||||
Reference in New Issue
Block a user