fix static variables used in m68k

This commit is contained in:
mio
2025-04-13 11:49:05 +08:00
parent aa86641e16
commit 334e83efd7
2 changed files with 10 additions and 9 deletions

View File

@@ -147,6 +147,9 @@ typedef struct CPUM68KState {
/* Fields from here on are preserved across CPU reset. */ /* Fields from here on are preserved across CPU reset. */
uint32_t features; uint32_t features;
// translate opcode
void* opcode_table[65536];
// Unicorn engine // Unicorn engine
struct uc_struct *uc; struct uc_struct *uc;
} CPUM68KState; } CPUM68KState;

View File

@@ -5996,10 +5996,8 @@ DISAS_INSN(to_mext)
gen_helper_set_mac_extu(tcg_ctx, tcg_ctx->cpu_env, val, acc); gen_helper_set_mac_extu(tcg_ctx, tcg_ctx->cpu_env, val, acc);
} }
static disas_proc opcode_table[65536];
static void static void
register_opcode (disas_proc proc, uint16_t opcode, uint16_t mask) register_opcode (CPUM68KState *env, disas_proc proc, uint16_t opcode, uint16_t mask)
{ {
int i; int i;
int from; int from;
@@ -6029,7 +6027,7 @@ register_opcode (disas_proc proc, uint16_t opcode, uint16_t mask)
to = from + i; to = from + i;
for (i = from; i < to; i++) { for (i = from; i < to; i++) {
if ((i & mask) == opcode) if ((i & mask) == opcode)
opcode_table[i] = proc; env->opcode_table[i] = proc;
} }
} }
@@ -6043,16 +6041,16 @@ void register_m68k_insns (CPUM68KState *env)
* Build the opcode table only once to avoid * Build the opcode table only once to avoid
* multithreading issues. * multithreading issues.
*/ */
if (opcode_table[0] != NULL) { // if (opcode_table[0] != NULL) {
return; // return;
} // }
/* /*
* use BASE() for instruction available * use BASE() for instruction available
* for CF_ISA_A and M68000. * for CF_ISA_A and M68000.
*/ */
#define BASE(name, opcode, mask) \ #define BASE(name, opcode, mask) \
register_opcode(disas_##name, 0x##opcode, 0x##mask) register_opcode(env, disas_##name, 0x##opcode, 0x##mask)
#define INSN(name, opcode, mask, feature) do { \ #define INSN(name, opcode, mask, feature) do { \
if (m68k_feature(env, M68K_FEATURE_##feature)) \ if (m68k_feature(env, M68K_FEATURE_##feature)) \
BASE(name, opcode, mask); \ BASE(name, opcode, mask); \
@@ -6344,7 +6342,7 @@ static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
insn = read_im16(env, dc); insn = read_im16(env, dc);
opcode_table[insn](env, dc, insn); ((disas_proc)env->opcode_table[insn])(env, dc, insn);
do_writebacks(dc); do_writebacks(dc);
do_release(dc); do_release(dc);