mirror of
https://github.com/86Box/86Box.git
synced 2026-02-25 04:45:31 -07:00
NEC Vx0: Swap the two operands in CMPSB/CMPSW, fixes #6764.
Also do some refactoring to make thinking back to old 808x instructions easier for debugging purposes.
This commit is contained in:
3287
src/cpu/808x.c
3287
src/cpu/808x.c
File diff suppressed because it is too large
Load Diff
133
src/cpu/vx0.c
133
src/cpu/vx0.c
@@ -224,20 +224,6 @@ const uint8_t opf_0f[256] = { 0, 0, 0, 0, 0, 0,
|
||||
|
||||
int nx = 0;
|
||||
|
||||
static uint32_t cpu_src = 0;
|
||||
static uint32_t cpu_dest = 0;
|
||||
|
||||
static uint32_t cpu_data = 0;
|
||||
|
||||
static int oldc;
|
||||
static int cpu_alu_op;
|
||||
static int completed = 1;
|
||||
static int in_rep = 0;
|
||||
static int repeating = 0;
|
||||
static int rep_c_flag = 0;
|
||||
static int clear_lock = 0;
|
||||
static int noint = 0;
|
||||
static int tempc_fpu = 0;
|
||||
static int started = 0;
|
||||
static int group_delay = 0;
|
||||
static int modrm_loaded = 0;
|
||||
@@ -246,8 +232,6 @@ static int in_hlt = 0;
|
||||
static int retem = 0;
|
||||
static int halted = 0;
|
||||
|
||||
static uint32_t * ovr_seg = NULL;
|
||||
|
||||
/* Pointer tables needed for segment overrides. */
|
||||
static uint32_t * opseg[4];
|
||||
|
||||
@@ -489,6 +473,8 @@ void i8080_port_out(UNUSED(void* priv), uint8_t port, uint8_t val)
|
||||
void
|
||||
reset_vx0(int hard)
|
||||
{
|
||||
reset_808x(hard);
|
||||
|
||||
halted = 0;
|
||||
in_hlt = 0;
|
||||
in_0f = 0;
|
||||
@@ -1854,9 +1840,53 @@ do_mod_rm(void)
|
||||
}
|
||||
|
||||
static void
|
||||
decode(void)
|
||||
decode_modrm(void)
|
||||
{
|
||||
uint8_t op_f;
|
||||
|
||||
modrm_loaded = 0;
|
||||
|
||||
if (is_nec) {
|
||||
if (in_0f)
|
||||
op_f = (uint8_t) opf_0f[opcode];
|
||||
else
|
||||
op_f = (uint8_t) opf_nec[opcode];
|
||||
} else
|
||||
op_f = (uint8_t) opf[opcode];
|
||||
|
||||
if (op_f & OP_GRP) {
|
||||
do_mod_rm();
|
||||
modrm_loaded = 1;
|
||||
|
||||
op_f |= (OP_MRM | OP_EA);
|
||||
|
||||
if (opcode >= 0xf0) {
|
||||
op_f |= OP_DELAY;
|
||||
group_delay = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!modrm_loaded && (op_f & OP_MRM)) {
|
||||
do_mod_rm();
|
||||
modrm_loaded = 1;
|
||||
}
|
||||
|
||||
if (modrm_loaded && !(op_f & OP_EA)) {
|
||||
if (is_nec)
|
||||
do_cycle();
|
||||
else {
|
||||
if (opcode == 0x8f) {
|
||||
if (cpu_mod == 3)
|
||||
do_cycles_i(2);
|
||||
} else
|
||||
do_cycles_i(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
decode(void)
|
||||
{
|
||||
uint8_t prefix = 0;
|
||||
|
||||
if (halted)
|
||||
@@ -1864,8 +1894,6 @@ decode(void)
|
||||
else
|
||||
opcode = biu_pfq_fetchb_common();
|
||||
|
||||
modrm_loaded = 0;
|
||||
|
||||
while (1) {
|
||||
prefix = 0;
|
||||
|
||||
@@ -1913,43 +1941,6 @@ decode(void)
|
||||
|
||||
opcode = biu_pfq_fetchb_common();
|
||||
}
|
||||
|
||||
if (is_nec) {
|
||||
if (in_0f)
|
||||
op_f = (uint8_t) opf_0f[opcode];
|
||||
else
|
||||
op_f = (uint8_t) opf_nec[opcode];
|
||||
} else
|
||||
op_f = (uint8_t) opf[opcode];
|
||||
|
||||
if (op_f & OP_GRP) {
|
||||
do_mod_rm();
|
||||
modrm_loaded = 1;
|
||||
|
||||
op_f |= (OP_MRM | OP_EA);
|
||||
|
||||
if (opcode >= 0xf0) {
|
||||
op_f |= OP_DELAY;
|
||||
group_delay = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!modrm_loaded && (op_f & OP_MRM)) {
|
||||
do_mod_rm();
|
||||
modrm_loaded = 1;
|
||||
}
|
||||
|
||||
if (modrm_loaded && !(op_f & OP_EA)) {
|
||||
if (is_nec)
|
||||
do_cycle();
|
||||
else {
|
||||
if (opcode == 0x8f) {
|
||||
if (cpu_mod == 3)
|
||||
do_cycles_i(2);
|
||||
} else
|
||||
do_cycles_i(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1992,6 +1983,10 @@ string_op(int bits)
|
||||
lods_di(bits);
|
||||
tmpa = cpu_data;
|
||||
lods(bits);
|
||||
/* Swap them or else the operation goes wrong. */
|
||||
uint32_t tmpa2 = tmpa;
|
||||
tmpa = cpu_data;
|
||||
cpu_data = tmpa2;
|
||||
} else {
|
||||
lods(bits);
|
||||
tmpa = cpu_data;
|
||||
@@ -4735,7 +4730,16 @@ execvx0(int cycs)
|
||||
startx86();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_INSTRUCTIONS
|
||||
if (repeating) {
|
||||
if ((opcode >= 0xa0) && (opcode <= 0xaf) && (opcode != 0x8e)) {
|
||||
execx86_instruction();
|
||||
goto check_completed;
|
||||
}
|
||||
} else {
|
||||
#else
|
||||
if (!repeating) {
|
||||
#endif
|
||||
cpu_state.oldpc = cpu_state.pc;
|
||||
|
||||
if (clear_lock) {
|
||||
@@ -4743,9 +4747,21 @@ execvx0(int cycs)
|
||||
clear_lock = 0;
|
||||
}
|
||||
|
||||
if (!is_nec || (cpu_state.flags & MD_FLAG))
|
||||
if (!is_nec || (cpu_state.flags & MD_FLAG)) {
|
||||
decode();
|
||||
|
||||
#ifdef DEBUG_INSTRUCTIONS
|
||||
if ((opcode >= 0xa0) && (opcode <= 0xaf) && (opcode != 0x8e)) {
|
||||
oldc = cpu_state.flags & C_FLAG;
|
||||
|
||||
execx86_instruction();
|
||||
goto check_completed;
|
||||
}
|
||||
#endif
|
||||
|
||||
decode_modrm();
|
||||
}
|
||||
|
||||
oldc = cpu_state.flags & C_FLAG;
|
||||
}
|
||||
|
||||
@@ -4753,6 +4769,9 @@ execvx0(int cycs)
|
||||
|
||||
execute_instruction();
|
||||
|
||||
#ifdef DEBUG_INSTRUCTIONS
|
||||
check_completed:
|
||||
#endif
|
||||
if (completed) {
|
||||
if (opcode != 0xf4)
|
||||
finalize();
|
||||
|
||||
@@ -76,7 +76,8 @@ enum {
|
||||
DMA_STATE_OPERATING
|
||||
};
|
||||
|
||||
/* Temporary BIU externs - move to 808x_biu.h. */
|
||||
extern void execx86_instruction(void);
|
||||
|
||||
extern void biu_resume_on_queue_read(void);
|
||||
extern void wait_vx0(int c);
|
||||
extern void biu_reset(void);
|
||||
@@ -106,6 +107,15 @@ extern void biu_wait_for_read_finish(void);
|
||||
extern uint8_t biu_preload_byte;
|
||||
|
||||
extern int nx;
|
||||
extern int oldc;
|
||||
extern int cpu_alu_op;
|
||||
extern int completed;
|
||||
extern int in_rep;
|
||||
extern int repeating;
|
||||
extern int rep_c_flag;
|
||||
extern int noint;
|
||||
extern int tempc_fpu;
|
||||
extern int clear_lock;
|
||||
|
||||
extern int schedule_fetch;
|
||||
extern int in_lock;
|
||||
@@ -113,4 +123,11 @@ extern int bus_request_type;
|
||||
extern int pic_data;
|
||||
extern int biu_queue_preload;
|
||||
|
||||
extern uint32_t cpu_src;
|
||||
extern uint32_t cpu_dest;
|
||||
|
||||
extern uint32_t cpu_data;
|
||||
|
||||
extern uint32_t *ovr_seg;
|
||||
|
||||
#endif /*EMU_808X_BIU_H*/
|
||||
|
||||
Reference in New Issue
Block a user