--- hatari/src/debug/68kDisass.c 2019/04/09 08:54:22 1.1.1.5 +++ hatari/src/debug/68kDisass.c 2019/04/09 08:55:35 1.1.1.6 @@ -15,6 +15,9 @@ #include "main.h" #include "configuration.h" #include "newcpu.h" +#ifdef WINUAE_FOR_HATARI +#include "debug.h" +#endif #include "paths.h" #include "profile.h" #include "tos.h" @@ -37,7 +40,7 @@ static const Diss68kOptions optionsMask // values <0 will hide the group static int optionPosAddress = 0; // current address -static int optionPosHexdump = 10; // 16-bit words at this address +static int optionPosHexdump = 12; // 16-bit words at this address static int optionPosLabel = 35; // label, if defined static int optionPosOpcode = 47; // opcode static int optionPosOperand = 57; // operands for the opcode @@ -124,7 +127,14 @@ static disSymbolEntry *disSymbolEntries; static inline unsigned short Disass68kGetWord(long addr) { + if ( ! valid_address ( addr , 2 ) ) + return 0; + +#ifndef WINUAE_FOR_HATARI return get_word(addr); +#else + return get_word_debug(addr); +#endif } // Load a text file into memory, count the lines and replace the LF with 0-bytes. @@ -132,28 +142,31 @@ static int Disass68kLoadTextFile(const { long index; long fileLength; - int lineCount; + int lineCount = 0; char *fbuf; FILE *f; if(filebuf) *filebuf = NULL; f = fopen(filename, "r"); - if(!f) return 0; - if(fseek(f, 0, SEEK_END)) + if (!f) return 0; + if (fseek(f, 0, SEEK_END)) + goto out; fileLength = ftell(f); - if(fileLength <= 0) return 0; - if(fseek(f, 0, SEEK_SET)) - return 0; + if (fileLength <= 0) + goto out; + if (fseek(f, 0, SEEK_SET)) + goto out; fbuf = malloc(fileLength); - if(!fbuf) return 0; + if(!fbuf) + goto out; if((size_t)fileLength != fread(fbuf, sizeof(char), fileLength, f)) { free(fbuf); - return 0; + goto out; } - lineCount = 0; + for(index=0; index 0) { - const int addrWidth = 6; // 6 on an ST, 8 on a TT + const int addrWidth = 8; // 6 on an ST (24 bit addressing), 8 on a TT (32 bit addressing) char lineBuffer[1024]; char addressBuffer[32]; @@ -2498,10 +2513,10 @@ static void Disass68k_loop (FILE *f, uae if (optionPosComment >= 0) { float percentage; - Uint32 count, cycles, misses; - if (Profile_CpuAddressData(addr, &percentage, &count, &cycles, &misses)) + Uint32 count, cycles, i_misses, d_hits; + if (Profile_CpuAddressData(addr, &percentage, &count, &cycles, &i_misses, &d_hits)) { - sprintf(commentBuffer, "%5.2f%% (%u, %u, %u)", percentage, count, cycles, misses); + sprintf(commentBuffer, "%5.2f%% (%u, %u, %u, %u)", percentage, count, cycles, i_misses, d_hits); Disass68kComposeStr(lineBuffer, commentBuffer, optionPosComment+1, 0); } /* show comments only if profile data is missing */ @@ -2542,7 +2557,11 @@ Uint32 Disasm_GetNextPC(Uint32 pc) void Disasm (FILE *f, uaecptr addr, uaecptr *nextpc, int cnt) { if (ConfigureParams.Debugger.bDisasmUAE) +#ifdef WINUAE_FOR_HATARI + m68k_disasm_file (f, addr, nextpc, cnt); +#else m68k_disasm (f, addr, nextpc, cnt); +#endif else Disass68k_loop (f, addr, nextpc, cnt); } @@ -2620,6 +2639,27 @@ int Disasm_GetOptions(void) } /** + * Set CPU and FPU mask used for disassembly (when changed from the UI or the options) + */ +void Disasm_SetCPUType ( int CPU , int FPU ) +{ + optionCPUTypeMask = 0; + + if ( ( FPU == 68881 ) || ( FPU == 68882 ) ) + optionCPUTypeMask |= MC_FPU; + + switch ( CPU ) + { + case 0 : optionCPUTypeMask |= MC68000 ; break; + case 1 : optionCPUTypeMask |= MC68010 ; break; + case 2 : optionCPUTypeMask |= MC68020 ; break; + case 3 : optionCPUTypeMask |= MC68030 ; break; + case 4 : optionCPUTypeMask |= MC68040 ; break; + default : optionCPUTypeMask |= MC68000 ; break; + } +} + +/** * Parse disasm command line option argument * @return error string (""=silent 'error') or NULL for success. */