--- hatari/src/falcon/dsp_disasm.c 2019/04/09 08:52:09 1.1.1.6 +++ hatari/src/falcon/dsp_disasm.c 2019/04/09 08:57:00 1.1.1.9 @@ -24,7 +24,9 @@ #endif #include +#include #include +#include #include "dsp_core.h" #include "dsp_cpu.h" @@ -412,7 +414,7 @@ void dsp56k_disasm_reg_save(void) #endif } -void dsp56k_disasm_reg_compare(void) +void dsp56k_disasm_reg_compare(FILE *fp) { int i; bool bRegA = false; @@ -428,7 +430,7 @@ void dsp56k_disasm_reg_compare(void) case DSP_REG_X1: case DSP_REG_Y0: case DSP_REG_Y1: - fprintf(stderr,"\tReg: %s $%06x -> $%06x\n", registers_name[i], registers_save[i], dsp_core.registers[i]); + fprintf(fp, "\tReg: %s $%06x -> $%06x\n", registers_name[i], registers_save[i], dsp_core.registers[i]); break; case DSP_REG_R0: case DSP_REG_R1: @@ -457,19 +459,19 @@ void dsp56k_disasm_reg_compare(void) case DSP_REG_SR: case DSP_REG_LA: case DSP_REG_LC: - fprintf(stderr,"\tReg: %s $%04x -> $%04x\n", registers_name[i], registers_save[i], dsp_core.registers[i]); + fprintf(fp, "\tReg: %s $%04x -> $%04x\n", registers_name[i], registers_save[i], dsp_core.registers[i]); break; case DSP_REG_OMR: case DSP_REG_SP: case DSP_REG_SSH: case DSP_REG_SSL: - fprintf(stderr,"\tReg: %s $%02x -> $%02x\n", registers_name[i], registers_save[i], dsp_core.registers[i]); + fprintf(fp, "\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", + fprintf(fp, "\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] ); @@ -480,7 +482,7 @@ void dsp56k_disasm_reg_compare(void) case DSP_REG_B1: case DSP_REG_B2: if (bRegB == false) { - fprintf(stderr,"\tReg: b $%02x:%06x:%06x -> $%02x:%06x:%06x\n", + fprintf(fp, "\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] ); @@ -492,12 +494,12 @@ void dsp56k_disasm_reg_compare(void) #if DSP_DISASM_REG_PC if (pc_save != dsp_core.pc) { - fprintf(stderr,"\tReg: pc $%04x -> $%04x\n", pc_save, dsp_core.pc); + fprintf(fp, "\tReg: pc $%04x -> $%04x\n", pc_save, dsp_core.pc); } #endif } -Uint16 dsp56k_disasm(dsp_trace_disasm_t mode) +Uint16 dsp56k_disasm(dsp_trace_disasm_t mode, FILE *fp) { Uint32 value; @@ -505,7 +507,7 @@ Uint16 dsp56k_disasm(dsp_trace_disasm_t isInDisasmMode = false; if (prev_inst_pc == dsp_core.pc) { if (!isLooping) { - fprintf(stderr, "Looping on DSP instruction at PC = $%04x\n", prev_inst_pc); + fprintf(fp, "Looping on DSP instruction at PC = $%04x\n", prev_inst_pc); isLooping = true; } return 0; @@ -540,7 +542,9 @@ Uint16 dsp56k_disasm(dsp_trace_disasm_t const char* dsp56k_getInstructionText(void) { const int len = sizeof(str_instr); - Uint32 count, cycles; + Uint64 count, cycles; + Uint16 cycle_diff; + float percentage; int offset; if (isLooping) { @@ -551,9 +555,10 @@ const char* dsp56k_getInstructionText(vo } 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, &count, &cycles)) { + if (offset > 2 && Profile_DspAddressData(prev_inst_pc, &percentage, &count, &cycles, &cycle_diff)) { offset -= 2; - sprintf(str_instr2+offset, "%d/%d times/cycles\n", count, cycles); + sprintf(str_instr2+offset, "%5.2f%% (%"PRId64", %"PRId64", %d)\n", + percentage, count, cycles, cycle_diff); } return str_instr2; } @@ -673,6 +678,9 @@ static void opcode8h_0(void) case 0x00008c: dsp_enddo(); break; + default: + dsp_undefined(); + break; } }