--- hatari/src/falcon/dsp_disasm.c 2019/04/01 07:13:46 1.1 +++ hatari/src/falcon/dsp_disasm.c 2019/04/09 08:48:45 1.1.1.4 @@ -1,36 +1,35 @@ /* - * Dsp56K disassembler - * - * ARAnyM (C) 2003 Patrice Mandin - * Adaption to Hatari (C) 2006 by Thomas Huth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ + DSP M56001 emulation + Disassembler + + (C) 2003-2008 ARAnyM developer team + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include -#include "main.h" -#include "sysdeps.h" -#include "ioMem.h" -#include "dsp.h" +#include "dsp_core.h" #include "dsp_cpu.h" #include "dsp_disasm.h" -#if DEBUG -#define D(x) x -#else -#define D(x) -#endif +#define DEBUG 0 /* More disasm infos, if wanted */ #define DSP_DISASM_REG_PC 0 @@ -46,16 +45,30 @@ **********************************/ /* Current instruction */ -static uint32 cur_inst; +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; + +void dsp56k_disasm_init(dsp_core_t *my_dsp_core) +{ + dsp_core = my_dsp_core; +} /********************************** * Register change **********************************/ -static uint32 registers_save[64]; -static uint32 registers_changed[64]; +static Uint32 registers_save[64]; #if DSP_DISASM_REG_PC -static uint32 pc_save; +static Uint32 pc_save; #endif static const char *registers_name[64]={ @@ -80,139 +93,71 @@ static const char *registers_name[64]={ "ssh","ssl","la","lc" }; -void dsp56k_disasm_reg_read(void) -{ - memcpy(registers_save, dsp_registers , sizeof(registers_save)); - memset(registers_changed, 0, sizeof(registers_changed)); -#if DSP_DISASM_REG_PC - pc_save = dsp_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_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_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_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_registers[DSP_REG_A2+(i & 1)] & BITMASK(8), - dsp_registers[DSP_REG_A1+(i & 1)] & BITMASK(24), - dsp_registers[DSP_REG_A0+(i & 1)] & BITMASK(24) - ); - } - break; - } - } -#if DSP_DISASM_REG_PC - if (pc_save != dsp_pc) { - fprintf(stderr,"Dsp: Reg: pc: 0x%04x -> 0x%04x\n", pc_save, dsp_pc); - } -#endif -} - /********************************** * Opcode disassembler **********************************/ +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); +static int dsp_calc_ea(Uint32 ea_mode, char *dest); +static void dsp_calc_cc(Uint32 cc_mode, char *dest); 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); @@ -220,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); @@ -263,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); @@ -279,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 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_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 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_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_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_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, @@ -602,11 +381,11 @@ static int registers_tcc[16][2]={ {DSP_REG_X0,DSP_REG_A}, {DSP_REG_X0,DSP_REG_B}, - {DSP_REG_X1,DSP_REG_A}, - {DSP_REG_X1,DSP_REG_B}, - {DSP_REG_Y0,DSP_REG_A}, {DSP_REG_Y0,DSP_REG_B}, + + {DSP_REG_X1,DSP_REG_A}, + {DSP_REG_X1,DSP_REG_B}, {DSP_REG_Y1,DSP_REG_A}, {DSP_REG_Y1,DSP_REG_B} }; @@ -654,45 +433,167 @@ 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(void) +void dsp56k_disasm_reg_compare(void) { - uint32 value; + int i; + + for (i=0; i<64; i++) { + if (registers_save[i] == dsp_core->registers[i]) { + continue; + } - cur_inst = dsp_ram[DSP_SPACE_P][dsp_pc]; + 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; + } + } -#if 0 - if (dsp_pc == 0x728) { - D(bug("Dsp: Disasm: instruction = 0x%06x",cur_inst)); +#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; +} + +/** + * dsp56k_getInstrText : return the disasembled instructions + */ +char* dsp56k_getInstructionText(void) +{ + 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) +{ + Uint32 value; + + if (currPc<0x200) { + value = dsp_core->ramint[DSP_SPACE_P][currPc]; + } else { + value = dsp_core->ramext[currPc & (DSP_RAMSIZE-1)]; } + + return value & BITMASK(24); } /********************************** * Conditions code calculation **********************************/ -static void dsp_calc_cc(uint32 cc_mode, char *dest) +static void dsp_calc_cc(Uint32 cc_mode, char *dest) { strcpy(dest, cc_name[cc_mode & BITMASK(4)]); } @@ -701,7 +602,7 @@ static void dsp_calc_cc(uint32 cc_mode, * Effective address calculation **********************************/ -static int dsp_calc_ea(uint32 ea_mode, char *dest) +static int dsp_calc_ea(Uint32 ea_mode, char *dest) { int value, retour, numreg; @@ -712,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) */ @@ -726,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) */ @@ -740,17 +637,17 @@ 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 */ - sprintf(dest, ea_names[value], dsp_ram[DSP_SPACE_P][dsp_pc+1]); + sprintf(dest, ea_names[value], read_memory(dsp_core->pc+1)); break; case 1: /* Immediate value */ - sprintf(dest, ea_names[8], dsp_ram[DSP_SPACE_P][dsp_pc+1]); + sprintf(dest, ea_names[8], read_memory(dsp_core->pc+1)); retour = 1; break; } @@ -761,345 +658,354 @@ 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); - value = (cur_inst >> 12) & BITMASK(4); - opcodes_0809[value](); + dsp_calc_ea(value, addr_name); + if (memspace) { + sprintf(name,"y:%s",addr_name); + } else { + sprintf(name,"x:%s",addr_name); + } + + 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_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); } - fprintf(stderr,"Dsp: 0x%04x: andi #0x%02x,%s\n", - dsp_pc, - (cur_inst>>8) & BITMASK(8), - regname - ); + sprintf(str_instr,"bclr #%d,%s", numbit, name); } -static void dsp_bchg(void) +static void dsp_bclr_reg(void) { - char name[16], addr_name[16]; - uint32 memspace, value, numbit; + /* 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_bset_aa(void) +{ + /* 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); } - fprintf(stderr,"Dsp: 0x%04x: bchg #%d,%s\n",dsp_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; + 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: - /* 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); } - fprintf(stderr,"Dsp: 0x%04x: bclr #%d,%s\n",dsp_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]; - uint32 memspace, value, numbit; + /* 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); + } + + 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_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; + 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: - /* 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); } - fprintf(stderr,"Dsp: 0x%04x: btst #%d,%s\n",dsp_pc, numbit, name); + sprintf(str_instr,"btst #%d,%s", 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) { - uint32 srcreg=DSP_REG_NULL, destreg; + Uint32 srcreg=DSP_REG_NULL, destreg; switch((cur_inst>>4) & BITMASK(2)) { case 0: @@ -1116,56 +1022,45 @@ static void dsp_div(void) break; } destreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[destreg]=1; - fprintf(stderr,"Dsp: 0x%04x: div %s,%s\n",dsp_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; -} - -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_pc, + sprintf(str_instr,"do %s,p:0x%04x", name, - dsp_ram[DSP_SPACE_P][dsp_pc+1] & BITMASK(16) + 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_pc, + disasm_cur_inst_len++; + + sprintf(str_instr,"do #0x%04x,p:0x%04x", ((cur_inst>>8) & BITMASK(8))|((cur_inst & BITMASK(4))<<8), - dsp_ram[DSP_SPACE_P][dsp_pc+1] & BITMASK(16) + 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; + Uint32 ea_mode; + disasm_cur_inst_len++; + ea_mode = (cur_inst>>8) & BITMASK(6); dsp_calc_ea(ea_mode, addr_name); @@ -1175,369 +1070,537 @@ static void dsp_do_4(void) sprintf(name, "x:%s", addr_name); } - fprintf(stderr,"Dsp: 0x%04x: do %s,p:0x%04x\n", - dsp_pc, + sprintf(str_instr,"do %s,p:0x%04x", name, - dsp_ram[DSP_SPACE_P][dsp_pc+1] & BITMASK(16) + 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_pc, + disasm_cur_inst_len++; + + sprintf(str_instr,"do %s,p:0x%04x", registers_name[(cur_inst>>8) & BITMASK(6)], - dsp_ram[DSP_SPACE_P][dsp_pc+1] & BITMASK(16) + read_memory(dsp_core->pc+1) ); } static void dsp_enddo(void) { - fprintf(stderr,"Dsp: 0x%04x: enddo\n",dsp_pc); + sprintf(str_instr,"enddo"); } static void dsp_illegal(void) { - fprintf(stderr,"Dsp: 0x%04x: illegal\n",dsp_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; + 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_pc, cond_name, addr_name); + sprintf(str_instr,"j%s p:%s", cond_name, addr_name); } -static void dsp_jclr(void) +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_ea(void) +{ + /* jclr #n,x:ea,p:xx */ + /* jclr #n,y:ea,p:xx */ char srcname[16], addr_name[16]; - uint32 memspace, value, numbit; + 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_pc, + sprintf(str_instr,"jclr #%d,%s,p:0x%04x", numbit, srcname, - dsp_ram[DSP_SPACE_P][dsp_pc+1] + 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_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; + 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_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; + 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); } - fprintf(stderr,"Dsp: 0x%04x: jsclr #%d,%s,p:0x%04x\n", - dsp_pc, + sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", numbit, srcname, - dsp_ram[DSP_SPACE_P][dsp_pc+1] + read_memory(dsp_core->pc+1) ); } -static void dsp_jset(void) +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); + } + + sprintf(str_instr,"jset #%d,%s,p:0x%04x", + numbit, + srcname, + read_memory(dsp_core->pc+1) + ); +} + +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; + 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_pc, + sprintf(str_instr,"jset #%d,%s,p:0x%04x", numbit, srcname, - dsp_ram[DSP_SPACE_P][dsp_pc+1] + 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_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; + 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_pc, + sprintf(str_instr,"jsset #%d,%s,p:0x%04x", numbit, srcname, - dsp_ram[DSP_SPACE_P][dsp_pc+1] + 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_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); + + 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; - opcodes_movec[value](); + 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; + Uint32 numreg1, numreg2; /* S1,D2 */ /* 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_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_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]; - uint32 numreg, addr; + Uint32 numreg, addr; /* x:aa,D1 */ /* S1,x:aa */ /* 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)) { @@ -1556,26 +1619,25 @@ static void dsp_movec_9(void) sprintf(dstname, "%s:0x%04x", spacename, addr); } - fprintf(stderr,"Dsp: 0x%04x: movec %s,%s\n",dsp_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; + 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_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]; - uint32 numreg, ea_mode; + Uint32 numreg, ea_mode; int retour; /* x:ea,D1 */ @@ -1584,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); @@ -1601,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 */ @@ -1609,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_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 { @@ -1642,22 +1692,36 @@ static void dsp_movem(void) sprintf(dstname, "p:%s", addr_name); } - fprintf(stderr,"Dsp: 0x%04x: movem %s,%s\n",dsp_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; + + 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); + } - opcodes_movep[value](); + sprintf(str_instr,"movem %s,%s", srcname, dstname); } static void dsp_movep_0(void) { char srcname[16]="",dstname[16]=""; - uint32 addr, memspace, numreg; + Uint32 addr, memspace, numreg; /* S,x:pp */ /* x:pp,D */ @@ -1687,17 +1751,16 @@ 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_pc, srcname, dstname); + sprintf(str_instr,"movep %s,%s", srcname, dstname); } static void dsp_movep_1(void) { char srcname[16]="",dstname[16]="",name[16]=""; - uint32 addr, memspace; + Uint32 addr, memspace; /* p:ea,x:pp */ /* x:pp,p:ea */ @@ -1730,13 +1793,13 @@ static void dsp_movep_1(void) sprintf(dstname, "p:%s", name); } - fprintf(stderr,"Dsp: 0x%04x: movep %s,%s\n",dsp_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; + Uint32 addr, memspace, easpace, retour; /* x:ea,x:pp */ /* y:ea,x:pp */ @@ -1789,71 +1852,43 @@ static void dsp_movep_2(void) } } - fprintf(stderr,"Dsp: 0x%04x: movep %s,%s\n",dsp_pc, srcname, dstname); + sprintf(str_instr,"movep %s,%s", srcname, dstname); } static void dsp_nop(void) { - fprintf(stderr,"Dsp: 0x%04x: nop\n",dsp_pc); + sprintf(str_instr,"nop"); } static void dsp_norm(void) { - uint32 srcreg, destreg; + Uint32 srcreg, destreg; 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; - - fprintf(stderr,"Dsp: 0x%04x: norm %s,%s\n",dsp_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; } - fprintf(stderr,"Dsp: 0x%04x: ori #0x%02x,%s\n", - dsp_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_LA]=1; - registers_changed[DSP_REG_LC]=1; } -static void dsp_rep_1(void) +static void dsp_rep_aa(void) { char name[16]; @@ -1866,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_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_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]; @@ -1889,58 +1925,55 @@ static void dsp_rep_5(void) sprintf(name, "x:%s",addr_name); } - fprintf(stderr,"Dsp: 0x%04x: rep %s\n",dsp_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_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_pc); + sprintf(str_instr,"reset"); } static void dsp_rti(void) { - fprintf(stderr,"Dsp: 0x%04x: rti\n",dsp_pc); + sprintf(str_instr,"rti"); } static void dsp_rts(void) { - fprintf(stderr,"Dsp: 0x%04x: rts\n",dsp_pc); + sprintf(str_instr,"rts"); } static void dsp_stop(void) { - fprintf(stderr,"Dsp: 0x%04x: stop\n",dsp_pc); + sprintf(str_instr,"stop"); } static void dsp_swi(void) { - fprintf(stderr,"Dsp: 0x%04x: swi\n",dsp_pc); + sprintf(str_instr,"swi"); } static void dsp_tcc(void) { char ccname[16]; - uint32 src1reg, dst1reg, src2reg, dst2reg; + Uint32 src1reg, dst1reg, src2reg, dst2reg; dsp_calc_cc((cur_inst>>12) & BITMASK(4), ccname); src1reg = registers_tcc[(cur_inst>>3) & BITMASK(4)][0]; - dst1reg = 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_pc, + sprintf(str_instr,"t%s %s,%s %s,%s", ccname, registers_name[src1reg], registers_name[dst1reg], @@ -1948,8 +1981,7 @@ static void dsp_tcc(void) registers_name[dst2reg] ); } else { - fprintf(stderr,"Dsp: 0x%04x: t%s %s,%s\n", - dsp_pc, + sprintf(str_instr,"t%s %s,%s", ccname, registers_name[src1reg], registers_name[dst1reg] @@ -1959,7 +1991,7 @@ static void dsp_tcc(void) static void dsp_wait(void) { - fprintf(stderr,"Dsp: 0x%04x: wait\n",dsp_pc); + sprintf(str_instr,"wait"); } /********************************** @@ -1968,17 +2000,16 @@ static void dsp_wait(void) static void dsp_pm(void) { - uint32 value; + Uint32 value; value = (cur_inst >> 20) & BITMASK(4); - opcodes_parmove[value](); } static void dsp_pm_0(void) { char space_name[16], addr_name[16]; - uint32 memspace, numreg1, numreg2; + Uint32 memspace, numreg1, numreg2; /* 0000 100d 00mm mrrr S,x:ea x0,D 0000 100d 10mm mrrr S,y:ea y0,D @@ -1995,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], @@ -2019,7 +2048,7 @@ static void dsp_pm_1(void) */ char addr_name[16]; - uint32 memspace, write_flag, retour, s1reg, s2reg, d1reg, d2reg; + Uint32 memspace, write_flag, retour, s1reg, s2reg, d1reg, d2reg; memspace = (cur_inst>>14) & 1; write_flag = (cur_inst>>15) & 1; @@ -2037,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], @@ -2081,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, @@ -2119,7 +2140,7 @@ static void dsp_pm_1(void) static void dsp_pm_2(void) { char addr_name[16]; - uint32 numreg1, numreg2; + Uint32 numreg1, numreg2; /* 0010 0000 0000 0000 nop 0010 0000 010m mrrr R update @@ -2132,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; } @@ -2140,20 +2160,18 @@ 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]); } static void dsp_pm_4(void) { char addr_name[16]; - uint32 value, retour, ea_mode, memspace; + Uint32 value, retour, ea_mode, memspace; /* 0100 l0ll w0aa aaaa l:aa,D S,l:aa @@ -2180,7 +2198,7 @@ static void dsp_pm_4(void) if (cur_inst & (1<<14)) { retour = dsp_calc_ea(ea_mode, addr_name); } else { - sprintf(addr_name,"0x%04x", value); + sprintf(addr_name,"0x%04x", ea_mode); retour = 0; } @@ -2190,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 { @@ -2218,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 { @@ -2235,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 { @@ -2252,7 +2266,7 @@ static void dsp_pm_4(void) static void dsp_pm_8(void) { char addr1_name[16], addr2_name[16]; - uint32 ea_mode1, ea_mode2, numreg1, numreg2; + Uint32 ea_mode1, ea_mode2, numreg1, numreg2; /* 1wmm eeff WrrM MRRR x:ea,D1 y:ea,D2 x:ea,D1 S2,y:ea @@ -2292,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], @@ -2311,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, @@ -2336,22 +2347,17 @@ static void dsp_pm_8(void) static void dsp_abs(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - fprintf(stderr,"Dsp: 0x%04x: abs %s %s\n", - dsp_pc, - registers_name[numreg], - parallelmove_name - ); + sprintf(str_instr,"abs %s %s", registers_name[numreg], parallelmove_name); } static void dsp_adc(void) { const char *srcname; - uint32 numreg; + Uint32 numreg; if (cur_inst & (1<<4)) { srcname="y"; @@ -2360,10 +2366,8 @@ static void dsp_adc(void) } numreg=DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - fprintf(stderr,"Dsp: 0x%04x: adc %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"adc %s,%s %s", srcname, registers_name[numreg], parallelmove_name @@ -2373,7 +2377,7 @@ static void dsp_adc(void) static void dsp_add(void) { const char *srcname; - uint32 srcreg, dstreg; + Uint32 srcreg, dstreg; srcreg = (cur_inst>>4) & BITMASK(3); dstreg = (cur_inst>>3) & 1; @@ -2389,20 +2393,24 @@ static void dsp_add(void) case 3: srcname="y"; break; - case DSP_REG_X0: - case DSP_REG_X1: - case DSP_REG_Y0: - case DSP_REG_Y1: - srcname=registers_name[srcreg]; + case 4: + srcname=registers_name[DSP_REG_X0]; + break; + case 5: + srcname=registers_name[DSP_REG_Y0]; + break; + case 6: + srcname=registers_name[DSP_REG_X1]; + break; + case 7: + srcname=registers_name[DSP_REG_Y1]; break; default: srcname=""; break; } - registers_changed[DSP_REG_A+dstreg]=1; - fprintf(stderr,"Dsp: 0x%04x: add %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"add %s,%s %s", srcname, registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -2411,13 +2419,11 @@ static void dsp_add(void) static void dsp_addl(void) { - uint32 numreg; + Uint32 numreg; numreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+numreg]=1; - fprintf(stderr,"Dsp: 0x%04x: addl %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"addl %s,%s %s", registers_name[DSP_REG_A+(numreg ^ 1)], registers_name[DSP_REG_A+numreg], parallelmove_name @@ -2426,13 +2432,11 @@ static void dsp_addl(void) static void dsp_addr(void) { - uint32 numreg; + Uint32 numreg; numreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+numreg]=1; - fprintf(stderr,"Dsp: 0x%04x: addr %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"addr %s,%s %s", registers_name[DSP_REG_A+(numreg ^ 1)], registers_name[DSP_REG_A+numreg], parallelmove_name @@ -2441,30 +2445,38 @@ static void dsp_addr(void) static void dsp_and(void) { - uint32 numreg; + Uint32 srcreg,dstreg; - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - registers_changed[numreg]=1; + switch((cur_inst>>4) & BITMASK(2)) { + case 1: + srcreg=DSP_REG_Y0; + break; + case 2: + srcreg=DSP_REG_X1; + break; + case 3: + srcreg=DSP_REG_Y1; + break; + case 0: + default: + srcreg=DSP_REG_X0; + } + dstreg = DSP_REG_A+((cur_inst>>3) & 1); - fprintf(stderr,"Dsp: 0x%04x: and %s,%s %s\n", - dsp_pc, - registers_name[DSP_REG_X0+((cur_inst>>4) & BITMASK(2))], - registers_name[numreg], + sprintf(str_instr,"and %s,%s %s", + registers_name[srcreg], + registers_name[dstreg], parallelmove_name ); } static void dsp_asl(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: asl %s %s\n", - dsp_pc, + sprintf(str_instr,"asl %s %s", registers_name[numreg], parallelmove_name ); @@ -2472,14 +2484,11 @@ static void dsp_asl(void) static void dsp_asr(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: asr %s %s\n", - dsp_pc, + sprintf(str_instr,"asr %s %s", registers_name[numreg], parallelmove_name ); @@ -2487,14 +2496,11 @@ static void dsp_asr(void) static void dsp_clr(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: clr %s %s\n", - dsp_pc, + sprintf(str_instr,"clr %s %s", registers_name[numreg], parallelmove_name ); @@ -2502,7 +2508,7 @@ static void dsp_clr(void) static void dsp_cmp(void) { - uint32 srcreg, dstreg; + Uint32 srcreg, dstreg; srcreg = (cur_inst>>4) & BITMASK(3); dstreg = (cur_inst>>3) & 1; @@ -2525,8 +2531,7 @@ static void dsp_cmp(void) break; } - fprintf(stderr,"Dsp: 0x%04x: cmp %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"cmp %s,%s %s", registers_name[srcreg], registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -2535,7 +2540,7 @@ static void dsp_cmp(void) static void dsp_cmpm(void) { - uint32 srcreg, dstreg; + Uint32 srcreg, dstreg; srcreg = (cur_inst>>4) & BITMASK(3); dstreg = (cur_inst>>3) & 1; @@ -2558,8 +2563,7 @@ static void dsp_cmpm(void) break; } - fprintf(stderr,"Dsp: 0x%04x: cmpm %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"cmpm %s,%s %s", registers_name[srcreg], registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -2568,30 +2572,38 @@ static void dsp_cmpm(void) static void dsp_eor(void) { - uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); + Uint32 srcreg, dstreg; - registers_changed[numreg]=1; + switch((cur_inst>>4) & BITMASK(2)) { + case 1: + srcreg=DSP_REG_Y0; + break; + case 2: + srcreg=DSP_REG_X1; + break; + case 3: + srcreg=DSP_REG_Y1; + break; + case 0: + default: + srcreg=DSP_REG_X0; + } + dstreg = DSP_REG_A+((cur_inst>>3) & 1); - fprintf(stderr,"Dsp: 0x%04x: eor %s,%s %s\n", - dsp_pc, - registers_name[DSP_REG_X0+((cur_inst>>4) & BITMASK(2))], - registers_name[numreg], + sprintf(str_instr,"eor %s,%s %s", + registers_name[srcreg], + registers_name[dstreg], parallelmove_name ); } static void dsp_lsl(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: lsl %s %s\n", - dsp_pc, + sprintf(str_instr,"lsl %s %s", registers_name[numreg], parallelmove_name ); @@ -2599,14 +2611,11 @@ static void dsp_lsl(void) static void dsp_lsr(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: lsr %s %s\n", - dsp_pc, + sprintf(str_instr,"lsr %s %s", registers_name[numreg], parallelmove_name ); @@ -2615,7 +2624,7 @@ static void dsp_lsr(void) static void dsp_mac(void) { const char *sign_name; - uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; + Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; if (cur_inst & (1<<2)) { sign_name="-"; @@ -2659,9 +2668,7 @@ static void dsp_mac(void) } dstreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+dstreg]=1; - fprintf(stderr,"Dsp: 0x%04x: mac %s%s,%s,%s %s\n", - dsp_pc, + sprintf(str_instr,"mac %s%s,%s,%s %s", sign_name, registers_name[src1reg], registers_name[src2reg], @@ -2673,7 +2680,7 @@ static void dsp_mac(void) static void dsp_macr(void) { const char *sign_name; - uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; + Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; if (cur_inst & (1<<2)) { sign_name="-"; @@ -2717,9 +2724,7 @@ static void dsp_macr(void) } dstreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+dstreg]=1; - fprintf(stderr,"Dsp: 0x%04x: macr %s%s,%s,%s %s\n", - dsp_pc, + sprintf(str_instr,"macr %s%s,%s,%s %s", sign_name, registers_name[src1reg], registers_name[src2reg], @@ -2730,19 +2735,13 @@ static void dsp_macr(void) static void dsp_move(void) { - fprintf(stderr,"Dsp: 0x%04x: move %s\n",dsp_pc, parallelmove_name); -} - -static void dsp_move_nopm(void) -{ - dsp_pm(); - fprintf(stderr,"Dsp: 0x%04x: move %s\n",dsp_pc, parallelmove_name); + sprintf(str_instr,"move %s", parallelmove_name); } static void dsp_mpy(void) { const char *sign_name; - uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; + Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; if (cur_inst & (1<<2)) { sign_name="-"; @@ -2786,9 +2785,7 @@ static void dsp_mpy(void) } dstreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+dstreg]=1; - fprintf(stderr,"Dsp: 0x%04x: mpy %s%s,%s,%s %s\n", - dsp_pc, + sprintf(str_instr,"mpy %s%s,%s,%s %s", sign_name, registers_name[src1reg], registers_name[src2reg], @@ -2800,7 +2797,7 @@ static void dsp_mpy(void) static void dsp_mpyr(void) { const char *sign_name; - uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; + Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; if (cur_inst & (1<<2)) { sign_name="-"; @@ -2844,9 +2841,7 @@ static void dsp_mpyr(void) } dstreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+dstreg]=1; - fprintf(stderr,"Dsp: 0x%04x: mpyr %s%s,%s,%s %s\n", - dsp_pc, + sprintf(str_instr,"mpyr %s%s,%s,%s %s", sign_name, registers_name[src1reg], registers_name[src2reg], @@ -2857,14 +2852,11 @@ static void dsp_mpyr(void) static void dsp_neg(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: neg %s %s\n", - dsp_pc, + sprintf(str_instr,"neg %s %s", registers_name[numreg], parallelmove_name ); @@ -2872,14 +2864,11 @@ static void dsp_neg(void) static void dsp_not(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: not %s %s\n", - dsp_pc, + sprintf(str_instr,"not %s %s", registers_name[numreg], parallelmove_name ); @@ -2887,30 +2876,38 @@ static void dsp_not(void) static void dsp_or(void) { - uint32 numreg; + Uint32 srcreg, dstreg; - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - registers_changed[numreg]=1; + switch((cur_inst>>4) & BITMASK(2)) { + case 1: + srcreg=DSP_REG_Y0; + break; + case 2: + srcreg=DSP_REG_X1; + break; + case 3: + srcreg=DSP_REG_Y1; + break; + case 0: + default: + srcreg=DSP_REG_X0; + } + dstreg = DSP_REG_A+((cur_inst>>3) & 1); - fprintf(stderr,"Dsp: 0x%04x: or %s,%s %s\n", - dsp_pc, - registers_name[DSP_REG_X0+((cur_inst>>4) & BITMASK(2))], - registers_name[numreg], + sprintf(str_instr,"or %s,%s %s", + registers_name[srcreg], + registers_name[dstreg], parallelmove_name ); } static void dsp_rnd(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: rnd %s %s\n", - dsp_pc, + sprintf(str_instr,"rnd %s %s", registers_name[numreg], parallelmove_name ); @@ -2918,14 +2915,11 @@ static void dsp_rnd(void) static void dsp_rol(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: rol %s %s\n", - dsp_pc, + sprintf(str_instr,"rol %s %s", registers_name[numreg], parallelmove_name ); @@ -2933,14 +2927,11 @@ static void dsp_rol(void) static void dsp_ror(void) { - uint32 numreg; + Uint32 numreg; numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: ror %s %s\n", - dsp_pc, + sprintf(str_instr,"ror %s %s", registers_name[numreg], parallelmove_name ); @@ -2949,7 +2940,7 @@ static void dsp_ror(void) static void dsp_sbc(void) { const char *srcname; - uint32 numreg; + Uint32 numreg; if (cur_inst & (1<<4)) { srcname="y"; @@ -2959,10 +2950,7 @@ static void dsp_sbc(void) numreg = DSP_REG_A+((cur_inst>>3) & 1); - registers_changed[numreg]=1; - - fprintf(stderr,"Dsp: 0x%04x: sbc %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"sbc %s,%s %s", srcname, registers_name[numreg], parallelmove_name @@ -2972,7 +2960,7 @@ static void dsp_sbc(void) static void dsp_sub(void) { const char *srcname; - uint32 srcreg, dstreg; + Uint32 srcreg, dstreg; srcreg = (cur_inst>>4) & BITMASK(3); dstreg = (cur_inst>>3) & 1; @@ -2988,20 +2976,24 @@ static void dsp_sub(void) case 3: srcname="y"; break; - case DSP_REG_X0: - case DSP_REG_X1: - case DSP_REG_Y0: - case DSP_REG_Y1: - srcname=registers_name[srcreg]; + case 4: + srcname=registers_name[DSP_REG_X0]; + break; + case 5: + srcname=registers_name[DSP_REG_Y0]; + break; + case 6: + srcname=registers_name[DSP_REG_X1]; + break; + case 7: + srcname=registers_name[DSP_REG_Y1]; break; default: srcname=""; break; } - registers_changed[DSP_REG_A+dstreg]=1; - fprintf(stderr,"Dsp: 0x%04x: sub %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"sub %s,%s %s", srcname, registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -3010,13 +3002,11 @@ static void dsp_sub(void) static void dsp_subl(void) { - uint32 numreg; + Uint32 numreg; numreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+numreg]=1; - fprintf(stderr,"Dsp: 0x%04x: subl %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"subl %s,%s %s", registers_name[DSP_REG_A+(numreg ^ 1)], registers_name[DSP_REG_A+numreg], parallelmove_name @@ -3025,13 +3015,11 @@ static void dsp_subl(void) static void dsp_subr(void) { - uint32 numreg; + Uint32 numreg; numreg = (cur_inst>>3) & 1; - registers_changed[DSP_REG_A+numreg]=1; - fprintf(stderr,"Dsp: 0x%04x: subr %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"subr %s,%s %s", registers_name[DSP_REG_A+(numreg ^ 1)], registers_name[DSP_REG_A+numreg], parallelmove_name @@ -3040,18 +3028,31 @@ static void dsp_subr(void) static void dsp_tfr(void) { - uint32 srcreg, dstreg; + Uint32 srcreg, dstreg; srcreg = (cur_inst>>4) & BITMASK(3); dstreg = (cur_inst>>3) & 1; - if (srcreg==0) { - srcreg = DSP_REG_A+(dstreg ^ 1); + switch(srcreg) { + case 4: + srcreg = DSP_REG_X0; + break; + case 5: + srcreg = DSP_REG_Y0; + break; + case 6: + srcreg = DSP_REG_X1; + break; + case 7: + srcreg = DSP_REG_Y1; + break; + case 0: + default: + srcreg = DSP_REG_A+(dstreg ^ 1); + break; } - registers_changed[DSP_REG_A+dstreg]=1; - fprintf(stderr,"Dsp: 0x%04x: tfr %s,%s %s\n", - dsp_pc, + sprintf(str_instr,"tfr %s,%s %s", registers_name[srcreg], registers_name[DSP_REG_A+dstreg], parallelmove_name @@ -3060,23 +3061,8 @@ static void dsp_tfr(void) static void dsp_tst(void) { - fprintf(stderr,"Dsp: 0x%04x: tst %s %s\n", - dsp_pc, + sprintf(str_instr,"tst %s %s", registers_name[DSP_REG_A+((cur_inst>>3) & 1)], parallelmove_name ); } - -/* - 2002-07-31:PM - BUG:pm_2 (register update) wrong calc of eamode - 2002-07-30:PM - FIX:output registers that have been written to - 2002-07-26:PM - BUG:added missing '\n' to disasm output - 2002-07-22:PM - FIX:disasm output changed from D(bug()) to fprintf() - 2002-07-19:PM - BUG:movec_b and movec_d operations permuted - BUG:pm_5: bad calc of address in [x|y]:aa addressing -*/