--- hatari/src/falcon/dsp_disasm.c 2019/04/01 07:14:53 1.1.1.2 +++ hatari/src/falcon/dsp_disasm.c 2019/04/09 08:48:45 1.1.1.4 @@ -46,6 +46,14 @@ /* Current instruction */ static Uint32 cur_inst; +static Uint32 disasm_cur_inst_len; +static char str_instr[50]; +static char str_instr2[100]; +static char parallelmove_name[64]; + +/* Previous instruction */ +static Uint32 prev_inst_pc = 0x10000; /* Init to an invalid value */ +static Uint16 isLooping = 0; static dsp_core_t *dsp_core; @@ -59,7 +67,6 @@ void dsp56k_disasm_init(dsp_core_t *my_d **********************************/ static Uint32 registers_save[64]; -static Uint32 registers_changed[64]; #if DSP_DISASM_REG_PC static Uint32 pc_save; #endif @@ -86,95 +93,6 @@ static const char *registers_name[64]={ "ssh","ssl","la","lc" }; -void dsp56k_disasm_reg_read(void) -{ - memcpy(registers_save, dsp_core->registers , sizeof(registers_save)); - memset(registers_changed, 0, sizeof(registers_changed)); -#if DSP_DISASM_REG_PC - pc_save = dsp_core->pc; -#endif -} - -void dsp56k_disasm_reg_compare(void) -{ - int i; - - for (i=0;i<64;i++) { - if (!registers_changed[i]) { - continue; - } - - switch(i) { - case DSP_REG_X0: - case DSP_REG_X1: - case DSP_REG_Y0: - case DSP_REG_Y1: - case DSP_REG_A0: - case DSP_REG_A1: - case DSP_REG_B0: - case DSP_REG_B1: - fprintf(stderr,"Dsp: Reg: %s: 0x%06x -> 0x%06x\n", registers_name[i], registers_save[i] & BITMASK(24), dsp_core->registers[i] & BITMASK(24)); - break; - case DSP_REG_R0: - case DSP_REG_R1: - case DSP_REG_R2: - case DSP_REG_R3: - case DSP_REG_R4: - case DSP_REG_R5: - case DSP_REG_R6: - case DSP_REG_R7: - case DSP_REG_M0: - case DSP_REG_M1: - case DSP_REG_M2: - case DSP_REG_M3: - case DSP_REG_M4: - case DSP_REG_M5: - case DSP_REG_M6: - case DSP_REG_M7: - case DSP_REG_N0: - case DSP_REG_N1: - case DSP_REG_N2: - case DSP_REG_N3: - case DSP_REG_N4: - case DSP_REG_N5: - case DSP_REG_N6: - case DSP_REG_N7: - case DSP_REG_SR: - case DSP_REG_LA: - case DSP_REG_LC: - fprintf(stderr,"Dsp: Reg: %s: 0x%04x -> 0x%04x\n", registers_name[i], registers_save[i] & BITMASK(16), dsp_core->registers[i] & BITMASK(16)); - break; - case DSP_REG_A2: - case DSP_REG_B2: - case DSP_REG_OMR: - case DSP_REG_SP: - case DSP_REG_SSH: - case DSP_REG_SSL: - fprintf(stderr,"Dsp: Reg: %s: 0x%02x -> 0x%02x\n", registers_name[i], registers_save[i] & BITMASK(8), dsp_core->registers[i] & BITMASK(8)); - break; - case DSP_REG_A: - case DSP_REG_B: - { - fprintf(stderr,"Dsp: Reg: %s: 0x%02x:%06x:%06x -> 0x%02x:%06x:%06x\n", - registers_name[i], - registers_save[DSP_REG_A2+(i & 1)] & BITMASK(8), - registers_save[DSP_REG_A1+(i & 1)] & BITMASK(24), - registers_save[DSP_REG_A0+(i & 1)] & BITMASK(24), - dsp_core->registers[DSP_REG_A2+(i & 1)] & BITMASK(8), - dsp_core->registers[DSP_REG_A1+(i & 1)] & BITMASK(24), - dsp_core->registers[DSP_REG_A0+(i & 1)] & BITMASK(24) - ); - } - break; - } - } -#if DSP_DISASM_REG_PC - if (pc_save != dsp_core->pc) { - fprintf(stderr,"Dsp: Reg: pc: 0x%04x -> 0x%04x\n", pc_save, dsp_core->pc); - } -#endif -} - /********************************** * Opcode disassembler **********************************/ @@ -184,12 +102,6 @@ static Uint32 read_memory(Uint32 currPc) typedef void (*dsp_emul_t)(void); static void opcode8h_0(void); -static void opcode8h_1(void); -static void opcode8h_4(void); -static void opcode8h_6(void); -static void opcode8h_8(void); -static void opcode8h_a(void); -static void opcode8h_b(void); static int dsp_calc_ea(Uint32 ea_mode, char *dest); static void dsp_calc_cc(Uint32 cc_mode, char *dest); @@ -197,30 +109,55 @@ static void dsp_undefined(void); /* Instructions without parallel moves */ static void dsp_andi(void); -static void dsp_bchg(void); -static void dsp_bclr(void); -static void dsp_bset(void); -static void dsp_btst(void); +static void dsp_bchg_aa(void); +static void dsp_bchg_ea(void); +static void dsp_bchg_pp(void); +static void dsp_bchg_reg(void); +static void dsp_bclr_aa(void); +static void dsp_bclr_ea(void); +static void dsp_bclr_pp(void); +static void dsp_bclr_reg(void); +static void dsp_bset_aa(void); +static void dsp_bset_ea(void); +static void dsp_bset_pp(void); +static void dsp_bset_reg(void); +static void dsp_btst_aa(void); +static void dsp_btst_ea(void); +static void dsp_btst_pp(void); +static void dsp_btst_reg(void); static void dsp_div(void); -static void dsp_do(void); static void dsp_enddo(void); static void dsp_illegal(void); -static void dsp_jcc(void); -static void dsp_jclr(void); -static void dsp_jmp(void); -static void dsp_jscc(void); -static void dsp_jsclr(void); -static void dsp_jset(void); -static void dsp_jsr(void); -static void dsp_jsset(void); +static void dsp_jcc_imm(void); +static void dsp_jcc_ea(void); +static void dsp_jclr_aa(void); +static void dsp_jclr_ea(void); +static void dsp_jclr_pp(void); +static void dsp_jclr_reg(void); +static void dsp_jmp_ea(void); +static void dsp_jmp_imm(void); +static void dsp_jscc_ea(void); +static void dsp_jscc_imm(void); +static void dsp_jsclr_aa(void); +static void dsp_jsclr_ea(void); +static void dsp_jsclr_pp(void); +static void dsp_jsclr_reg(void); +static void dsp_jset_aa(void); +static void dsp_jset_ea(void); +static void dsp_jset_pp(void); +static void dsp_jset_reg(void); +static void dsp_jsr_ea(void); +static void dsp_jsr_imm(void); +static void dsp_jsset_aa(void); +static void dsp_jsset_ea(void); +static void dsp_jsset_pp(void); +static void dsp_jsset_reg(void); static void dsp_lua(void); -static void dsp_movec(void); -static void dsp_movem(void); -static void dsp_movep(void); +static void dsp_movem_ea(void); +static void dsp_movem_aa(void); static void dsp_nop(void); static void dsp_norm(void); static void dsp_ori(void); -static void dsp_rep(void); static void dsp_reset(void); static void dsp_rti(void); static void dsp_rts(void); @@ -228,24 +165,24 @@ static void dsp_stop(void); static void dsp_swi(void); static void dsp_tcc(void); static void dsp_wait(void); - -static void dsp_do_0(void); -static void dsp_do_2(void); -static void dsp_do_4(void); -static void dsp_do_c(void); -static void dsp_movec_7(void); -static void dsp_movec_9(void); -static void dsp_movec_b(void); -static void dsp_movec_d(void); +static void dsp_do_ea(void); +static void dsp_do_aa(void); +static void dsp_do_imm(void); +static void dsp_do_reg(void); +static void dsp_rep_aa(void); +static void dsp_rep_ea(void); +static void dsp_rep_imm(void); +static void dsp_rep_reg(void); +static void dsp_movec_aa(void); +static void dsp_movec_ea(void); +static void dsp_movec_imm(void); +static void dsp_movec_reg(void); static void dsp_movep_0(void); static void dsp_movep_1(void); -static void dsp_movep_2(void); -static void dsp_rep_1(void); -static void dsp_rep_3(void); -static void dsp_rep_5(void); -static void dsp_rep_d(void); +static void dsp_movep_23(void); /* Parallel moves */ +static void dsp_pm_class2(void); static void dsp_pm(void); static void dsp_pm_0(void); static void dsp_pm_1(void); @@ -271,7 +208,6 @@ static void dsp_lsr(void); static void dsp_mac(void); static void dsp_macr(void); static void dsp_move(void); -static void dsp_move_nopm(void); static void dsp_mpy(void); static void dsp_mpyr(void); static void dsp_neg(void); @@ -287,295 +223,130 @@ static void dsp_subr(void); static void dsp_tfr(void); static void dsp_tst(void); -static dsp_emul_t opcodes8h[16]={ - opcode8h_0, - opcode8h_1, - dsp_tcc, - dsp_tcc, - opcode8h_4, - dsp_movec, - opcode8h_6, - dsp_movem, - opcode8h_8, - opcode8h_8, - opcode8h_a, - opcode8h_b, - dsp_jmp, - dsp_jsr, - dsp_jcc, - dsp_jscc +static dsp_emul_t opcodes8h[512]={ + /* 0x00 - 0x3f */ + opcode8h_0, dsp_undefined, dsp_undefined, dsp_undefined, opcode8h_0, dsp_andi, dsp_undefined, dsp_ori, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_andi, dsp_undefined, dsp_ori, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_andi, dsp_undefined, dsp_ori, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_andi, dsp_undefined, dsp_ori, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_div, dsp_div, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_norm, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + + /* 0x40 - 0x7f */ + dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + + /* 0x80 - 0xbf */ + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_lua, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_movec_reg, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_movec_reg, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_movec_aa, dsp_undefined, dsp_movec_aa, dsp_undefined, dsp_movec_imm, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_movec_ea, dsp_undefined, dsp_movec_ea, dsp_undefined, dsp_movec_imm, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_movec_aa, dsp_undefined, dsp_movec_aa, dsp_undefined, dsp_movec_imm, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_movec_ea, dsp_undefined, dsp_movec_ea, dsp_undefined, dsp_movec_imm, dsp_undefined, dsp_undefined, + + /* 0xc0 - 0xff */ + dsp_do_aa, dsp_rep_aa, dsp_do_aa, dsp_rep_aa, dsp_do_imm, dsp_rep_imm, dsp_undefined, dsp_undefined, + dsp_do_ea, dsp_rep_ea, dsp_do_ea, dsp_rep_ea, dsp_do_imm, dsp_rep_imm, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_do_imm, dsp_rep_imm, dsp_undefined, dsp_undefined, + dsp_do_reg, dsp_rep_reg, dsp_undefined, dsp_undefined, dsp_do_imm, dsp_rep_imm, dsp_undefined, dsp_undefined, + dsp_movem_aa, dsp_movem_aa, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_movem_ea, dsp_movem_ea, dsp_undefined, dsp_undefined, + dsp_movem_aa, dsp_movem_aa, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_movem_ea, dsp_movem_ea, dsp_undefined, dsp_undefined, + + /* 0x100 - 0x13f */ + dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, + dsp_movep_0, dsp_movep_0, dsp_movep_1, dsp_movep_1, dsp_movep_23, dsp_movep_23, dsp_movep_23, dsp_movep_23, + dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, + dsp_movep_0, dsp_movep_0, dsp_movep_1, dsp_movep_1, dsp_movep_23, dsp_movep_23, dsp_movep_23, dsp_movep_23, + dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, + dsp_movep_0, dsp_movep_0, dsp_movep_1, dsp_movep_1, dsp_movep_23, dsp_movep_23, dsp_movep_23, dsp_movep_23, + dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, + dsp_movep_0, dsp_movep_0, dsp_movep_1, dsp_movep_1, dsp_movep_23, dsp_movep_23, dsp_movep_23, dsp_movep_23, + + /* 0x140 - 0x17f */ + dsp_bclr_aa, dsp_bset_aa, dsp_bclr_aa, dsp_bset_aa, dsp_jclr_aa, dsp_jset_aa, dsp_jclr_aa, dsp_jset_aa, + dsp_bclr_ea, dsp_bset_ea, dsp_bclr_ea, dsp_bset_ea, dsp_jclr_ea, dsp_jset_ea, dsp_jclr_ea, dsp_jset_ea, + dsp_bclr_pp, dsp_bset_pp, dsp_bclr_pp, dsp_bset_pp, dsp_jclr_pp, dsp_jset_pp, dsp_jclr_pp, dsp_jset_pp, + dsp_jclr_reg, dsp_jset_reg, dsp_bclr_reg, dsp_bset_reg, dsp_jmp_ea, dsp_jcc_ea, dsp_undefined, dsp_undefined, + dsp_bchg_aa, dsp_btst_aa, dsp_bchg_aa, dsp_btst_aa, dsp_jsclr_aa, dsp_jsset_aa, dsp_jsclr_aa, dsp_jsset_aa, + dsp_bchg_ea, dsp_btst_ea, dsp_bchg_ea, dsp_btst_ea, dsp_jsclr_ea, dsp_jsset_ea, dsp_jsclr_ea, dsp_jsset_ea, + dsp_bchg_pp, dsp_btst_pp, dsp_bchg_pp, dsp_btst_pp, dsp_jsclr_pp, dsp_jsset_pp, dsp_jsclr_pp, dsp_jsset_pp, + dsp_jsclr_reg, dsp_jsset_reg, dsp_bchg_reg, dsp_btst_reg, dsp_jsr_ea, dsp_jscc_ea, dsp_undefined, dsp_undefined, + + /* 0x180 - 0x1bf */ + dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, + + /* 0x1c0 - 0x1ff */ + dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, + dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, + dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, + dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, + dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, + dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, + dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, + dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, }; -static dsp_emul_t opcodes_0809[16]={ - dsp_move_nopm, - dsp_move_nopm, - dsp_move_nopm, - dsp_move_nopm, - - dsp_movep, - dsp_movep, - dsp_movep, - dsp_movep, - - dsp_move_nopm, - dsp_move_nopm, - dsp_move_nopm, - dsp_move_nopm, - - dsp_movep, - dsp_movep, - dsp_movep, - dsp_movep +static dsp_emul_t opcodes_alu[256]={ + /* 0x00 - 0x3f */ + dsp_move, dsp_tfr, dsp_addr, dsp_tst, dsp_undefined, dsp_cmp, dsp_subr, dsp_cmpm, + dsp_undefined, dsp_tfr, dsp_addr, dsp_tst, dsp_undefined, dsp_cmp, dsp_subr, dsp_cmpm, + dsp_add, dsp_rnd, dsp_addl, dsp_clr, dsp_sub, dsp_undefined, dsp_subl, dsp_not, + dsp_add, dsp_rnd, dsp_addl, dsp_clr, dsp_sub, dsp_undefined, dsp_subl, dsp_not, + dsp_add, dsp_adc, dsp_asr, dsp_lsr, dsp_sub, dsp_sbc, dsp_abs, dsp_ror, + dsp_add, dsp_adc, dsp_asr, dsp_lsr, dsp_sub, dsp_sbc, dsp_abs, dsp_ror, + dsp_add, dsp_adc, dsp_asl, dsp_lsl, dsp_sub, dsp_sbc, dsp_neg, dsp_rol, + dsp_add, dsp_adc, dsp_asl, dsp_lsl, dsp_sub, dsp_sbc, dsp_neg, dsp_rol, + + /* 0x40 - 0x7f */ + dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm, + dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm, + dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm, + dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm, + dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm, + dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm, + dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm, + dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm, + + /* 0x80 - 0xbf */ + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + + /* 0xc0 - 0xff */ + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, + dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr }; -static dsp_emul_t opcodes_0a[32]={ - dsp_bclr, - dsp_bset, - dsp_bclr, - dsp_bset, - dsp_jclr, - dsp_jset, - dsp_jclr, - dsp_jset, - - dsp_bclr, - dsp_bset, - dsp_bclr, - dsp_bset, - dsp_jclr, - dsp_jset, - dsp_jclr, - dsp_jset, - - dsp_bclr, - dsp_bset, - dsp_bclr, - dsp_bset, - dsp_jclr, - dsp_jset, - dsp_jclr, - dsp_jset, - - dsp_jclr, - dsp_jset, - dsp_bclr, - dsp_bset, - dsp_jmp, - dsp_jcc, - dsp_undefined, - dsp_undefined -}; - -static dsp_emul_t opcodes_0b[32]={ - dsp_bchg, - dsp_btst, - dsp_bchg, - dsp_btst, - dsp_jsclr, - dsp_jsset, - dsp_jsclr, - dsp_jsset, - - dsp_bchg, - dsp_btst, - dsp_bchg, - dsp_btst, - dsp_jsclr, - dsp_jsset, - dsp_jsclr, - dsp_jsset, - - dsp_bchg, - dsp_btst, - dsp_bchg, - dsp_btst, - dsp_jsclr, - dsp_jsset, - dsp_jsclr, - dsp_jsset, - - dsp_jsclr, - dsp_jsclr, - dsp_bchg, - dsp_btst, - dsp_jsr, - dsp_jscc, - dsp_undefined, - dsp_undefined -}; - -static dsp_emul_t opcodes_alu003f[64]={ - /* 0x00 - 0x0f */ - dsp_move, - dsp_tfr, - dsp_addr, - dsp_tst, - dsp_undefined, - dsp_cmp, - dsp_subr, - dsp_cmpm, - dsp_undefined, - dsp_tfr, - dsp_addr, - dsp_tst, - dsp_undefined, - dsp_cmp, - dsp_subr, - dsp_cmpm, - - /* 0x10 - 0x1f */ - dsp_add, - dsp_rnd, - dsp_addl, - dsp_clr, - dsp_sub, - dsp_undefined, - dsp_subl, - dsp_not, - dsp_add, - dsp_rnd, - dsp_addl, - dsp_clr, - dsp_sub, - dsp_undefined, - dsp_subl, - dsp_not, - - /* 0x20 - 0x2f */ - dsp_add, - dsp_adc, - dsp_asr, - dsp_lsr, - dsp_sub, - dsp_sbc, - dsp_abs, - dsp_ror, - dsp_add, - dsp_adc, - dsp_asr, - dsp_lsr, - dsp_sub, - dsp_sbc, - dsp_abs, - dsp_ror, - - /* 0x30 - 0x3f */ - dsp_add, - dsp_adc, - dsp_asl, - dsp_lsl, - dsp_sub, - dsp_sbc, - dsp_neg, - dsp_rol, - dsp_add, - dsp_adc, - dsp_asl, - dsp_lsl, - dsp_sub, - dsp_sbc, - dsp_neg, - dsp_rol -}; - -static dsp_emul_t opcodes_alu407f[16]={ - dsp_add, - dsp_tfr, - dsp_or, - dsp_eor, - dsp_sub, - dsp_cmp, - dsp_and, - dsp_cmpm, - dsp_add, - dsp_tfr, - dsp_or, - dsp_eor, - dsp_sub, - dsp_cmp, - dsp_and, - dsp_cmpm -}; - -static dsp_emul_t opcodes_alu80ff[4]={ - dsp_mpy, - dsp_mpyr, - dsp_mac, - dsp_macr -}; - -static dsp_emul_t opcodes_do[16]={ - dsp_do_0, - dsp_undefined, - dsp_do_2, - dsp_undefined, - - dsp_do_4, - dsp_undefined, - dsp_do_2, - dsp_undefined, - - dsp_undefined, - dsp_undefined, - dsp_do_2, - dsp_undefined, - - dsp_do_c, - dsp_undefined, - dsp_do_2, - dsp_undefined -}; - -static dsp_emul_t opcodes_movec[16]={ - dsp_undefined, - dsp_undefined, - dsp_undefined, - dsp_undefined, - - dsp_undefined, - dsp_undefined, - dsp_undefined, - dsp_movec_7, - - dsp_undefined, - dsp_movec_9, - dsp_undefined, - dsp_movec_b, - - dsp_undefined, - dsp_movec_d, - dsp_undefined, - dsp_movec_b -}; - -static dsp_emul_t opcodes_movep[4]={ - dsp_movep_0, - dsp_movep_1, - dsp_movep_2, - dsp_movep_2 -}; - -static dsp_emul_t opcodes_rep[16]={ - dsp_undefined, - dsp_rep_1, - dsp_undefined, - dsp_rep_3, - - dsp_undefined, - dsp_rep_5, - dsp_undefined, - dsp_rep_3, - - dsp_undefined, - dsp_undefined, - dsp_undefined, - dsp_rep_3, - - dsp_undefined, - dsp_rep_d, - dsp_undefined, - dsp_rep_3 -}; static dsp_emul_t opcodes_parmove[16]={ dsp_pm_0, @@ -662,38 +433,148 @@ static const char *cc_name[16]={ "le" }; -static char parallelmove_name[64]; +void dsp56k_disasm_reg_save(void) +{ + memcpy(registers_save, dsp_core->registers , sizeof(registers_save)); +#if DSP_DISASM_REG_PC + pc_save = dsp_core->pc; +#endif +} + +void dsp56k_disasm_reg_compare(void) +{ + int i; + + for (i=0; i<64; i++) { + if (registers_save[i] == dsp_core->registers[i]) { + continue; + } + + switch(i) { + case DSP_REG_X0: + case DSP_REG_X1: + case DSP_REG_Y0: + case DSP_REG_Y1: + case DSP_REG_A0: + case DSP_REG_A1: + case DSP_REG_B0: + case DSP_REG_B1: + fprintf(stderr,"\tReg: %s 0x%06x -> 0x%06x\n", registers_name[i], registers_save[i] & BITMASK(24), dsp_core->registers[i] & BITMASK(24)); + break; + case DSP_REG_R0: + case DSP_REG_R1: + case DSP_REG_R2: + case DSP_REG_R3: + case DSP_REG_R4: + case DSP_REG_R5: + case DSP_REG_R6: + case DSP_REG_R7: + case DSP_REG_M0: + case DSP_REG_M1: + case DSP_REG_M2: + case DSP_REG_M3: + case DSP_REG_M4: + case DSP_REG_M5: + case DSP_REG_M6: + case DSP_REG_M7: + case DSP_REG_N0: + case DSP_REG_N1: + case DSP_REG_N2: + case DSP_REG_N3: + case DSP_REG_N4: + case DSP_REG_N5: + case DSP_REG_N6: + case DSP_REG_N7: + case DSP_REG_SR: + case DSP_REG_LA: + case DSP_REG_LC: + fprintf(stderr,"\tReg: %s 0x%04x -> 0x%04x\n", registers_name[i], registers_save[i] & BITMASK(16), dsp_core->registers[i] & BITMASK(16)); + break; + case DSP_REG_A2: + case DSP_REG_B2: + case DSP_REG_OMR: + case DSP_REG_SP: + case DSP_REG_SSH: + case DSP_REG_SSL: + fprintf(stderr,"\tReg: %s 0x%02x -> 0x%02x\n", registers_name[i], registers_save[i] & BITMASK(8), dsp_core->registers[i] & BITMASK(8)); + break; + case DSP_REG_A: + case DSP_REG_B: + { + fprintf(stderr,"\tReg: %s 0x%02x:%06x:%06x -> 0x%02x:%06x:%06x\n", + registers_name[i], + registers_save[DSP_REG_A2+(i & 1)] & BITMASK(8), + registers_save[DSP_REG_A1+(i & 1)] & BITMASK(24), + registers_save[DSP_REG_A0+(i & 1)] & BITMASK(24), + dsp_core->registers[DSP_REG_A2+(i & 1)] & BITMASK(8), + dsp_core->registers[DSP_REG_A1+(i & 1)] & BITMASK(24), + dsp_core->registers[DSP_REG_A0+(i & 1)] & BITMASK(24) + ); + } + break; + } + } -void dsp56k_disasm(void) +#if DSP_DISASM_REG_PC + if (pc_save != dsp_core->pc) { + fprintf(stderr,"\tReg: pc 0x%04x -> 0x%04x\n", pc_save, dsp_core->pc); + } +#endif +} + +Uint16 dsp56k_disasm(void) { Uint32 value; + if (prev_inst_pc == dsp_core->pc){ + isLooping = 1; + return 0; + } + prev_inst_pc = dsp_core->pc; + isLooping = 0; + cur_inst = read_memory(dsp_core->pc); + disasm_cur_inst_len = 1; strcpy(parallelmove_name, ""); - value = (cur_inst >> 16) & BITMASK(8); - if (value< 0x10) { + if (cur_inst < 0x100000) { + value = (cur_inst >> 11) & (BITMASK(6) << 3); + value += (cur_inst >> 5) & BITMASK(3); opcodes8h[value](); } else { dsp_pm(); value = cur_inst & BITMASK(8); - if (value < 0x40) { - opcodes_alu003f[value](); - } else if (value < 0x80) { - value &= BITMASK(4); - opcodes_alu407f[value](); - } else { - value &= BITMASK(2); - opcodes_alu80ff[value](); - } + opcodes_alu[value](); } + return disasm_cur_inst_len; } -void dsp56k_disasm_force_reg_changed(int num_dsp_reg) +/** + * dsp56k_getInstrText : return the disasembled instructions + */ +char* dsp56k_getInstructionText(void) { - registers_changed[num_dsp_reg]=1; -} + if (isLooping) { + *str_instr2 = 0; + } + else if (disasm_cur_inst_len == 1) { + sprintf(str_instr2, "%04x: %06x (%02d cyc) %s\n", prev_inst_pc, cur_inst, dsp_core->instr_cycle, str_instr); + } + else { + sprintf(str_instr2, "%04x: %06x %06x (%02d cyc) %s\n", prev_inst_pc, cur_inst, read_memory(prev_inst_pc + 1), dsp_core->instr_cycle, str_instr); + } + + return str_instr2; +} + +static void dsp_pm_class2(void) { + Uint32 value; + + dsp_pm(); + value = cur_inst & BITMASK(8); + opcodes_alu[value](); +} static Uint32 read_memory(Uint32 currPc) { @@ -702,7 +583,7 @@ static Uint32 read_memory(Uint32 currPc) if (currPc<0x200) { value = dsp_core->ramint[DSP_SPACE_P][currPc]; } else { - value = dsp_core->ram[DSP_SPACE_P][currPc & (DSP_RAMSIZE-1)]; + value = dsp_core->ramext[currPc & (DSP_RAMSIZE-1)]; } return value & BITMASK(24); @@ -732,12 +613,10 @@ static int dsp_calc_ea(Uint32 ea_mode, c case 0: /* (Rx)-Nx */ sprintf(dest, ea_names[value], numreg, numreg); - registers_changed[DSP_REG_R0+numreg]=1; break; case 1: /* (Rx)+Nx */ sprintf(dest, ea_names[value], numreg, numreg); - registers_changed[DSP_REG_R0+numreg]=1; break; case 5: /* (Rx+Nx) */ @@ -746,12 +625,10 @@ static int dsp_calc_ea(Uint32 ea_mode, c case 2: /* (Rx)- */ sprintf(dest, ea_names[value], numreg); - registers_changed[DSP_REG_R0+numreg]=1; break; case 3: /* (Rx)+ */ sprintf(dest, ea_names[value], numreg); - registers_changed[DSP_REG_R0+numreg]=1; break; case 4: /* (Rx) */ @@ -760,9 +637,9 @@ static int dsp_calc_ea(Uint32 ea_mode, c case 7: /* -(Rx) */ sprintf(dest, ea_names[value], numreg); - registers_changed[DSP_REG_R0+numreg]=1; break; case 6: + disasm_cur_inst_len++; switch ((ea_mode >> 2) & 1) { case 0: /* Absolute address */ @@ -781,204 +658,231 @@ static int dsp_calc_ea(Uint32 ea_mode, c static void opcode8h_0(void) { - Uint32 value; - - if (cur_inst <= 0x00008c) { - switch(cur_inst) { - case 0x000000: - dsp_nop(); - break; - case 0x000004: - dsp_rti(); - break; - case 0x000005: - dsp_illegal(); - break; - case 0x000006: - dsp_swi(); - break; - case 0x00000c: - dsp_rts(); - break; - case 0x000084: - dsp_reset(); - break; - case 0x000086: - dsp_wait(); - break; - case 0x000087: - dsp_stop(); - break; - case 0x00008c: - dsp_enddo(); - break; - } - } else { - value = cur_inst & 0xf8; - switch (value) { - case 0x0000b8: - dsp_andi(); - break; - case 0x0000f8: - dsp_ori(); - break; - } + switch(cur_inst) { + case 0x000000: + dsp_nop(); + break; + case 0x000004: + dsp_rti(); + break; + case 0x000005: + dsp_illegal(); + break; + case 0x000006: + dsp_swi(); + break; + case 0x00000c: + dsp_rts(); + break; + case 0x000084: + dsp_reset(); + break; + case 0x000086: + dsp_wait(); + break; + case 0x000087: + dsp_stop(); + break; + case 0x00008c: + dsp_enddo(); + break; } } -static void opcode8h_1(void) +/********************************** + * Non-parallel moves instructions + **********************************/ + +static void dsp_undefined(void) { - switch(cur_inst & 0xfff8c7) { - case 0x018040: - dsp_div(); - break; - case 0x01c805: - dsp_norm(); - break; - } + sprintf(str_instr,"0x%06x unknown instruction", cur_inst); } -static void opcode8h_4(void) +static void dsp_andi(void) { - switch((cur_inst>>5) & BITMASK(3)) { + switch(cur_inst & BITMASK(2)) { case 0: - dsp_lua(); + sprintf(str_instr, "andi #0x%02x,mr", (cur_inst>>8) & BITMASK(8)); break; - case 5: - dsp_movec(); + case 1: + sprintf(str_instr, "andi #0x%02x,ccr", (cur_inst>>8) & BITMASK(8)); + break; + case 2: + sprintf(str_instr, "andi #0x%02x,omr", (cur_inst>>8) & BITMASK(8)); + break; + default: break; } } -static void opcode8h_6(void) +static void dsp_bchg_aa(void) { - if (cur_inst & (1<<5)) { - dsp_rep(); + /* bchg #n,x:aa */ + /* bchg #n,y:aa */ + char name[16]; + Uint32 memspace, value, numbit; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + if (memspace) { + sprintf(name,"y:0x%04x",value); } else { - dsp_do(); + sprintf(name,"x:0x%04x",value); } + + sprintf(str_instr,"bchg #%d,%s", numbit, name); } -static void opcode8h_8(void) +static void dsp_bchg_ea(void) { - Uint32 value; + /* bchg #n,x:ea */ + /* bchg #n,y:ea */ + char name[16], addr_name[16]; + Uint32 memspace, value, numbit; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(name,"y:%s",addr_name); + } else { + sprintf(name,"x:%s",addr_name); + } - value = (cur_inst >> 12) & BITMASK(4); - opcodes_0809[value](); + sprintf(str_instr,"bchg #%d,%s", numbit, name); } -static void opcode8h_a(void) +static void dsp_bchg_pp(void) { - Uint32 value; + /* bchg #n,x:pp */ + /* bchg #n,y:pp */ + char name[16]; + Uint32 memspace, value, numbit; - value = (cur_inst >> 11) & (BITMASK(2)<<3); - value |= (cur_inst >> 5) & BITMASK(3); + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); - opcodes_0a[value](); + if (memspace) { + sprintf(name,"y:0x%04x",value+0xffc0); + } else { + sprintf(name,"x:0x%04x",value+0xffc0); + } + + sprintf(str_instr,"bchg #%d,%s", numbit, name); } -static void opcode8h_b(void) +static void dsp_bchg_reg(void) { - Uint32 value; + /* bchg #n,R */ + Uint32 value, numbit; - value = (cur_inst >> 11) & (BITMASK(2)<<3); - value |= (cur_inst >> 5) & BITMASK(3); + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); - opcodes_0b[value](); + sprintf(str_instr,"bchg #%d,%s", numbit, registers_name[value]); } -/********************************** - * Non-parallel moves instructions - **********************************/ +static void dsp_bclr_aa(void) +{ + /* bclr #n,x:aa */ + /* bclr #n,y:aa */ + char name[16]; + Uint32 memspace, value, numbit; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); -static void dsp_undefined(void) + if (memspace) { + sprintf(name,"y:0x%04x",value); + } else { + sprintf(name,"x:0x%04x",value); + } + + sprintf(str_instr,"bclr #%d,%s", numbit, name); +} + +static void dsp_bclr_ea(void) { - fprintf(stderr,"Dsp: 0x%04x: 0x%06x unknown instruction\n",dsp_core->pc, cur_inst); + /* bclr #n,x:ea */ + /* bclr #n,y:ea */ + char name[16], addr_name[16]; + Uint32 memspace, value, numbit; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(name,"y:%s",addr_name); + } else { + sprintf(name,"x:%s",addr_name); + } + + sprintf(str_instr,"bclr #%d,%s", numbit, name); } -static void dsp_andi(void) +static void dsp_bclr_pp(void) { - const char *regname; + /* bclr #n,x:pp */ + /* bclr #n,y:pp */ + char name[16]; + Uint32 memspace, value, numbit; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); - switch(cur_inst & BITMASK(2)) { - case 0: - regname="mr"; - registers_changed[DSP_REG_SR]=1; - break; - case 1: - regname="ccr"; - registers_changed[DSP_REG_SR]=1; - break; - case 2: - regname="omr"; - registers_changed[DSP_REG_OMR]=1; - break; - default: - regname=""; - break; + if (memspace) { + sprintf(name,"y:0x%04x",value+0xffc0); + } else { + sprintf(name,"x:0x%04x",value+0xffc0); } - registers_changed[DSP_REG_SR]=1; + sprintf(str_instr,"bclr #%d,%s", numbit, name); +} - fprintf(stderr,"Dsp: 0x%04x: andi #0x%02x,%s\n", - dsp_core->pc, - (cur_inst>>8) & BITMASK(8), - regname - ); +static void dsp_bclr_reg(void) +{ + /* bclr #n,R */ + Uint32 value, numbit; + + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + sprintf(str_instr,"bclr #%d,%s", numbit, registers_name[value]); } -static void dsp_bchg(void) +static void dsp_bset_aa(void) { - char name[16], addr_name[16]; + /* bset #n,x:aa */ + /* bset #n,y:aa */ + char name[16]; Uint32 memspace, value, numbit; memspace = (cur_inst>>6) & 1; value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - switch((cur_inst>>14) & BITMASK(2)) { - case 0: - /* bchg #n,x:aa */ - /* bchg #n,y:aa */ - if (memspace) { - sprintf(name,"y:0x%04x",value); - } else { - sprintf(name,"x:0x%04x",value); - } - break; - case 1: - /* bchg #n,x:ea */ - /* bchg #n,y:ea */ - dsp_calc_ea(value, addr_name); - if (memspace) { - sprintf(name,"y:%s",addr_name); - } else { - sprintf(name,"x:%s",addr_name); - } - break; - case 2: - /* bchg #n,x:pp */ - /* bchg #n,y:pp */ - if (memspace) { - sprintf(name,"y:0x%04x",value+0xffc0); - } else { - sprintf(name,"x:0x%04x",value+0xffc0); - } - break; - case 3: - /* bchg #n,R */ - sprintf(name,"%s",registers_name[value]); - registers_changed[value]=1; - break; + if (memspace) { + sprintf(name,"y:0x%04x",value); + } else { + sprintf(name,"x:0x%04x",value); } - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: bchg #%d,%s\n",dsp_core->pc, numbit, name); + sprintf(str_instr,"bset #%d,%s", numbit, name); } -static void dsp_bclr(void) +static void dsp_bset_ea(void) { + /* bset #n,x:ea */ + /* bset #n,y:ea */ char name[16], addr_name[16]; Uint32 memspace, value, numbit; @@ -986,99 +890,71 @@ static void dsp_bclr(void) value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - switch((cur_inst>>14) & BITMASK(2)) { - case 0: - /* bclr #n,x:aa */ - /* bclr #n,y:aa */ - if (memspace) { - sprintf(name,"y:0x%04x",value); - } else { - sprintf(name,"x:0x%04x",value); - } - break; - case 1: - /* bclr #n,x:ea */ - /* bclr #n,y:ea */ - dsp_calc_ea(value, addr_name); - if (memspace) { - sprintf(name,"y:%s",addr_name); - } else { - sprintf(name,"x:%s",addr_name); - } - break; - case 2: - /* bclr #n,x:pp */ - /* bclr #n,y:pp */ - if (memspace) { - sprintf(name,"y:0x%04x",value+0xffc0); - } else { - sprintf(name,"x:0x%04x",value+0xffc0); - } - break; - case 3: - /* bclr #n,R */ - sprintf(name,"%s",registers_name[value]); - registers_changed[value]=1; - break; + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(name,"y:%s",addr_name); + } else { + sprintf(name,"x:%s",addr_name); } - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: bclr #%d,%s\n",dsp_core->pc, numbit, name); + sprintf(str_instr,"bset #%d,%s", numbit, name); } -static void dsp_bset(void) +static void dsp_bset_pp(void) { - char name[16], addr_name[16]; + /* bset #n,x:pp */ + /* bset #n,y:pp */ + char name[16]; Uint32 memspace, value, numbit; memspace = (cur_inst>>6) & 1; value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - switch((cur_inst>>14) & BITMASK(2)) { - case 0: - /* bset #n,x:aa */ - /* bset #n,y:aa */ - if (memspace) { - sprintf(name,"y:0x%04x",value); - } else { - sprintf(name,"x:0x%04x",value); - } - break; - case 1: - /* bset #n,x:ea */ - /* bset #n,y:ea */ - dsp_calc_ea(value, addr_name); - if (memspace) { - sprintf(name,"y:%s",addr_name); - } else { - sprintf(name,"x:%s",addr_name); - } - break; - case 2: - /* bset #n,x:pp */ - /* bset #n,y:pp */ - if (memspace) { - sprintf(name,"y:0x%04x",value+0xffc0); - } else { - sprintf(name,"x:0x%04x",value+0xffc0); - } - break; - case 3: - /* bset #n,R */ - sprintf(name,"%s",registers_name[value]); - registers_changed[value]=1; - break; + if (memspace) { + sprintf(name,"y:0x%04x",value+0xffc0); + } else { + sprintf(name,"x:0x%04x",value+0xffc0); } - registers_changed[DSP_REG_SR]=1; + sprintf(str_instr,"bset #%d,%s", numbit, name); +} + +static void dsp_bset_reg(void) +{ + /* bset #n,R */ + Uint32 value, numbit; + + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + sprintf(str_instr,"bset #%d,%s", numbit, registers_name[value]); +} + +static void dsp_btst_aa(void) +{ + /* btst #n,x:aa */ + /* btst #n,y:aa */ + char name[16]; + Uint32 memspace, value, numbit; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + if (memspace) { + sprintf(name,"y:0x%04x",value); + } else { + sprintf(name,"x:0x%04x",value); + } - fprintf(stderr,"Dsp: 0x%04x: bset #%d,%s\n",dsp_core->pc, numbit, name); + sprintf(str_instr,"btst #%d,%s", numbit, name); } -static void dsp_btst(void) +static void dsp_btst_ea(void) { + /* btst #n,x:ea */ + /* btst #n,y:ea */ char name[16], addr_name[16]; Uint32 memspace, value, numbit; @@ -1086,45 +962,45 @@ static void dsp_btst(void) value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - switch((cur_inst>>14) & BITMASK(2)) { - case 0: - /* btst #n,x:aa */ - /* btst #n,y:aa */ - if (memspace) { - sprintf(name,"y:0x%04x",value); - } else { - sprintf(name,"x:0x%04x",value); - } - break; - case 1: - /* btst #n,x:ea */ - /* btst #n,y:ea */ - dsp_calc_ea(value, addr_name); - if (memspace) { - sprintf(name,"y:%s",addr_name); - } else { - sprintf(name,"x:%s",addr_name); - } - break; - case 2: - /* btst #n,x:pp */ - /* btst #n,y:pp */ - if (memspace) { - sprintf(name,"y:0x%04x",value+0xffc0); - } else { - sprintf(name,"x:0x%04x",value+0xffc0); - } - break; - case 3: - /* btst #n,R */ - sprintf(name,"%s",registers_name[value]); - registers_changed[value]=1; - break; + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(name,"y:%s",addr_name); + } else { + sprintf(name,"x:%s",addr_name); + } + + sprintf(str_instr,"btst #%d,%s", numbit, name); +} + +static void dsp_btst_pp(void) +{ + /* btst #n,x:pp */ + /* btst #n,y:pp */ + char name[16]; + Uint32 memspace, value, numbit; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + if (memspace) { + sprintf(name,"y:0x%04x",value+0xffc0); + } else { + sprintf(name,"x:0x%04x",value+0xffc0); } - registers_changed[DSP_REG_SR]=1; + sprintf(str_instr,"btst #%d,%s", numbit, name); +} - fprintf(stderr,"Dsp: 0x%04x: btst #%d,%s\n",dsp_core->pc, numbit, name); +static void dsp_btst_reg(void) +{ + /* btst #n,R */ + Uint32 value, numbit; + + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + sprintf(str_instr,"btst #%d,%s", numbit, registers_name[value]); } static void dsp_div(void) @@ -1146,58 +1022,45 @@ static void dsp_div(void) break; } destreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[destreg]=1; - registers_changed[DSP_REG_SR]=1; - fprintf(stderr,"Dsp: 0x%04x: div %s,%s\n",dsp_core->pc, registers_name[srcreg],registers_name[destreg]); + sprintf(str_instr,"div %s,%s", registers_name[srcreg],registers_name[destreg]); } -static void dsp_do(void) -{ - Uint32 value; - - value = (cur_inst>>12) & (BITMASK(2)<<2); - value |= (cur_inst>>6) & 1<<1; - value |= (cur_inst>>5) & 1; - - opcodes_do[value](); - - registers_changed[DSP_REG_LA]=1; - registers_changed[DSP_REG_LC]=1; - registers_changed[DSP_REG_SR]=1; -} - -static void dsp_do_0(void) +static void dsp_do_aa(void) { char name[16]; + disasm_cur_inst_len++; + if (cur_inst & (1<<6)) { sprintf(name, "y:0x%04x", (cur_inst>>8) & BITMASK(6)); } else { sprintf(name, "x:0x%04x", (cur_inst>>8) & BITMASK(6)); } - fprintf(stderr,"Dsp: 0x%04x: do %s,p:0x%04x\n", - dsp_core->pc, + sprintf(str_instr,"do %s,p:0x%04x", name, read_memory(dsp_core->pc+1) ); } -static void dsp_do_2(void) +static void dsp_do_imm(void) { - fprintf(stderr,"Dsp: 0x%04x: do #0x%04x,p:0x%04x\n", - dsp_core->pc, + disasm_cur_inst_len++; + + sprintf(str_instr,"do #0x%04x,p:0x%04x", ((cur_inst>>8) & BITMASK(8))|((cur_inst & BITMASK(4))<<8), read_memory(dsp_core->pc+1) ); } -static void dsp_do_4(void) +static void dsp_do_ea(void) { char addr_name[16], name[16]; Uint32 ea_mode; + disasm_cur_inst_len++; + ea_mode = (cur_inst>>8) & BITMASK(6); dsp_calc_ea(ea_mode, addr_name); @@ -1207,17 +1070,17 @@ static void dsp_do_4(void) sprintf(name, "x:%s", addr_name); } - fprintf(stderr,"Dsp: 0x%04x: do %s,p:0x%04x\n", - dsp_core->pc, + sprintf(str_instr,"do %s,p:0x%04x", name, read_memory(dsp_core->pc+1) ); } -static void dsp_do_c(void) +static void dsp_do_reg(void) { - fprintf(stderr,"Dsp: 0x%04x: do %s,p:0x%04x\n", - dsp_core->pc, + disasm_cur_inst_len++; + + sprintf(str_instr,"do %s,p:0x%04x", registers_name[(cur_inst>>8) & BITMASK(6)], read_memory(dsp_core->pc+1) ); @@ -1225,321 +1088,489 @@ static void dsp_do_c(void) static void dsp_enddo(void) { - fprintf(stderr,"Dsp: 0x%04x: enddo\n",dsp_core->pc); + sprintf(str_instr,"enddo"); } static void dsp_illegal(void) { - fprintf(stderr,"Dsp: 0x%04x: illegal\n",dsp_core->pc); + sprintf(str_instr,"illegal"); } -static void dsp_jcc(void) +static void dsp_jcc_ea(void) { char cond_name[16], addr_name[16]; Uint32 cc_code=0; - switch((cur_inst >> 16) & BITMASK(8)) { - case 0x0a: - dsp_calc_ea((cur_inst >>8) & BITMASK(6), addr_name); - cc_code=cur_inst & BITMASK(4); - break; - case 0x0e: - sprintf(addr_name, "0x%04x", cur_inst & BITMASK(12)); - cc_code=(cur_inst>>12) & BITMASK(4); - break; - } + dsp_calc_ea((cur_inst >>8) & BITMASK(6), addr_name); + cc_code=cur_inst & BITMASK(4); dsp_calc_cc(cc_code, cond_name); - fprintf(stderr,"Dsp: 0x%04x: j%s p:%s\n",dsp_core->pc, cond_name, addr_name); + sprintf(str_instr,"j%s p:%s", cond_name, addr_name); +} + +static void dsp_jcc_imm(void) +{ + char cond_name[16], addr_name[16]; + Uint32 cc_code=0; + + sprintf(addr_name, "0x%04x", cur_inst & BITMASK(12)); + cc_code=(cur_inst>>12) & BITMASK(4); + dsp_calc_cc(cc_code, cond_name); + + sprintf(str_instr,"j%s p:%s", cond_name, addr_name); +} + +static void dsp_jclr_aa(void) +{ + /* jclr #n,x:aa,p:xx */ + /* jclr #n,y:aa,p:xx */ + char srcname[16]; + Uint32 memspace, value, numbit; + + disasm_cur_inst_len++; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + if (memspace) { + sprintf(srcname, "y:0x%04x", value); + } else { + sprintf(srcname, "x:0x%04x", value); + } + + sprintf(str_instr,"jclr #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); } -static void dsp_jclr(void) +static void dsp_jclr_ea(void) { + /* jclr #n,x:ea,p:xx */ + /* jclr #n,y:ea,p:xx */ char srcname[16], addr_name[16]; Uint32 memspace, value, numbit; + disasm_cur_inst_len++; + memspace = (cur_inst>>6) & 1; value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - switch((cur_inst>>14) & BITMASK(2)) { - case 0: - /* jclr #n,x:aa,p:xx */ - /* jclr #n,y:aa,p:xx */ - if (memspace) { - sprintf(srcname, "y:0x%04x", value); - } else { - sprintf(srcname, "x:0x%04x", value); - } - break; - case 1: - /* jclr #n,x:ea,p:xx */ - /* jclr #n,y:ea,p:xx */ - dsp_calc_ea(value, addr_name); - if (memspace) { - sprintf(srcname, "y:%s", addr_name); - } else { - sprintf(srcname, "x:%s", addr_name); - } - break; - case 2: - /* jclr #n,x:pp,p:xx */ - /* jclr #n,y:pp,p:xx */ - value += 0xffc0; - if (memspace) { - sprintf(srcname, "y:0x%04x", value); - } else { - sprintf(srcname, "x:0x%04x", value); - } - break; - case 3: - /* jclr #n,R,p:xx */ - sprintf(srcname, registers_name[value]); - break; + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(srcname, "y:%s", addr_name); + } else { + sprintf(srcname, "x:%s", addr_name); } - fprintf(stderr,"Dsp: 0x%04x: jclr #%d,%s,p:0x%04x\n", - dsp_core->pc, + sprintf(str_instr,"jclr #%d,%s,p:0x%04x", numbit, srcname, read_memory(dsp_core->pc+1) ); } -static void dsp_jmp(void) +static void dsp_jclr_pp(void) { - char dstname[16]; + /* jclr #n,x:pp,p:xx */ + /* jclr #n,y:pp,p:xx */ + char srcname[16]; + Uint32 memspace, value, numbit; + + disasm_cur_inst_len++; - switch((cur_inst >> 16) & BITMASK(8)) { - case 0x0a: - dsp_calc_ea((cur_inst >>8) & BITMASK(6), dstname); - break; - case 0x0c: - sprintf(dstname, "0x%04x", cur_inst & BITMASK(12)); - break; + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + value += 0xffc0; + if (memspace) { + sprintf(srcname, "y:0x%04x", value); + } else { + sprintf(srcname, "x:0x%04x", value); } - fprintf(stderr,"Dsp: 0x%04x: jmp p:%s\n",dsp_core->pc, dstname); + sprintf(str_instr,"jclr #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); } -static void dsp_jscc(void) +static void dsp_jclr_reg(void) +{ + /* jclr #n,R,p:xx */ + Uint32 value, numbit; + + disasm_cur_inst_len++; + + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + sprintf(str_instr,"jclr #%d,%s,p:0x%04x", + numbit, + registers_name[value], + read_memory(dsp_core->pc+1) + ); +} + +static void dsp_jmp_imm(void) +{ + sprintf(str_instr,"jmp p:0x%04x", cur_inst & BITMASK(12)); +} + +static void dsp_jmp_ea(void) +{ + char dstname[16]; + + dsp_calc_ea((cur_inst >>8) & BITMASK(6), dstname); + + sprintf(str_instr,"jmp p:%s", dstname); +} + +static void dsp_jscc_ea(void) { char cond_name[16], addr_name[16]; Uint32 cc_code=0; - switch((cur_inst >> 16) & BITMASK(8)) { - case 0x0b: - dsp_calc_ea((cur_inst >>8) & BITMASK(6), addr_name); - cc_code=cur_inst & BITMASK(4); - break; - case 0x0f: - sprintf(addr_name, "0x%04x", cur_inst & BITMASK(12)); - cc_code=(cur_inst>>12) & BITMASK(4); - break; - } + dsp_calc_ea((cur_inst>>8) & BITMASK(6), addr_name); + cc_code=cur_inst & BITMASK(4); dsp_calc_cc(cc_code, cond_name); - fprintf(stderr,"Dsp: 0x%04x: js%s p:%s\n",dsp_core->pc, cond_name, addr_name); + sprintf(str_instr,"js%s p:%s", cond_name, addr_name); } -static void dsp_jsclr(void) +static void dsp_jscc_imm(void) { + char cond_name[16], addr_name[16]; + Uint32 cc_code=0; + + sprintf(addr_name, "0x%04x", cur_inst & BITMASK(12)); + cc_code=(cur_inst>>12) & BITMASK(4); + dsp_calc_cc(cc_code, cond_name); + + sprintf(str_instr,"js%s p:%s", cond_name, addr_name); +} + +static void dsp_jsclr_aa(void) +{ + /* jsclr #n,x:aa,p:xx */ + /* jsclr #n,y:aa,p:xx */ + char srcname[16]; + Uint32 memspace, value, numbit; + + disasm_cur_inst_len++; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + if (memspace) { + sprintf(srcname, "y:0x%04x", value); + } else { + sprintf(srcname, "x:0x%04x", value); + } + + sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); +} + +static void dsp_jsclr_ea(void) +{ + /* jsclr #n,x:ea,p:xx */ + /* jsclr #n,y:ea,p:xx */ char srcname[16], addr_name[16]; Uint32 memspace, value, numbit; + disasm_cur_inst_len++; + memspace = (cur_inst>>6) & 1; value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - switch((cur_inst>>14) & BITMASK(2)) { - case 0: - /* jsclr #n,x:aa,p:xx */ - /* jsclr #n,y:aa,p:xx */ - if (memspace) { - sprintf(srcname, "y:0x%04x", value); - } else { - sprintf(srcname, "x:0x%04x", value); - } - break; - case 1: - /* jsclr #n,x:ea,p:xx */ - /* jsclr #n,y:ea,p:xx */ - dsp_calc_ea(value, addr_name); - if (memspace) { - sprintf(srcname, "y:%s", addr_name); - } else { - sprintf(srcname, "x:%s", addr_name); - } - break; - case 2: - /* jsclr #n,x:pp,p:xx */ - /* jsclr #n,y:pp,p:xx */ - value += 0xffc0; - if (memspace) { - sprintf(srcname, "y:0x%04x", value); - } else { - sprintf(srcname, "x:0x%04x", value); - } - break; - case 3: - /* jsclr #n,R,p:xx */ - sprintf(srcname, registers_name[value]); - break; + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(srcname, "y:%s", addr_name); + } else { + sprintf(srcname, "x:%s", addr_name); + } + + sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); +} + +static void dsp_jsclr_pp(void) +{ + /* jsclr #n,x:pp,p:xx */ + /* jsclr #n,y:pp,p:xx */ + char srcname[16]; + Uint32 memspace, value, numbit; + + disasm_cur_inst_len++; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + value += 0xffc0; + if (memspace) { + sprintf(srcname, "y:0x%04x", value); + } else { + sprintf(srcname, "x:0x%04x", value); + } + + sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); +} + +static void dsp_jsclr_reg(void) +{ + /* jsclr #n,R,p:xx */ + Uint32 value, numbit; + + disasm_cur_inst_len++; + + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", + numbit, + registers_name[value], + read_memory(dsp_core->pc+1) + ); +} + +static void dsp_jset_aa(void) +{ + /* jset #n,x:aa,p:xx */ + /* jset #n,y:aa,p:xx */ + char srcname[16]; + Uint32 memspace, value, numbit; + + disasm_cur_inst_len++; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + if (memspace) { + sprintf(srcname, "y:0x%04x", value); + } else { + sprintf(srcname, "x:0x%04x", value); } - fprintf(stderr,"Dsp: 0x%04x: jsclr #%d,%s,p:0x%04x\n", - dsp_core->pc, + sprintf(str_instr,"jset #%d,%s,p:0x%04x", numbit, srcname, read_memory(dsp_core->pc+1) ); } -static void dsp_jset(void) +static void dsp_jset_ea(void) { + /* jset #n,x:ea,p:xx */ + /* jset #n,y:ea,p:xx */ char srcname[16], addr_name[16]; Uint32 memspace, value, numbit; + disasm_cur_inst_len++; + memspace = (cur_inst>>6) & 1; value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - switch((cur_inst>>14) & BITMASK(2)) { - case 0: - /* jset #n,x:aa,p:xx */ - /* jset #n,y:aa,p:xx */ - if (memspace) { - sprintf(srcname, "y:0x%04x", value); - } else { - sprintf(srcname, "x:0x%04x", value); - } - break; - case 1: - /* jset #n,x:ea,p:xx */ - /* jset #n,y:ea,p:xx */ - dsp_calc_ea(value, addr_name); - if (memspace) { - sprintf(srcname, "y:%s", addr_name); - } else { - sprintf(srcname, "x:%s", addr_name); - } - break; - case 2: - /* jset #n,x:pp,p:xx */ - /* jset #n,y:pp,p:xx */ - value += 0xffc0; - if (memspace) { - sprintf(srcname, "y:0x%04x", value); - } else { - sprintf(srcname, "x:0x%04x", value); - } - break; - case 3: - /* jset #n,R,p:xx */ - sprintf(srcname, registers_name[value]); - break; + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(srcname, "y:%s", addr_name); + } else { + sprintf(srcname, "x:%s", addr_name); } - fprintf(stderr,"Dsp: 0x%04x: jset #%d,%s,p:0x%04x\n", - dsp_core->pc, + sprintf(str_instr,"jset #%d,%s,p:0x%04x", numbit, srcname, read_memory(dsp_core->pc+1) ); } -static void dsp_jsr(void) +static void dsp_jset_pp(void) +{ + /* jset #n,x:pp,p:xx */ + /* jset #n,y:pp,p:xx */ + char srcname[16]; + Uint32 memspace, value, numbit; + + disasm_cur_inst_len++; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + value += 0xffc0; + if (memspace) { + sprintf(srcname, "y:0x%04x", value); + } else { + sprintf(srcname, "x:0x%04x", value); + } + + sprintf(str_instr,"jset #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); +} + +static void dsp_jset_reg(void) +{ + /* jset #n,R,p:xx */ + Uint32 value, numbit; + + disasm_cur_inst_len++; + + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + sprintf(str_instr,"jset #%d,%s,p:0x%04x", + numbit, + registers_name[value], + read_memory(dsp_core->pc+1) + ); +} + +static void dsp_jsr_imm(void) +{ + sprintf(str_instr,"jsr p:0x%04x", cur_inst & BITMASK(12)); +} + +static void dsp_jsr_ea(void) { char dstname[16]; - if (((cur_inst>>12) & BITMASK(4))==0) { - sprintf(dstname, "0x%04x", cur_inst & BITMASK(12)); + dsp_calc_ea((cur_inst>>8) & BITMASK(6),dstname); + + sprintf(str_instr,"jsr p:%s", dstname); +} + +static void dsp_jsset_aa(void) +{ + /* jsset #n,x:aa,p:xx */ + /* jsset #n,y:aa,p:xx */ + char srcname[16]; + Uint32 memspace, value, numbit; + + disasm_cur_inst_len++; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + if (memspace) { + sprintf(srcname, "y:0x%04x", value); } else { - dsp_calc_ea((cur_inst>>8) & BITMASK(6),dstname); + sprintf(srcname, "x:0x%04x", value); } - fprintf(stderr,"Dsp: 0x%04x: jsr p:%s\n",dsp_core->pc, dstname); + sprintf(str_instr,"jsset #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); } -static void dsp_jsset(void) +static void dsp_jsset_ea(void) { + /* jsset #n,x:ea,p:xx */ + /* jsset #n,y:ea,p:xx */ char srcname[16], addr_name[16]; Uint32 memspace, value, numbit; + disasm_cur_inst_len++; + memspace = (cur_inst>>6) & 1; value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - switch((cur_inst>>14) & BITMASK(2)) { - case 0: - /* jsset #n,x:aa,p:xx */ - /* jsset #n,y:aa,p:xx */ - if (memspace) { - sprintf(srcname, "y:0x%04x", value); - } else { - sprintf(srcname, "x:0x%04x", value); - } - break; - case 1: - /* jsset #n,x:ea,p:xx */ - /* jsset #n,y:ea,p:xx */ - dsp_calc_ea(value, addr_name); - if (memspace) { - sprintf(srcname, "y:%s", addr_name); - } else { - sprintf(srcname, "x:%s", addr_name); - } - break; - case 2: - /* jsset #n,x:pp,p:xx */ - /* jsset #n,y:pp,p:xx */ - value += 0xffc0; - if (memspace) { - sprintf(srcname, "y:0x%04x", value); - } else { - sprintf(srcname, "x:0x%04x", value); - } - break; - case 3: - /* jsset #n,R,p:xx */ - sprintf(srcname, registers_name[value]); - break; + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(srcname, "y:%s", addr_name); + } else { + sprintf(srcname, "x:%s", addr_name); } - fprintf(stderr,"Dsp: 0x%04x: jsset #%d,%s,p:0x%04x\n", - dsp_core->pc, + sprintf(str_instr,"jsset #%d,%s,p:0x%04x", numbit, srcname, read_memory(dsp_core->pc+1) ); } -static void dsp_lua(void) +static void dsp_jsset_pp(void) { - char addr_name[16], numreg; - - dsp_calc_ea((cur_inst>>8) & BITMASK(5), addr_name); - numreg = cur_inst & BITMASK(3); - registers_changed[DSP_REG_R0+numreg]=1; + /* jsset #n,x:pp,p:xx */ + /* jsset #n,y:pp,p:xx */ + char srcname[16]; + Uint32 memspace, value, numbit; - fprintf(stderr,"Dsp: 0x%04x: lua %s,r%d\n",dsp_core->pc, addr_name, numreg); + disasm_cur_inst_len++; + + memspace = (cur_inst>>6) & 1; + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); + + value += 0xffc0; + if (memspace) { + sprintf(srcname, "y:0x%04x", value); + } else { + sprintf(srcname, "x:0x%04x", value); + } + + sprintf(str_instr,"jsset #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); } -static void dsp_movec(void) +static void dsp_jsset_reg(void) { - Uint32 value; + /* jsset #n,r,p:xx */ + Uint32 value, numbit; - value = (cur_inst>>13) & (1<<3); - value |= (cur_inst>>12) & (1<<2); - value |= (cur_inst>>6) & (1<<1); - value |= (cur_inst>>5) & 1; + disasm_cur_inst_len++; + + value = (cur_inst>>8) & BITMASK(6); + numbit = cur_inst & BITMASK(5); - opcodes_movec[value](); + sprintf(str_instr,"jsset #%d,%s,p:0x%04x", + numbit, + registers_name[value], + read_memory(dsp_core->pc+1) + ); +} + +static void dsp_lua(void) +{ + char addr_name[16], numreg; - registers_changed[DSP_REG_SR]=1; + dsp_calc_ea((cur_inst>>8) & BITMASK(5), addr_name); + numreg = cur_inst & BITMASK(3); + + sprintf(str_instr,"lua %s,r%d", addr_name, numreg); } -static void dsp_movec_7(void) +static void dsp_movec_reg(void) { Uint32 numreg1, numreg2; @@ -1547,20 +1578,18 @@ static void dsp_movec_7(void) /* S2,D1 */ numreg2 = (cur_inst>>8) & BITMASK(6); - numreg1 = (cur_inst & BITMASK(5))|0x20; + numreg1 = cur_inst & BITMASK(6); if (cur_inst & (1<<15)) { /* Write D1 */ - fprintf(stderr,"Dsp: 0x%04x: movec %s,%s\n",dsp_core->pc, registers_name[numreg2], registers_name[numreg1]); - registers_changed[numreg1]=1; + sprintf(str_instr,"movec %s,%s", registers_name[numreg2], registers_name[numreg1]); } else { /* Read S1 */ - fprintf(stderr,"Dsp: 0x%04x: movec %s,%s\n",dsp_core->pc, registers_name[numreg1], registers_name[numreg2]); - registers_changed[numreg2]=1; + sprintf(str_instr,"movec %s,%s", registers_name[numreg1], registers_name[numreg2]); } } -static void dsp_movec_9(void) +static void dsp_movec_aa(void) { const char *spacename; char srcname[16],dstname[16]; @@ -1571,7 +1600,7 @@ static void dsp_movec_9(void) /* y:aa,D1 */ /* S1,y:aa */ - numreg = (cur_inst & BITMASK(5))|0x20; + numreg = cur_inst & BITMASK(6); addr = (cur_inst>>8) & BITMASK(6); if (cur_inst & (1<<6)) { @@ -1590,22 +1619,21 @@ static void dsp_movec_9(void) sprintf(dstname, "%s:0x%04x", spacename, addr); } - fprintf(stderr,"Dsp: 0x%04x: movec %s,%s\n",dsp_core->pc, srcname, dstname); + sprintf(str_instr,"movec %s,%s", srcname, dstname); } -static void dsp_movec_b(void) +static void dsp_movec_imm(void) { Uint32 numreg; /* #xx,D1 */ - numreg = (cur_inst & BITMASK(5))|0x20; + numreg = cur_inst & BITMASK(6); - registers_changed[numreg]=1; - fprintf(stderr,"Dsp: 0x%04x: movec #0x%02x,%s\n",dsp_core->pc, (cur_inst>>8) & BITMASK(8), registers_name[numreg]); + sprintf(str_instr,"movec #0x%02x,%s", (cur_inst>>8) & BITMASK(8), registers_name[numreg]); } -static void dsp_movec_d(void) +static void dsp_movec_ea(void) { const char *spacename; char srcname[16], dstname[16], addr_name[16]; @@ -1618,7 +1646,7 @@ static void dsp_movec_d(void) /* S1,y:ea */ /* #xxxx,D1 */ - numreg = (cur_inst & BITMASK(5))|0x20; + numreg = cur_inst & BITMASK(6); ea_mode = (cur_inst>>8) & BITMASK(6); retour = dsp_calc_ea(ea_mode, addr_name); @@ -1635,7 +1663,6 @@ static void dsp_movec_d(void) } else { sprintf(srcname, "%s:%s", spacename, addr_name); } - registers_changed[numreg]=1; strcpy(dstname, registers_name[numreg]); } else { /* Read S1 */ @@ -1643,31 +1670,20 @@ static void dsp_movec_d(void) sprintf(dstname, "%s:%s", spacename, addr_name); } - fprintf(stderr,"Dsp: 0x%04x: movec %s,%s\n",dsp_core->pc, srcname, dstname); + sprintf(str_instr,"movec %s,%s", srcname, dstname); } -static void dsp_movem(void) +static void dsp_movem_aa(void) { + /* S,p:aa */ + /* p:aa,D */ char addr_name[16], srcname[16], dstname[16]; - Uint32 ea_mode, numreg; - - if (cur_inst & (1<<14)) { - /* S,p:ea */ - /* p:ea,D */ - - ea_mode = (cur_inst>>8) & BITMASK(6); - dsp_calc_ea(ea_mode, addr_name); - } else { - /* S,p:aa */ - /* p:aa,D */ - - sprintf(addr_name, "0x%04x",(cur_inst>>8) & BITMASK(6)); - } + Uint32 numreg; + sprintf(addr_name, "0x%04x",(cur_inst>>8) & BITMASK(6)); numreg = cur_inst & BITMASK(6); if (cur_inst & (1<<15)) { /* Write D */ - registers_changed[numreg]=1; sprintf(srcname, "p:%s", addr_name); strcpy(dstname, registers_name[numreg]); } else { @@ -1676,19 +1692,30 @@ static void dsp_movem(void) sprintf(dstname, "p:%s", addr_name); } - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: movem %s,%s\n",dsp_core->pc, srcname, dstname); + sprintf(str_instr,"movem %s,%s", srcname, dstname); } -static void dsp_movep(void) +static void dsp_movem_ea(void) { - Uint32 value; - - value = (cur_inst>>6) & BITMASK(2); + /* S,p:ea */ + /* p:ea,D */ + char addr_name[16], srcname[16], dstname[16]; + Uint32 ea_mode, numreg; - opcodes_movep[value](); - registers_changed[DSP_REG_SR]=1; + ea_mode = (cur_inst>>8) & BITMASK(6); + dsp_calc_ea(ea_mode, addr_name); + numreg = cur_inst & BITMASK(6); + if (cur_inst & (1<<15)) { + /* Write D */ + sprintf(srcname, "p:%s", addr_name); + strcpy(dstname, registers_name[numreg]); + } else { + /* Read S */ + strcpy(srcname, registers_name[numreg]); + sprintf(dstname, "p:%s", addr_name); + } + + sprintf(str_instr,"movem %s,%s", srcname, dstname); } static void dsp_movep_0(void) @@ -1724,11 +1751,10 @@ static void dsp_movep_0(void) sprintf(srcname, "x:0x%04x", addr); } - registers_changed[numreg]=1; strcpy(dstname, registers_name[numreg]); } - fprintf(stderr,"Dsp: 0x%04x: movep %s,%s\n",dsp_core->pc, srcname, dstname); + sprintf(str_instr,"movep %s,%s", srcname, dstname); } static void dsp_movep_1(void) @@ -1767,10 +1793,10 @@ static void dsp_movep_1(void) sprintf(dstname, "p:%s", name); } - fprintf(stderr,"Dsp: 0x%04x: movep %s,%s\n",dsp_core->pc, srcname, dstname); + sprintf(str_instr,"movep %s,%s", srcname, dstname); } -static void dsp_movep_2(void) +static void dsp_movep_23(void) { char srcname[16]="",dstname[16]="",name[16]=""; Uint32 addr, memspace, easpace, retour; @@ -1826,12 +1852,12 @@ static void dsp_movep_2(void) } } - fprintf(stderr,"Dsp: 0x%04x: movep %s,%s\n",dsp_core->pc, srcname, dstname); + sprintf(str_instr,"movep %s,%s", srcname, dstname); } static void dsp_nop(void) { - fprintf(stderr,"Dsp: 0x%04x: nop\n",dsp_core->pc); + sprintf(str_instr,"nop"); } static void dsp_norm(void) @@ -1841,59 +1867,28 @@ static void dsp_norm(void) srcreg = DSP_REG_R0+((cur_inst>>8) & BITMASK(3)); destreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[srcreg]=1; - registers_changed[destreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: norm %s,%s\n",dsp_core->pc, registers_name[srcreg], registers_name[destreg]); + sprintf(str_instr,"norm %s,%s", registers_name[srcreg], registers_name[destreg]); } static void dsp_ori(void) { - const char *regname; - switch(cur_inst & BITMASK(2)) { case 0: - regname="mr"; - registers_changed[DSP_REG_SR]=1; + sprintf(str_instr,"ori #0x%02x,mr", (cur_inst>>8) & BITMASK(8)); break; case 1: - regname="ccr"; - registers_changed[DSP_REG_SR]=1; + sprintf(str_instr,"ori #0x%02x,ccr", (cur_inst>>8) & BITMASK(8)); break; case 2: - regname="omr"; - registers_changed[DSP_REG_OMR]=1; + sprintf(str_instr,"ori #0x%02x,omr", (cur_inst>>8) & BITMASK(8)); break; default: - regname=""; break; } - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: ori #0x%02x,%s\n", - dsp_core->pc, - (cur_inst>>8) & BITMASK(8), - regname - ); } -static void dsp_rep(void) -{ - Uint32 value; - - value = (cur_inst>>12) & (BITMASK(2)<<2); - value |= (cur_inst>>6) & (1<<1); - value |= (cur_inst>>5) & 1; - - opcodes_rep[value](); - - registers_changed[DSP_REG_LC]=1; - registers_changed[DSP_REG_SR]=1; -} - -static void dsp_rep_1(void) +static void dsp_rep_aa(void) { char name[16]; @@ -1906,16 +1901,17 @@ static void dsp_rep_1(void) sprintf(name, "x:0x%04x",(cur_inst>>8) & BITMASK(6)); } - fprintf(stderr,"Dsp: 0x%04x: rep %s\n",dsp_core->pc, name); + sprintf(str_instr,"rep %s", name); } -static void dsp_rep_3(void) +static void dsp_rep_imm(void) { /* #xxx */ - fprintf(stderr,"Dsp: 0x%04x: rep #0x%02x\n",dsp_core->pc, (cur_inst>>8) & BITMASK(8)); + sprintf(str_instr,"rep #0x%02x", ((cur_inst>>8) & BITMASK(8)) + + ((cur_inst & BITMASK(4))<<8)); } -static void dsp_rep_5(void) +static void dsp_rep_ea(void) { char name[16],addr_name[16]; @@ -1929,41 +1925,39 @@ static void dsp_rep_5(void) sprintf(name, "x:%s",addr_name); } - fprintf(stderr,"Dsp: 0x%04x: rep %s\n",dsp_core->pc, name); + sprintf(str_instr,"rep %s", name); } -static void dsp_rep_d(void) +static void dsp_rep_reg(void) { /* R */ - fprintf(stderr,"Dsp: 0x%04x: rep %s\n",dsp_core->pc, registers_name[(cur_inst>>8) & BITMASK(6)]); + sprintf(str_instr,"rep %s", registers_name[(cur_inst>>8) & BITMASK(6)]); } static void dsp_reset(void) { - fprintf(stderr,"Dsp: 0x%04x: reset\n",dsp_core->pc); + sprintf(str_instr,"reset"); } static void dsp_rti(void) { - registers_changed[DSP_REG_SR]=1; - fprintf(stderr,"Dsp: 0x%04x: rti\n",dsp_core->pc); + sprintf(str_instr,"rti"); } static void dsp_rts(void) { - registers_changed[DSP_REG_SR]=1; - fprintf(stderr,"Dsp: 0x%04x: rts\n",dsp_core->pc); + sprintf(str_instr,"rts"); } static void dsp_stop(void) { - fprintf(stderr,"Dsp: 0x%04x: stop\n",dsp_core->pc); + sprintf(str_instr,"stop"); } static void dsp_swi(void) { - fprintf(stderr,"Dsp: 0x%04x: swi\n",dsp_core->pc); + sprintf(str_instr,"swi"); } static void dsp_tcc(void) @@ -1975,14 +1969,11 @@ static void dsp_tcc(void) src1reg = registers_tcc[(cur_inst>>3) & BITMASK(4)][0]; dst1reg = registers_tcc[(cur_inst>>3) & BITMASK(4)][1]; - registers_changed[dst1reg]=1; if (cur_inst & (1<<16)) { src2reg = DSP_REG_R0+(cur_inst & BITMASK(3)); dst2reg = DSP_REG_R0+((cur_inst>>8) & BITMASK(3)); - registers_changed[dst2reg]=1; - fprintf(stderr,"Dsp: 0x%04x: t%s %s,%s %s,%s\n", - dsp_core->pc, + sprintf(str_instr,"t%s %s,%s %s,%s", ccname, registers_name[src1reg], registers_name[dst1reg], @@ -1990,8 +1981,7 @@ static void dsp_tcc(void) registers_name[dst2reg] ); } else { - fprintf(stderr,"Dsp: 0x%04x: t%s %s,%s\n", - dsp_core->pc, + sprintf(str_instr,"t%s %s,%s", ccname, registers_name[src1reg], registers_name[dst1reg] @@ -2001,7 +1991,7 @@ static void dsp_tcc(void) static void dsp_wait(void) { - fprintf(stderr,"Dsp: 0x%04x: wait\n",dsp_core->pc); + sprintf(str_instr,"wait"); } /********************************** @@ -2013,7 +2003,6 @@ static void dsp_pm(void) Uint32 value; value = (cur_inst >> 20) & BITMASK(4); - opcodes_parmove[value](); } @@ -2037,8 +2026,6 @@ static void dsp_pm_0(void) numreg2 = DSP_REG_X0; } - registers_changed[numreg1]=1; - sprintf(parallelmove_name, "%s,%s:%s %s,%s", registers_name[numreg1], @@ -2079,13 +2066,9 @@ static void dsp_pm_1(void) s1reg = DSP_REG_A+((cur_inst>>19) & 1); d1reg = DSP_REG_X0+((cur_inst>>18) & 1); - registers_changed[d1reg]=1; - if (write_flag) { /* Write D2 */ - registers_changed[d2reg]=1; - if (retour) { sprintf(parallelmove_name,"%s,%s #%s,%s", registers_name[s1reg], @@ -2123,13 +2106,9 @@ static void dsp_pm_1(void) s2reg = DSP_REG_A+((cur_inst>>17) & 1); d2reg = DSP_REG_Y0+((cur_inst>>16) & 1); - registers_changed[d2reg]=1; - if (write_flag) { /* Write D1 */ - registers_changed[d1reg]=1; - if (retour) { sprintf(parallelmove_name,"#%s,%s %s,%s", addr_name, @@ -2174,7 +2153,6 @@ static void dsp_pm_2(void) if (((cur_inst >> 8) & 0xffe0) == 0x2040) { dsp_calc_ea((cur_inst>>8) & BITMASK(5), addr_name); - registers_changed[DSP_REG_R0+((cur_inst>>8) & BITMASK(3))]=1; sprintf(parallelmove_name, "%s,r%d",addr_name, (cur_inst>>8) & BITMASK(3)); return; } @@ -2182,13 +2160,11 @@ static void dsp_pm_2(void) if (((cur_inst >> 8) & 0xfc00) == 0x2000) { numreg1 = (cur_inst>>13) & BITMASK(5); numreg2 = (cur_inst>>8) & BITMASK(5); - registers_changed[numreg2]=1; sprintf(parallelmove_name, "%s,%s", registers_name[numreg1], registers_name[numreg2]); return; } numreg1 = (cur_inst>>16) & BITMASK(5); - registers_changed[numreg1]=1; sprintf(parallelmove_name, "#0x%02x,%s", (cur_inst >> 8) & BITMASK(8), registers_name[numreg1]); } @@ -2232,7 +2208,6 @@ static void dsp_pm_4(void) if (cur_inst & (1<<15)) { /* Write D */ - registers_changed[value]=1; if (retour) { sprintf(parallelmove_name, "#%s,%s", addr_name, registers_lmove[value]); } else { @@ -2260,7 +2235,6 @@ static void dsp_pm_4(void) if (cur_inst & (1<<15)) { /* Write D */ - registers_changed[value]=1; if (retour) { sprintf(parallelmove_name, "#%s,%s", addr_name, registers_name[value]); } else { @@ -2277,8 +2251,6 @@ static void dsp_pm_4(void) if (cur_inst & (1<<15)) { /* Write D */ - registers_changed[value]=1; - if (retour) { sprintf(parallelmove_name, "#%s,%s", addr_name, registers_name[value]); } else { @@ -2334,9 +2306,7 @@ static void dsp_pm_8(void) dsp_calc_ea(ea_mode2, addr2_name); if (cur_inst & (1<<15)) { - registers_changed[numreg1]=1; if (cur_inst & (1<<22)) { - registers_changed[numreg2]=1; sprintf(parallelmove_name, "x:%s,%s y:%s,%s", addr1_name, registers_name[numreg1], @@ -2353,7 +2323,6 @@ static void dsp_pm_8(void) } } else { if (cur_inst & (1<<22)) { - registers_changed[numreg2]=1; sprintf(parallelmove_name, "%s,x:%s y:%s,%s", registers_name[numreg1], addr1_name, @@ -2382,14 +2351,7 @@ static void dsp_abs(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: abs %s %s\n", - dsp_core->pc, - registers_name[numreg], - parallelmove_name - ); + sprintf(str_instr,"abs %s %s", registers_name[numreg], parallelmove_name); } static void dsp_adc(void) @@ -2404,11 +2366,8 @@ static void dsp_adc(void) } numreg=DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - fprintf(stderr,"Dsp: 0x%04x: adc %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"adc %s,%s %s", srcname, registers_name[numreg], parallelmove_name @@ -2451,11 +2410,7 @@ static void dsp_add(void) break; } - registers_changed[DSP_REG_A+dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: add %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"add %s,%s %s", srcname, registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -2468,11 +2423,7 @@ static void dsp_addl(void) numreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: addl %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"addl %s,%s %s", registers_name[DSP_REG_A+(numreg ^ 1)], registers_name[DSP_REG_A+numreg], parallelmove_name @@ -2485,11 +2436,7 @@ static void dsp_addr(void) numreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: addr %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"addr %s,%s %s", registers_name[DSP_REG_A+(numreg ^ 1)], registers_name[DSP_REG_A+numreg], parallelmove_name @@ -2516,11 +2463,7 @@ static void dsp_and(void) } dstreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: and %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"and %s,%s %s", registers_name[srcreg], registers_name[dstreg], parallelmove_name @@ -2533,11 +2476,7 @@ static void dsp_asl(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: asl %s %s\n", - dsp_core->pc, + sprintf(str_instr,"asl %s %s", registers_name[numreg], parallelmove_name ); @@ -2549,11 +2488,7 @@ static void dsp_asr(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: asr %s %s\n", - dsp_core->pc, + sprintf(str_instr,"asr %s %s", registers_name[numreg], parallelmove_name ); @@ -2565,11 +2500,7 @@ static void dsp_clr(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: clr %s %s\n", - dsp_core->pc, + sprintf(str_instr,"clr %s %s", registers_name[numreg], parallelmove_name ); @@ -2600,10 +2531,7 @@ static void dsp_cmp(void) break; } - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: cmp %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"cmp %s,%s %s", registers_name[srcreg], registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -2635,10 +2563,7 @@ static void dsp_cmpm(void) break; } - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: cmpm %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"cmpm %s,%s %s", registers_name[srcreg], registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -2665,11 +2590,7 @@ static void dsp_eor(void) } dstreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: eor %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"eor %s,%s %s", registers_name[srcreg], registers_name[dstreg], parallelmove_name @@ -2682,11 +2603,7 @@ static void dsp_lsl(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: lsl %s %s\n", - dsp_core->pc, + sprintf(str_instr,"lsl %s %s", registers_name[numreg], parallelmove_name ); @@ -2698,11 +2615,7 @@ static void dsp_lsr(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: lsr %s %s\n", - dsp_core->pc, + sprintf(str_instr,"lsr %s %s", registers_name[numreg], parallelmove_name ); @@ -2755,11 +2668,7 @@ static void dsp_mac(void) } dstreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: mac %s%s,%s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"mac %s%s,%s,%s %s", sign_name, registers_name[src1reg], registers_name[src2reg], @@ -2815,11 +2724,7 @@ static void dsp_macr(void) } dstreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: macr %s%s,%s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"macr %s%s,%s,%s %s", sign_name, registers_name[src1reg], registers_name[src2reg], @@ -2830,13 +2735,7 @@ static void dsp_macr(void) static void dsp_move(void) { - fprintf(stderr,"Dsp: 0x%04x: move %s\n",dsp_core->pc, parallelmove_name); -} - -static void dsp_move_nopm(void) -{ - dsp_pm(); - fprintf(stderr,"Dsp: 0x%04x: move %s\n",dsp_core->pc, parallelmove_name); + sprintf(str_instr,"move %s", parallelmove_name); } static void dsp_mpy(void) @@ -2886,11 +2785,7 @@ static void dsp_mpy(void) } dstreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: mpy %s%s,%s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"mpy %s%s,%s,%s %s", sign_name, registers_name[src1reg], registers_name[src2reg], @@ -2946,11 +2841,7 @@ static void dsp_mpyr(void) } dstreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: mpyr %s%s,%s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"mpyr %s%s,%s,%s %s", sign_name, registers_name[src1reg], registers_name[src2reg], @@ -2965,11 +2856,7 @@ static void dsp_neg(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: neg %s %s\n", - dsp_core->pc, + sprintf(str_instr,"neg %s %s", registers_name[numreg], parallelmove_name ); @@ -2981,11 +2868,7 @@ static void dsp_not(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: not %s %s\n", - dsp_core->pc, + sprintf(str_instr,"not %s %s", registers_name[numreg], parallelmove_name ); @@ -3011,11 +2894,7 @@ static void dsp_or(void) } dstreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: or %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"or %s,%s %s", registers_name[srcreg], registers_name[dstreg], parallelmove_name @@ -3028,11 +2907,7 @@ static void dsp_rnd(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: rnd %s %s\n", - dsp_core->pc, + sprintf(str_instr,"rnd %s %s", registers_name[numreg], parallelmove_name ); @@ -3044,11 +2919,7 @@ static void dsp_rol(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: rol %s %s\n", - dsp_core->pc, + sprintf(str_instr,"rol %s %s", registers_name[numreg], parallelmove_name ); @@ -3060,11 +2931,7 @@ static void dsp_ror(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: ror %s %s\n", - dsp_core->pc, + sprintf(str_instr,"ror %s %s", registers_name[numreg], parallelmove_name ); @@ -3083,11 +2950,7 @@ static void dsp_sbc(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: sbc %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"sbc %s,%s %s", srcname, registers_name[numreg], parallelmove_name @@ -3130,11 +2993,7 @@ static void dsp_sub(void) break; } - registers_changed[DSP_REG_A+dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: sub %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"sub %s,%s %s", srcname, registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -3147,11 +3006,7 @@ static void dsp_subl(void) numreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: subl %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"subl %s,%s %s", registers_name[DSP_REG_A+(numreg ^ 1)], registers_name[DSP_REG_A+numreg], parallelmove_name @@ -3164,11 +3019,7 @@ static void dsp_subr(void) numreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+numreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: subr %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"subr %s,%s %s", registers_name[DSP_REG_A+(numreg ^ 1)], registers_name[DSP_REG_A+numreg], parallelmove_name @@ -3201,11 +3052,7 @@ static void dsp_tfr(void) break; } - registers_changed[DSP_REG_A+dstreg]=1; - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: tfr %s,%s %s\n", - dsp_core->pc, + sprintf(str_instr,"tfr %s,%s %s", registers_name[srcreg], registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -3214,10 +3061,7 @@ static void dsp_tfr(void) static void dsp_tst(void) { - registers_changed[DSP_REG_SR]=1; - - fprintf(stderr,"Dsp: 0x%04x: tst %s %s\n", - dsp_core->pc, + sprintf(str_instr,"tst %s %s", registers_name[DSP_REG_A+((cur_inst>>3) & 1)], parallelmove_name );