--- hatari/src/falcon/dsp_disasm.c 2019/04/09 08:48:45 1.1.1.4 +++ hatari/src/falcon/dsp_disasm.c 2019/04/09 08:54:34 1.1.1.8 @@ -24,12 +24,15 @@ #endif #include +#include +#include +#include #include "dsp_core.h" #include "dsp_cpu.h" #include "dsp_disasm.h" +#include "profile.h" -#define DEBUG 0 /* More disasm infos, if wanted */ #define DSP_DISASM_REG_PC 0 @@ -38,28 +41,29 @@ * Defines **********************************/ -#define BITMASK(x) ((1<<(x))-1) - /********************************** * Variables **********************************/ /* Current instruction */ static Uint32 cur_inst; -static Uint32 disasm_cur_inst_len; +static Uint16 disasm_cur_inst_len; static char str_instr[50]; -static char str_instr2[100]; +static char str_instr2[120]; static char parallelmove_name[64]; /* Previous instruction */ -static Uint32 prev_inst_pc = 0x10000; /* Init to an invalid value */ -static Uint16 isLooping = 0; +static Uint32 prev_inst_pc; +static bool isLooping; -static dsp_core_t *dsp_core; +/* Used to display dc instead of unknown instruction for illegal opcodes */ +static bool isInDisasmMode; -void dsp56k_disasm_init(dsp_core_t *my_dsp_core) +void dsp56k_disasm_init(void) { - dsp_core = my_dsp_core; + prev_inst_pc = 0x10000; /* Init to an invalid value */ + isLooping = false; + isInDisasmMode = false; } /********************************** @@ -190,40 +194,8 @@ static void dsp_pm_2(void); static void dsp_pm_4(void); static void dsp_pm_8(void); -/* Instructions with parallel moves */ -static void dsp_abs(void); -static void dsp_adc(void); -static void dsp_add(void); -static void dsp_addl(void); -static void dsp_addr(void); -static void dsp_and(void); -static void dsp_asl(void); -static void dsp_asr(void); -static void dsp_clr(void); -static void dsp_cmp(void); -static void dsp_cmpm(void); -static void dsp_eor(void); -static void dsp_lsl(void); -static void dsp_lsr(void); -static void dsp_mac(void); -static void dsp_macr(void); -static void dsp_move(void); -static void dsp_mpy(void); -static void dsp_mpyr(void); -static void dsp_neg(void); -static void dsp_not(void); -static void dsp_or(void); -static void dsp_rnd(void); -static void dsp_rol(void); -static void dsp_ror(void); -static void dsp_sbc(void); -static void dsp_sub(void); -static void dsp_subl(void); -static void dsp_subr(void); -static void dsp_tfr(void); -static void dsp_tst(void); -static dsp_emul_t opcodes8h[512]={ +static const 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, @@ -305,50 +277,51 @@ static dsp_emul_t opcodes8h[512]={ 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_alu[256]={ +static const char* 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, + "move" , "tfr b,a", "addr b,a", "tst a", "undefined", "cmp b,a" , "subr b,a", "cmpm b,a", + "undefined", "tfr a,b", "addr a,b", "tst b", "undefined", "cmp a,b" , "subr a,b", "cmpm a,b", + "add b,a" , "rnd a" , "addl b,a", "clr a", "sub b,a" , "undefined", "subl b,a", "not a", + "add a,b" , "rnd b" , "addl a,b", "clr b", "sub a,b" , "undefined", "subl a,b", "not b", + "add x,a" , "adc x,a", "asr a" , "lsr a", "sub x,a" , "sbc x,a" , "abs a" , "ror a", + "add x,b" , "adc x,b", "asr b" , "lsr b", "sub x,b" , "sbc x,b" , "abs b" , "ror b", + "add y,a" , "adc y,a", "asl a" , "lsl a", "sub y,a" , "sbc y,a" , "neg a" , "rol a", + "add y,b" , "adc y,b", "asl b" , "lsl b", "sub y,b" , "sbc y,b" , "neg b" , "rol b", /* 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, + "add x0,a", "tfr x0,a", "or x0,a", "eor x0,a", "sub x0,a", "cmp x0,a", "and x0,a", "cmpm x0,a", + "add x0,b", "tfr x0,b", "or x0,b", "eor x0,b", "sub x0,b", "cmp x0,b", "and x0,b", "cmpm x0,b", + "add y0,a", "tfr y0,a", "or y0,a", "eor y0,a", "sub y0,a", "cmp y0,a", "and y0,a", "cmpm y0,a", + "add y0,b", "tfr y0,b", "or y0,b", "eor y0,b", "sub y0,b", "cmp y0,b", "and y0,b", "cmpm y0,b", + "add x1,a", "tfr x1,a", "or x1,a", "eor x1,a", "sub x1,a", "cmp x1,a", "and x1,a", "cmpm x1,a", + "add x1,b", "tfr x1,b", "or x1,b", "eor x1,b", "sub x1,b", "cmp x1,b", "and x1,b", "cmpm x1,b", + "add y1,a", "tfr y1,a", "or y1,a", "eor y1,a", "sub y1,a", "cmp y1,a", "and y1,a", "cmpm y1,a", + "add y1,b", "tfr y1,b", "or y1,b", "eor y1,b", "sub y1,b", "cmp y1,b", "and y1,b", "cmpm y1,b", /* 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, + "mpy +x0,x0,a", "mpyr +x0,x0,a", "mac +x0,x0,a", "macr +x0,x0,a", "mpy -x0,x0,a", "mpyr -x0,x0,a", "mac -x0,x0,a", "macr -x0,x0,a", + "mpy +x0,x0,b", "mpyr +x0,x0,b", "mac +x0,x0,b", "macr +x0,x0,b", "mpy -x0,x0,b", "mpyr -x0,x0,b", "mac -x0,x0,b", "macr -x0,x0,b", + "mpy +y0,y0,a", "mpyr +y0,y0,a", "mac +y0,y0,a", "macr +y0,y0,a", "mpy -y0,y0,a", "mpyr -y0,y0,a", "mac -y0,y0,a", "macr -y0,y0,a", + "mpy +y0,y0,b", "mpyr +y0,y0,b", "mac +y0,y0,b", "macr +y0,y0,b", "mpy -y0,y0,b", "mpyr -y0,y0,b", "mac -y0,y0,b", "macr -y0,y0,b", + "mpy +x1,x0,a", "mpyr +x1,x0,a", "mac +x1,x0,a", "macr +x1,x0,a", "mpy -x1,x0,a", "mpyr -x1,x0,a", "mac -x1,x0,a", "macr -x1,x0,a", + "mpy +x1,x0,b", "mpyr +x1,x0,b", "mac +x1,x0,b", "macr +x1,x0,b", "mpy -x1,x0,b", "mpyr -x1,x0,b", "mac -x1,x0,b", "macr -x1,x0,b", + "mpy +y1,y0,a", "mpyr +y1,y0,a", "mac +y1,y0,a", "macr +y1,y0,a", "mpy -y1,y0,a", "mpyr -y1,y0,a", "mac -y1,y0,a", "macr -y1,y0,a", + "mpy +y1,y0,b", "mpyr +y1,y0,b", "mac +y1,y0,b", "macr +y1,y0,b", "mpy -y1,y0,b", "mpyr -y1,y0,b", "mac -y1,y0,b", "macr -y1,y0,b", /* 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 + "mpy +x0,y1,a", "mpyr +x0,y1,a", "mac +x0,y1,a", "macr +x0,y1,a", "mpy -x0,y1,a", "mpyr -x0,y1,a", "mac -x0,y1,a", "macr -x0,y1,a", + "mpy +x0,y1,b", "mpyr +x0,y1,b", "mac +x0,y1,b", "macr +x0,y1,b", "mpy -x0,y1,b", "mpyr -x0,y1,b", "mac -x0,y1,b", "macr -x0,y1,b", + "mpy +y0,x0,a", "mpyr +y0,x0,a", "mac +y0,x0,a", "macr +y0,x0,a", "mpy -y0,x0,a", "mpyr -y0,x0,a", "mac -y0,x0,a", "macr -y0,x0,a", + "mpy +y0,x0,b", "mpyr +y0,x0,b", "mac +y0,x0,b", "macr +y0,x0,b", "mpy -y0,x0,b", "mpyr -y0,x0,b", "mac -y0,x0,b", "macr -y0,x0,b", + "mpy +x1,y0,a", "mpyr +x1,y0,a", "mac +x1,y0,a", "macr +x1,y0,a", "mpy -x1,y0,a", "mpyr -x1,y0,a", "mac -x1,y0,a", "macr -x1,y0,a", + "mpy +x1,y0,b", "mpyr +x1,y0,b", "mac +x1,y0,b", "macr +x1,y0,b", "mpy -x1,y0,b", "mpyr -x1,y0,b", "mac -x1,y0,b", "macr -x1,y0,b", + "mpy +y1,x1,a", "mpyr +y1,x1,a", "mac +y1,x1,a", "macr +y1,x1,a", "mpy -y1,x1,a", "mpyr -y1,x1,a", "mac -y1,x1,a", "macr -y1,x1,a", + "mpy +y1,x1,b", "mpyr +y1,x1,b", "mac +y1,x1,b", "macr +y1,x1,b", "mpy -y1,x1,b", "mpyr -y1,x1,b", "mac -y1,x1,b", "macr -y1,x1,b" }; -static dsp_emul_t opcodes_parmove[16]={ + +static const dsp_emul_t opcodes_parmove[16] = { dsp_pm_0, dsp_pm_1, dsp_pm_2, @@ -368,7 +341,7 @@ static dsp_emul_t opcodes_parmove[16]={ dsp_pm_8 }; -static int registers_tcc[16][2]={ +static const int registers_tcc[16][2] = { {DSP_REG_B,DSP_REG_A}, {DSP_REG_A,DSP_REG_B}, {DSP_REG_NULL,DSP_REG_NULL}, @@ -390,7 +363,7 @@ static int registers_tcc[16][2]={ {DSP_REG_Y1,DSP_REG_B} }; -static const char *registers_lmove[8]={ +static const char *registers_lmove[8] = { "a10", "b10", "x", @@ -401,19 +374,19 @@ static const char *registers_lmove[8]={ "ba" }; -static const char *ea_names[9]={ +static const char *ea_names[9] = { "(r%d)-n%d", /* 000xxx */ "(r%d)+n%d", /* 001xxx */ "(r%d)-", /* 010xxx */ "(r%d)+", /* 011xxx */ "(r%d)", /* 100xxx */ "(r%d+n%d)", /* 101xxx */ - "0x%04x", /* 110000 */ + "$%04x", /* 110000 */ "-(r%d)", /* 111xxx */ - "0x%06x" /* 110100 */ + "$%06x" /* 110100 */ }; -static const char *cc_name[16]={ +static const char *cc_name[16] = { "cc", "ge", "ne", @@ -435,18 +408,20 @@ static const char *cc_name[16]={ void dsp56k_disasm_reg_save(void) { - memcpy(registers_save, dsp_core->registers , sizeof(registers_save)); + memcpy(registers_save, dsp_core.registers , sizeof(registers_save)); #if DSP_DISASM_REG_PC - pc_save = dsp_core->pc; + pc_save = dsp_core.pc; #endif } void dsp56k_disasm_reg_compare(void) { int i; + bool bRegA = false; + bool bRegB = false; - for (i=0; i<64; i++) { - if (registers_save[i] == dsp_core->registers[i]) { + for (i=4; i<64; i++) { + if (registers_save[i] == dsp_core.registers[i]) { continue; } @@ -455,11 +430,7 @@ void dsp56k_disasm_reg_compare(void) 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)); + fprintf(stderr,"\tReg: %s $%06x -> $%06x\n", registers_name[i], registers_save[i], dsp_core.registers[i]); break; case DSP_REG_R0: case DSP_REG_R1: @@ -488,52 +459,68 @@ void dsp56k_disasm_reg_compare(void) 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)); + fprintf(stderr,"\tReg: %s $%04x -> $%04x\n", registers_name[i], registers_save[i], dsp_core.registers[i]); 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)); + fprintf(stderr,"\tReg: %s $%02x -> $%02x\n", registers_name[i], registers_save[i], dsp_core.registers[i]); + break; + case DSP_REG_A0: + case DSP_REG_A1: + case DSP_REG_A2: + if (bRegA == false) { + fprintf(stderr,"\tReg: a $%02x:%06x:%06x -> $%02x:%06x:%06x\n", + registers_save[DSP_REG_A2], registers_save[DSP_REG_A1], registers_save[DSP_REG_A0], + dsp_core.registers[DSP_REG_A2], dsp_core.registers[DSP_REG_A1], dsp_core.registers[DSP_REG_A0] + ); + bRegA = true; + } 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) + case DSP_REG_B0: + case DSP_REG_B1: + case DSP_REG_B2: + if (bRegB == false) { + fprintf(stderr,"\tReg: b $%02x:%06x:%06x -> $%02x:%06x:%06x\n", + registers_save[DSP_REG_B2], registers_save[DSP_REG_B1], registers_save[DSP_REG_B0], + dsp_core.registers[DSP_REG_B2], dsp_core.registers[DSP_REG_B1], dsp_core.registers[DSP_REG_B0] ); + bRegB = true; } break; } } #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); + if (pc_save != dsp_core.pc) { + fprintf(stderr,"\tReg: pc $%04x -> $%04x\n", pc_save, dsp_core.pc); } #endif } -Uint16 dsp56k_disasm(void) +Uint16 dsp56k_disasm(dsp_trace_disasm_t mode) { Uint32 value; - if (prev_inst_pc == dsp_core->pc){ - isLooping = 1; - return 0; + if (mode == DSP_TRACE_MODE) { + isInDisasmMode = false; + if (prev_inst_pc == dsp_core.pc) { + if (!isLooping) { + fprintf(stderr, "Looping on DSP instruction at PC = $%04x\n", prev_inst_pc); + isLooping = true; + } + return 0; + } + } + else { + isInDisasmMode = true; } - prev_inst_pc = dsp_core->pc; - isLooping = 0; - cur_inst = read_memory(dsp_core->pc); + prev_inst_pc = dsp_core.pc; + isLooping = false; + + cur_inst = read_memory(dsp_core.pc); disasm_cur_inst_len = 1; strcpy(parallelmove_name, ""); @@ -544,8 +531,7 @@ Uint16 dsp56k_disasm(void) opcodes8h[value](); } else { dsp_pm(); - value = cur_inst & BITMASK(8); - opcodes_alu[value](); + sprintf(str_instr, "%s %s", opcodes_alu[cur_inst & BITMASK(8)], parallelmove_name); } return disasm_cur_inst_len; } @@ -553,27 +539,33 @@ Uint16 dsp56k_disasm(void) /** * dsp56k_getInstrText : return the disasembled instructions */ -char* dsp56k_getInstructionText(void) +const char* dsp56k_getInstructionText(void) { + const int len = sizeof(str_instr); + Uint64 count, cycles; + Uint16 cycle_diff; + float percentage; + int offset; + 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); + if (disasm_cur_inst_len == 1) { + offset = sprintf(str_instr2, "p:%04x %06x (%02d cyc) %-*s\n", prev_inst_pc, cur_inst, dsp_core.instr_cycle, len, str_instr); + } else { + offset = sprintf(str_instr2, "p:%04x %06x %06x (%02d cyc) %-*s\n", prev_inst_pc, cur_inst, read_memory(prev_inst_pc + 1), dsp_core.instr_cycle, len, str_instr); + } + if (offset > 2 && Profile_DspAddressData(prev_inst_pc, &percentage, &count, &cycles, &cycle_diff)) { + offset -= 2; + sprintf(str_instr2+offset, "%5.2f%% (%"PRId64", %"PRId64", %d)\n", + percentage, count, cycles, cycle_diff); } - return str_instr2; } static void dsp_pm_class2(void) { - Uint32 value; - dsp_pm(); - value = cur_inst & BITMASK(8); - opcodes_alu[value](); + sprintf(str_instr, "%s %s", opcodes_alu[cur_inst & BITMASK(8)], parallelmove_name); } static Uint32 read_memory(Uint32 currPc) @@ -581,9 +573,9 @@ static Uint32 read_memory(Uint32 currPc) Uint32 value; if (currPc<0x200) { - value = dsp_core->ramint[DSP_SPACE_P][currPc]; + value = dsp_core.ramint[DSP_SPACE_P][currPc]; } else { - value = dsp_core->ramext[currPc & (DSP_RAMSIZE-1)]; + value = dsp_core.ramext[currPc & (DSP_RAMSIZE-1)]; } return value & BITMASK(24); @@ -643,11 +635,11 @@ static int dsp_calc_ea(Uint32 ea_mode, c switch ((ea_mode >> 2) & 1) { case 0: /* Absolute address */ - sprintf(dest, ea_names[value], read_memory(dsp_core->pc+1)); + sprintf(dest, ea_names[value], read_memory(dsp_core.pc+1)); break; case 1: /* Immediate value */ - sprintf(dest, ea_names[8], read_memory(dsp_core->pc+1)); + sprintf(dest, ea_names[8], read_memory(dsp_core.pc+1)); retour = 1; break; } @@ -686,6 +678,9 @@ static void opcode8h_0(void) case 0x00008c: dsp_enddo(); break; + default: + dsp_undefined(); + break; } } @@ -695,20 +690,25 @@ static void opcode8h_0(void) static void dsp_undefined(void) { - sprintf(str_instr,"0x%06x unknown instruction", cur_inst); + /* In Disasm mode, display dc instruction_opcode */ + if (isInDisasmMode) + sprintf(str_instr, "dc $%06x", cur_inst); + /* In trace mode, display unknown instruction */ + else + sprintf(str_instr, "$%06x unknown instruction", cur_inst); } static void dsp_andi(void) { switch(cur_inst & BITMASK(2)) { case 0: - sprintf(str_instr, "andi #0x%02x,mr", (cur_inst>>8) & BITMASK(8)); + sprintf(str_instr, "andi #$%02x,mr", (cur_inst>>8) & BITMASK(8)); break; case 1: - sprintf(str_instr, "andi #0x%02x,ccr", (cur_inst>>8) & BITMASK(8)); + sprintf(str_instr, "andi #$%02x,ccr", (cur_inst>>8) & BITMASK(8)); break; case 2: - sprintf(str_instr, "andi #0x%02x,omr", (cur_inst>>8) & BITMASK(8)); + sprintf(str_instr, "andi #$%02x,omr", (cur_inst>>8) & BITMASK(8)); break; default: break; @@ -727,9 +727,9 @@ static void dsp_bchg_aa(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(name,"y:0x%04x",value); + sprintf(name,"y:$%04x",value); } else { - sprintf(name,"x:0x%04x",value); + sprintf(name,"x:$%04x",value); } sprintf(str_instr,"bchg #%d,%s", numbit, name); @@ -768,9 +768,9 @@ static void dsp_bchg_pp(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(name,"y:0x%04x",value+0xffc0); + sprintf(name,"y:$%04x",value+0xffc0); } else { - sprintf(name,"x:0x%04x",value+0xffc0); + sprintf(name,"x:$%04x",value+0xffc0); } sprintf(str_instr,"bchg #%d,%s", numbit, name); @@ -799,9 +799,9 @@ static void dsp_bclr_aa(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(name,"y:0x%04x",value); + sprintf(name,"y:$%04x",value); } else { - sprintf(name,"x:0x%04x",value); + sprintf(name,"x:$%04x",value); } sprintf(str_instr,"bclr #%d,%s", numbit, name); @@ -840,9 +840,9 @@ static void dsp_bclr_pp(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(name,"y:0x%04x",value+0xffc0); + sprintf(name,"y:$%04x",value+0xffc0); } else { - sprintf(name,"x:0x%04x",value+0xffc0); + sprintf(name,"x:$%04x",value+0xffc0); } sprintf(str_instr,"bclr #%d,%s", numbit, name); @@ -871,9 +871,9 @@ static void dsp_bset_aa(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(name,"y:0x%04x",value); + sprintf(name,"y:$%04x",value); } else { - sprintf(name,"x:0x%04x",value); + sprintf(name,"x:$%04x",value); } sprintf(str_instr,"bset #%d,%s", numbit, name); @@ -912,9 +912,9 @@ static void dsp_bset_pp(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(name,"y:0x%04x",value+0xffc0); + sprintf(name,"y:$%04x",value+0xffc0); } else { - sprintf(name,"x:0x%04x",value+0xffc0); + sprintf(name,"x:$%04x",value+0xffc0); } sprintf(str_instr,"bset #%d,%s", numbit, name); @@ -943,9 +943,9 @@ static void dsp_btst_aa(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(name,"y:0x%04x",value); + sprintf(name,"y:$%04x",value); } else { - sprintf(name,"x:0x%04x",value); + sprintf(name,"x:$%04x",value); } sprintf(str_instr,"btst #%d,%s", numbit, name); @@ -984,9 +984,9 @@ static void dsp_btst_pp(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(name,"y:0x%04x",value+0xffc0); + sprintf(name,"y:$%04x",value+0xffc0); } else { - sprintf(name,"x:0x%04x",value+0xffc0); + sprintf(name,"x:$%04x",value+0xffc0); } sprintf(str_instr,"btst #%d,%s", numbit, name); @@ -1033,14 +1033,14 @@ static void dsp_do_aa(void) disasm_cur_inst_len++; if (cur_inst & (1<<6)) { - sprintf(name, "y:0x%04x", (cur_inst>>8) & BITMASK(6)); + sprintf(name, "y:$%04x", (cur_inst>>8) & BITMASK(6)); } else { - sprintf(name, "x:0x%04x", (cur_inst>>8) & BITMASK(6)); + sprintf(name, "x:$%04x", (cur_inst>>8) & BITMASK(6)); } - sprintf(str_instr,"do %s,p:0x%04x", + sprintf(str_instr,"do %s,p:$%04x", name, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1048,9 +1048,9 @@ static void dsp_do_imm(void) { disasm_cur_inst_len++; - sprintf(str_instr,"do #0x%04x,p:0x%04x", + sprintf(str_instr,"do #$%04x,p:$%04x", ((cur_inst>>8) & BITMASK(8))|((cur_inst & BITMASK(4))<<8), - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1070,9 +1070,9 @@ static void dsp_do_ea(void) sprintf(name, "x:%s", addr_name); } - sprintf(str_instr,"do %s,p:0x%04x", + sprintf(str_instr,"do %s,p:$%04x", name, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1080,9 +1080,9 @@ static void dsp_do_reg(void) { disasm_cur_inst_len++; - sprintf(str_instr,"do %s,p:0x%04x", + sprintf(str_instr,"do %s,p:$%04x", registers_name[(cur_inst>>8) & BITMASK(6)], - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1113,7 +1113,7 @@ 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)); + sprintf(addr_name, "$%04x", cur_inst & BITMASK(12)); cc_code=(cur_inst>>12) & BITMASK(4); dsp_calc_cc(cc_code, cond_name); @@ -1134,15 +1134,15 @@ static void dsp_jclr_aa(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(srcname, "y:0x%04x", value); + sprintf(srcname, "y:$%04x", value); } else { - sprintf(srcname, "x:0x%04x", value); + sprintf(srcname, "x:$%04x", value); } - sprintf(str_instr,"jclr #%d,%s,p:0x%04x", + sprintf(str_instr,"jclr #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1166,10 +1166,10 @@ static void dsp_jclr_ea(void) sprintf(srcname, "x:%s", addr_name); } - sprintf(str_instr,"jclr #%d,%s,p:0x%04x", + sprintf(str_instr,"jclr #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1188,15 +1188,15 @@ static void dsp_jclr_pp(void) value += 0xffc0; if (memspace) { - sprintf(srcname, "y:0x%04x", value); + sprintf(srcname, "y:$%04x", value); } else { - sprintf(srcname, "x:0x%04x", value); + sprintf(srcname, "x:$%04x", value); } - sprintf(str_instr,"jclr #%d,%s,p:0x%04x", + sprintf(str_instr,"jclr #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1210,16 +1210,16 @@ static void dsp_jclr_reg(void) value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - sprintf(str_instr,"jclr #%d,%s,p:0x%04x", + sprintf(str_instr,"jclr #%d,%s,p:$%04x", numbit, registers_name[value], - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } static void dsp_jmp_imm(void) { - sprintf(str_instr,"jmp p:0x%04x", cur_inst & BITMASK(12)); + sprintf(str_instr,"jmp p:$%04x", cur_inst & BITMASK(12)); } static void dsp_jmp_ea(void) @@ -1248,7 +1248,7 @@ 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)); + sprintf(addr_name, "$%04x", cur_inst & BITMASK(12)); cc_code=(cur_inst>>12) & BITMASK(4); dsp_calc_cc(cc_code, cond_name); @@ -1269,15 +1269,15 @@ static void dsp_jsclr_aa(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(srcname, "y:0x%04x", value); + sprintf(srcname, "y:$%04x", value); } else { - sprintf(srcname, "x:0x%04x", value); + sprintf(srcname, "x:$%04x", value); } - sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", + sprintf(str_instr,"jsclr #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1301,10 +1301,10 @@ static void dsp_jsclr_ea(void) sprintf(srcname, "x:%s", addr_name); } - sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", + sprintf(str_instr,"jsclr #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1323,15 +1323,15 @@ static void dsp_jsclr_pp(void) value += 0xffc0; if (memspace) { - sprintf(srcname, "y:0x%04x", value); + sprintf(srcname, "y:$%04x", value); } else { - sprintf(srcname, "x:0x%04x", value); + sprintf(srcname, "x:$%04x", value); } - sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", + sprintf(str_instr,"jsclr #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1345,10 +1345,10 @@ static void dsp_jsclr_reg(void) value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - sprintf(str_instr,"jsclr #%d,%s,p:0x%04x", + sprintf(str_instr,"jsclr #%d,%s,p:$%04x", numbit, registers_name[value], - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1366,15 +1366,15 @@ static void dsp_jset_aa(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(srcname, "y:0x%04x", value); + sprintf(srcname, "y:$%04x", value); } else { - sprintf(srcname, "x:0x%04x", value); + sprintf(srcname, "x:$%04x", value); } - sprintf(str_instr,"jset #%d,%s,p:0x%04x", + sprintf(str_instr,"jset #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1398,10 +1398,10 @@ static void dsp_jset_ea(void) sprintf(srcname, "x:%s", addr_name); } - sprintf(str_instr,"jset #%d,%s,p:0x%04x", + sprintf(str_instr,"jset #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1420,15 +1420,15 @@ static void dsp_jset_pp(void) value += 0xffc0; if (memspace) { - sprintf(srcname, "y:0x%04x", value); + sprintf(srcname, "y:$%04x", value); } else { - sprintf(srcname, "x:0x%04x", value); + sprintf(srcname, "x:$%04x", value); } - sprintf(str_instr,"jset #%d,%s,p:0x%04x", + sprintf(str_instr,"jset #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1442,16 +1442,16 @@ static void dsp_jset_reg(void) value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - sprintf(str_instr,"jset #%d,%s,p:0x%04x", + sprintf(str_instr,"jset #%d,%s,p:$%04x", numbit, registers_name[value], - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } static void dsp_jsr_imm(void) { - sprintf(str_instr,"jsr p:0x%04x", cur_inst & BITMASK(12)); + sprintf(str_instr,"jsr p:$%04x", cur_inst & BITMASK(12)); } static void dsp_jsr_ea(void) @@ -1477,15 +1477,15 @@ static void dsp_jsset_aa(void) numbit = cur_inst & BITMASK(5); if (memspace) { - sprintf(srcname, "y:0x%04x", value); + sprintf(srcname, "y:$%04x", value); } else { - sprintf(srcname, "x:0x%04x", value); + sprintf(srcname, "x:$%04x", value); } - sprintf(str_instr,"jsset #%d,%s,p:0x%04x", + sprintf(str_instr,"jsset #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1509,10 +1509,10 @@ static void dsp_jsset_ea(void) sprintf(srcname, "x:%s", addr_name); } - sprintf(str_instr,"jsset #%d,%s,p:0x%04x", + sprintf(str_instr,"jsset #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1531,15 +1531,15 @@ static void dsp_jsset_pp(void) value += 0xffc0; if (memspace) { - sprintf(srcname, "y:0x%04x", value); + sprintf(srcname, "y:$%04x", value); } else { - sprintf(srcname, "x:0x%04x", value); + sprintf(srcname, "x:$%04x", value); } - sprintf(str_instr,"jsset #%d,%s,p:0x%04x", + sprintf(str_instr,"jsset #%d,%s,p:$%04x", numbit, srcname, - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1553,10 +1553,10 @@ static void dsp_jsset_reg(void) value = (cur_inst>>8) & BITMASK(6); numbit = cur_inst & BITMASK(5); - sprintf(str_instr,"jsset #%d,%s,p:0x%04x", + sprintf(str_instr,"jsset #%d,%s,p:$%04x", numbit, registers_name[value], - read_memory(dsp_core->pc+1) + read_memory(dsp_core.pc+1) ); } @@ -1567,7 +1567,10 @@ static void dsp_lua(void) 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); + if (cur_inst & (1<<3)) + sprintf(str_instr,"lua %s,n%d", addr_name, numreg); + else + sprintf(str_instr,"lua %s,r%d", addr_name, numreg); } static void dsp_movec_reg(void) @@ -1611,12 +1614,12 @@ static void dsp_movec_aa(void) if (cur_inst & (1<<15)) { /* Write D1 */ - sprintf(srcname, "%s:0x%04x", spacename, addr); + sprintf(srcname, "%s:$%04x", spacename, addr); strcpy(dstname, registers_name[numreg]); } else { /* Read S1 */ strcpy(srcname, registers_name[numreg]); - sprintf(dstname, "%s:0x%04x", spacename, addr); + sprintf(dstname, "%s:$%04x", spacename, addr); } sprintf(str_instr,"movec %s,%s", srcname, dstname); @@ -1630,7 +1633,7 @@ static void dsp_movec_imm(void) numreg = cur_inst & BITMASK(6); - sprintf(str_instr,"movec #0x%02x,%s", (cur_inst>>8) & BITMASK(8), registers_name[numreg]); + sprintf(str_instr,"movec #$%02x,%s", (cur_inst>>8) & BITMASK(8), registers_name[numreg]); } static void dsp_movec_ea(void) @@ -1680,7 +1683,7 @@ static void dsp_movem_aa(void) char addr_name[16], srcname[16], dstname[16]; Uint32 numreg; - sprintf(addr_name, "0x%04x",(cur_inst>>8) & BITMASK(6)); + sprintf(addr_name, "$%04x",(cur_inst>>8) & BITMASK(6)); numreg = cur_inst & BITMASK(6); if (cur_inst & (1<<15)) { /* Write D */ @@ -1738,17 +1741,17 @@ static void dsp_movep_0(void) strcpy(srcname, registers_name[numreg]); if (memspace) { - sprintf(dstname, "y:0x%04x", addr); + sprintf(dstname, "y:$%04x", addr); } else { - sprintf(dstname, "x:0x%04x", addr); + sprintf(dstname, "x:$%04x", addr); } } else { /* Read pp */ if (memspace) { - sprintf(srcname, "y:0x%04x", addr); + sprintf(srcname, "y:$%04x", addr); } else { - sprintf(srcname, "x:0x%04x", addr); + sprintf(srcname, "x:$%04x", addr); } strcpy(dstname, registers_name[numreg]); @@ -1777,17 +1780,17 @@ static void dsp_movep_1(void) sprintf(srcname, "p:%s", name); if (memspace) { - sprintf(dstname, "y:0x%04x", addr); + sprintf(dstname, "y:$%04x", addr); } else { - sprintf(dstname, "x:0x%04x", addr); + sprintf(dstname, "x:$%04x", addr); } } else { /* Read pp */ if (memspace) { - sprintf(srcname, "y:0x%04x", addr); + sprintf(srcname, "y:$%04x", addr); } else { - sprintf(srcname, "x:0x%04x", addr); + sprintf(srcname, "x:$%04x", addr); } sprintf(dstname, "p:%s", name); @@ -1832,17 +1835,17 @@ static void dsp_movep_23(void) } if (memspace) { - sprintf(dstname, "y:0x%04x", addr); + sprintf(dstname, "y:$%04x", addr); } else { - sprintf(dstname, "x:0x%04x", addr); + sprintf(dstname, "x:$%04x", addr); } } else { /* Read pp */ if (memspace) { - sprintf(srcname, "y:0x%04x", addr); + sprintf(srcname, "y:$%04x", addr); } else { - sprintf(srcname, "x:0x%04x", addr); + sprintf(srcname, "x:$%04x", addr); } if (easpace) { @@ -1874,13 +1877,13 @@ static void dsp_ori(void) { switch(cur_inst & BITMASK(2)) { case 0: - sprintf(str_instr,"ori #0x%02x,mr", (cur_inst>>8) & BITMASK(8)); + sprintf(str_instr,"ori #$%02x,mr", (cur_inst>>8) & BITMASK(8)); break; case 1: - sprintf(str_instr,"ori #0x%02x,ccr", (cur_inst>>8) & BITMASK(8)); + sprintf(str_instr,"ori #$%02x,ccr", (cur_inst>>8) & BITMASK(8)); break; case 2: - sprintf(str_instr,"ori #0x%02x,omr", (cur_inst>>8) & BITMASK(8)); + sprintf(str_instr,"ori #$%02x,omr", (cur_inst>>8) & BITMASK(8)); break; default: break; @@ -1896,9 +1899,9 @@ static void dsp_rep_aa(void) /* y:aa */ if (cur_inst & (1<<6)) { - sprintf(name, "y:0x%04x",(cur_inst>>8) & BITMASK(6)); + sprintf(name, "y:$%04x",(cur_inst>>8) & BITMASK(6)); } else { - sprintf(name, "x:0x%04x",(cur_inst>>8) & BITMASK(6)); + sprintf(name, "x:$%04x",(cur_inst>>8) & BITMASK(6)); } sprintf(str_instr,"rep %s", name); @@ -1907,7 +1910,7 @@ static void dsp_rep_aa(void) static void dsp_rep_imm(void) { /* #xxx */ - sprintf(str_instr,"rep #0x%02x", ((cur_inst>>8) & BITMASK(8)) + sprintf(str_instr,"rep #$%02x", ((cur_inst>>8) & BITMASK(8)) + ((cur_inst & BITMASK(4))<<8)); } @@ -1970,8 +1973,8 @@ static void dsp_tcc(void) dst1reg = registers_tcc[(cur_inst>>3) & BITMASK(4)][1]; if (cur_inst & (1<<16)) { - src2reg = DSP_REG_R0+(cur_inst & BITMASK(3)); - dst2reg = DSP_REG_R0+((cur_inst>>8) & BITMASK(3)); + src2reg = DSP_REG_R0+((cur_inst>>8) & BITMASK(3)); + dst2reg = DSP_REG_R0+(cur_inst & BITMASK(3)); sprintf(str_instr,"t%s %s,%s %s,%s", ccname, @@ -2165,7 +2168,7 @@ static void dsp_pm_2(void) } numreg1 = (cur_inst>>16) & BITMASK(5); - sprintf(parallelmove_name, "#0x%02x,%s", (cur_inst >> 8) & BITMASK(8), registers_name[numreg1]); + sprintf(parallelmove_name, "#$%02x,%s", (cur_inst >> 8) & BITMASK(8), registers_name[numreg1]); } static void dsp_pm_4(void) @@ -2198,7 +2201,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", ea_mode); + sprintf(addr_name,"$%04x", ea_mode); retour = 0; } @@ -2225,7 +2228,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", ea_mode); + sprintf(addr_name,"$%04x", ea_mode); retour = 0; } @@ -2339,730 +2342,3 @@ static void dsp_pm_8(void) } } } - - -/********************************** - * Parallel moves ALU instructions - **********************************/ - -static void dsp_abs(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"abs %s %s", registers_name[numreg], parallelmove_name); -} - -static void dsp_adc(void) -{ - const char *srcname; - Uint32 numreg; - - if (cur_inst & (1<<4)) { - srcname="y"; - } else { - srcname="x"; - } - - numreg=DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"adc %s,%s %s", - srcname, - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_add(void) -{ - const char *srcname; - Uint32 srcreg, dstreg; - - srcreg = (cur_inst>>4) & BITMASK(3); - dstreg = (cur_inst>>3) & 1; - - switch(srcreg) { - case 1: - srcreg = dstreg ^ 1; - srcname = registers_name[DSP_REG_A+srcreg]; - break; - case 2: - srcname="x"; - break; - case 3: - srcname="y"; - break; - 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; - } - - sprintf(str_instr,"add %s,%s %s", - srcname, - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_addl(void) -{ - Uint32 numreg; - - numreg = (cur_inst>>3) & 1; - - sprintf(str_instr,"addl %s,%s %s", - registers_name[DSP_REG_A+(numreg ^ 1)], - registers_name[DSP_REG_A+numreg], - parallelmove_name - ); -} - -static void dsp_addr(void) -{ - Uint32 numreg; - - numreg = (cur_inst>>3) & 1; - - sprintf(str_instr,"addr %s,%s %s", - registers_name[DSP_REG_A+(numreg ^ 1)], - registers_name[DSP_REG_A+numreg], - parallelmove_name - ); -} - -static void dsp_and(void) -{ - Uint32 srcreg,dstreg; - - 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); - - sprintf(str_instr,"and %s,%s %s", - registers_name[srcreg], - registers_name[dstreg], - parallelmove_name - ); -} - -static void dsp_asl(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"asl %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_asr(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"asr %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_clr(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"clr %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_cmp(void) -{ - Uint32 srcreg, dstreg; - - srcreg = (cur_inst>>4) & BITMASK(3); - dstreg = (cur_inst>>3) & 1; - - switch(srcreg) { - case 0: - srcreg = DSP_REG_A+(dstreg ^ 1); - break; - 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; - } - - sprintf(str_instr,"cmp %s,%s %s", - registers_name[srcreg], - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_cmpm(void) -{ - Uint32 srcreg, dstreg; - - srcreg = (cur_inst>>4) & BITMASK(3); - dstreg = (cur_inst>>3) & 1; - - switch(srcreg) { - case 0: - srcreg = DSP_REG_A+(dstreg ^ 1); - break; - 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; - } - - sprintf(str_instr,"cmpm %s,%s %s", - registers_name[srcreg], - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_eor(void) -{ - Uint32 srcreg, dstreg; - - 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); - - sprintf(str_instr,"eor %s,%s %s", - registers_name[srcreg], - registers_name[dstreg], - parallelmove_name - ); -} - -static void dsp_lsl(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"lsl %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_lsr(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"lsr %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_mac(void) -{ - const char *sign_name; - Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; - - if (cur_inst & (1<<2)) { - sign_name="-"; - } else { - sign_name=""; - } - - switch((cur_inst>>4) & BITMASK(3)) { - case 0: - src1reg = DSP_REG_X0; - src2reg = DSP_REG_X0; - break; - case 1: - src1reg = DSP_REG_Y0; - src2reg = DSP_REG_Y0; - break; - case 2: - src1reg = DSP_REG_X1; - src2reg = DSP_REG_X0; - break; - case 3: - src1reg = DSP_REG_Y1; - src2reg = DSP_REG_Y0; - break; - case 4: - src1reg = DSP_REG_X0; - src2reg = DSP_REG_Y1; - break; - case 5: - src1reg = DSP_REG_Y0; - src2reg = DSP_REG_X0; - break; - case 6: - src1reg = DSP_REG_X1; - src2reg = DSP_REG_Y0; - break; - case 7: - src1reg = DSP_REG_Y1; - src2reg = DSP_REG_X1; - break; - } - dstreg = (cur_inst>>3) & 1; - - sprintf(str_instr,"mac %s%s,%s,%s %s", - sign_name, - registers_name[src1reg], - registers_name[src2reg], - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_macr(void) -{ - const char *sign_name; - Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; - - if (cur_inst & (1<<2)) { - sign_name="-"; - } else { - sign_name=""; - } - - switch((cur_inst>>4) & BITMASK(3)) { - case 0: - src1reg = DSP_REG_X0; - src2reg = DSP_REG_X0; - break; - case 1: - src1reg = DSP_REG_Y0; - src2reg = DSP_REG_Y0; - break; - case 2: - src1reg = DSP_REG_X1; - src2reg = DSP_REG_X0; - break; - case 3: - src1reg = DSP_REG_Y1; - src2reg = DSP_REG_Y0; - break; - case 4: - src1reg = DSP_REG_X0; - src2reg = DSP_REG_Y1; - break; - case 5: - src1reg = DSP_REG_Y0; - src2reg = DSP_REG_X0; - break; - case 6: - src1reg = DSP_REG_X1; - src2reg = DSP_REG_Y0; - break; - case 7: - src1reg = DSP_REG_Y1; - src2reg = DSP_REG_X1; - break; - } - dstreg = (cur_inst>>3) & 1; - - sprintf(str_instr,"macr %s%s,%s,%s %s", - sign_name, - registers_name[src1reg], - registers_name[src2reg], - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_move(void) -{ - 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; - - if (cur_inst & (1<<2)) { - sign_name="-"; - } else { - sign_name=""; - } - - switch((cur_inst>>4) & BITMASK(3)) { - case 0: - src1reg = DSP_REG_X0; - src2reg = DSP_REG_X0; - break; - case 1: - src1reg = DSP_REG_Y0; - src2reg = DSP_REG_Y0; - break; - case 2: - src1reg = DSP_REG_X1; - src2reg = DSP_REG_X0; - break; - case 3: - src1reg = DSP_REG_Y1; - src2reg = DSP_REG_Y0; - break; - case 4: - src1reg = DSP_REG_X0; - src2reg = DSP_REG_Y1; - break; - case 5: - src1reg = DSP_REG_Y0; - src2reg = DSP_REG_X0; - break; - case 6: - src1reg = DSP_REG_X1; - src2reg = DSP_REG_Y0; - break; - case 7: - src1reg = DSP_REG_Y1; - src2reg = DSP_REG_X1; - break; - } - dstreg = (cur_inst>>3) & 1; - - sprintf(str_instr,"mpy %s%s,%s,%s %s", - sign_name, - registers_name[src1reg], - registers_name[src2reg], - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_mpyr(void) -{ - const char *sign_name; - Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg; - - if (cur_inst & (1<<2)) { - sign_name="-"; - } else { - sign_name=""; - } - - switch((cur_inst>>4) & BITMASK(3)) { - case 0: - src1reg = DSP_REG_X0; - src2reg = DSP_REG_X0; - break; - case 1: - src1reg = DSP_REG_Y0; - src2reg = DSP_REG_Y0; - break; - case 2: - src1reg = DSP_REG_X1; - src2reg = DSP_REG_X0; - break; - case 3: - src1reg = DSP_REG_Y1; - src2reg = DSP_REG_Y0; - break; - case 4: - src1reg = DSP_REG_X0; - src2reg = DSP_REG_Y1; - break; - case 5: - src1reg = DSP_REG_Y0; - src2reg = DSP_REG_X0; - break; - case 6: - src1reg = DSP_REG_X1; - src2reg = DSP_REG_Y0; - break; - case 7: - src1reg = DSP_REG_Y1; - src2reg = DSP_REG_X1; - break; - } - dstreg = (cur_inst>>3) & 1; - - sprintf(str_instr,"mpyr %s%s,%s,%s %s", - sign_name, - registers_name[src1reg], - registers_name[src2reg], - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_neg(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"neg %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_not(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"not %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_or(void) -{ - Uint32 srcreg, dstreg; - - 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); - - sprintf(str_instr,"or %s,%s %s", - registers_name[srcreg], - registers_name[dstreg], - parallelmove_name - ); -} - -static void dsp_rnd(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"rnd %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_rol(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"rol %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_ror(void) -{ - Uint32 numreg; - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"ror %s %s", - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_sbc(void) -{ - const char *srcname; - Uint32 numreg; - - if (cur_inst & (1<<4)) { - srcname="y"; - } else { - srcname="x"; - } - - numreg = DSP_REG_A+((cur_inst>>3) & 1); - - sprintf(str_instr,"sbc %s,%s %s", - srcname, - registers_name[numreg], - parallelmove_name - ); -} - -static void dsp_sub(void) -{ - const char *srcname; - Uint32 srcreg, dstreg; - - srcreg = (cur_inst>>4) & BITMASK(3); - dstreg = (cur_inst>>3) & 1; - - switch(srcreg) { - case 1: - srcreg = dstreg ^ 1; - srcname = registers_name[DSP_REG_A+srcreg]; - break; - case 2: - srcname="x"; - break; - case 3: - srcname="y"; - break; - 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; - } - - sprintf(str_instr,"sub %s,%s %s", - srcname, - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_subl(void) -{ - Uint32 numreg; - - numreg = (cur_inst>>3) & 1; - - sprintf(str_instr,"subl %s,%s %s", - registers_name[DSP_REG_A+(numreg ^ 1)], - registers_name[DSP_REG_A+numreg], - parallelmove_name - ); -} - -static void dsp_subr(void) -{ - Uint32 numreg; - - numreg = (cur_inst>>3) & 1; - - sprintf(str_instr,"subr %s,%s %s", - registers_name[DSP_REG_A+(numreg ^ 1)], - registers_name[DSP_REG_A+numreg], - parallelmove_name - ); -} - -static void dsp_tfr(void) -{ - Uint32 srcreg, dstreg; - - srcreg = (cur_inst>>4) & BITMASK(3); - dstreg = (cur_inst>>3) & 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; - } - - sprintf(str_instr,"tfr %s,%s %s", - registers_name[srcreg], - registers_name[DSP_REG_A+dstreg], - parallelmove_name - ); -} - -static void dsp_tst(void) -{ - sprintf(str_instr,"tst %s %s", - registers_name[DSP_REG_A+((cur_inst>>3) & 1)], - parallelmove_name - ); -}