Disassembly formating

TraceFile fixes
This commit is contained in:
mpohoreski 2006-08-16 18:58:56 +00:00
parent eb6c0d557a
commit 70813c8814
8 changed files with 602 additions and 360 deletions

View File

@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// TODO: COLOR LOAD ["filename"]
// See Debugger_Changelong.txt for full details
const int DEBUGGER_VERSION = MAKE_VERSION(2,5,7,6);
const int DEBUGGER_VERSION = MAKE_VERSION(2,5,7,11);
// Public _________________________________________________________________________________________
@ -741,8 +741,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bool g_bSourceAddSymbols = false;
bool g_bSourceAddMemory = false;
TCHAR g_aSourceFileName[ MAX_PATH ] = TEXT("");
TCHAR g_aSourceFontName[ MAX_FONT_NAME ] = TEXT("Arial");
char g_aSourceFileName[ MAX_PATH ] = "";
MemoryTextFile_t g_AssemblerSourceBuffer;
@ -755,11 +754,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// Symbols ________________________________________________________________________________________
TCHAR * g_aSymbolTableNames[ NUM_SYMBOL_TABLES ] =
char * g_aSymbolTableNames[ NUM_SYMBOL_TABLES ] =
{
TEXT("Main"),
TEXT("User"),
TEXT("Src" )
"Main",
"User",
"Src"
};
SymbolTable_t g_aSymbols[ NUM_SYMBOL_TABLES ];
@ -824,6 +823,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
int g_nDebugSkipLen = 0;
FILE *g_hTraceFile = NULL;
bool g_bTraceHeader = false; // semaphore, flag header to be printed
DWORD extbench = 0;
bool g_bDebuggerViewingAppleOutput = false;
@ -872,7 +872,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bool _CmdSymbolList_Symbol2Address( LPCTSTR pSymbol, int bSymbolTables );
// Source Level Debugging
static bool BufferAssemblyListing ( TCHAR * pFileName );
static bool BufferAssemblyListing ( char * pFileName );
static bool ParseAssemblyListing ( bool bBytesToMemory, bool bAddSymbols );
@ -1426,7 +1426,8 @@ Update_t CmdProfile (int nArgs)
if (pText)
{
TextConvertTabsToSpaces( sText, pText, CONSOLE_WIDTH, 4 );
ConsoleBufferPush( sText );
// ConsoleBufferPush( sText );
ConsolePrint( sText );
}
}
}
@ -2471,18 +2472,47 @@ Update_t CmdTrace (int nArgs)
}
//===========================================================================
Update_t CmdTraceFile (int nArgs) {
Update_t CmdTraceFile (int nArgs)
{
char sText[ CONSOLE_WIDTH ] = "";
if (g_hTraceFile)
fclose(g_hTraceFile);
{
fclose( g_hTraceFile );
g_hTraceFile = NULL;
TCHAR sFilename[MAX_PATH];
_tcscpy(sFilename,g_sCurrentDir); // g_sProgramDir
if (nArgs)
_tcscat( sFilename, g_aArgs[1].sArg );
sprintf( sText, "Trace stopped." );
}
else
_tcscat( sFilename, g_sFileNameTrace );
g_hTraceFile = fopen( sFilename, "wt" );
{
char sFileName[MAX_PATH];
if (nArgs)
strcpy( sFileName, g_aArgs[1].sArg );
else
strcpy( sFileName, g_sFileNameTrace );
char sFilePath[ MAX_PATH ];
strcpy(sFilePath, g_sCurrentDir); // g_sProgramDir
strcat(sFilePath, sFileName );
g_hTraceFile = fopen( sFilePath, "wt" );
if (g_hTraceFile)
{
sprintf( sText, "Trace started: %s", sFileName );
g_bTraceHeader = true;
}
else
{
sprintf( sText, "Trace ERROR: %s", sFileName );
}
}
ConsoleBufferPush( sText );
ConsoleBufferToDisplay();
return UPDATE_ALL; // TODO: Verify // 0
}
@ -2660,7 +2690,7 @@ Update_t CmdNOP (int nArgs)
int iOpmode;
int nOpbytes;
_6502_GetOpcodeOpmodeOpbytes( iOpcode, iOpmode, nOpbytes );
_6502_GetOpcodeOpmodeOpbyte( iOpcode, iOpmode, nOpbytes );
while (nOpbytes--)
{
@ -3493,9 +3523,9 @@ void DisasmCalcTopFromCurAddress( bool bUpdateTop )
for( int iLine = 0; iLine <= nLen; iLine++ ) // min 1 opcode/instruction
{
// a.
_6502_GetOpmodeOpbytes( iAddress, iOpmode, nOpbytes );
_6502_GetOpmodeOpbyte( iAddress, iOpmode, nOpbytes );
// b.
// _6502_GetOpcodeOpmodeOpbytes( iOpcode, iOpmode, nOpbytes );
// _6502_GetOpcodeOpmodeOpbyte( iOpcode, iOpmode, nOpbytes );
if (iLine == g_nDisasmCurLine) // && (iAddress == g_nDisasmCurAddress))
{
@ -3563,7 +3593,7 @@ WORD DisasmCalcAddressFromLines( WORD iAddress, int nLines )
{
int iOpmode;
int nOpbytes;
_6502_GetOpmodeOpbytes( iAddress, iOpmode, nOpbytes );
_6502_GetOpmodeOpbyte( iAddress, iOpmode, nOpbytes );
iAddress += nOpbytes;
}
return iAddress;
@ -3621,7 +3651,7 @@ Update_t CmdCursorLineDown (int nArgs)
{
int iOpmode;
int nOpbytes;
_6502_GetOpmodeOpbytes( g_nDisasmCurAddress, iOpmode, nOpbytes ); // g_nDisasmTopAddress
_6502_GetOpmodeOpbyte( g_nDisasmCurAddress, iOpmode, nOpbytes ); // g_nDisasmTopAddress
if (g_iWindowThis == WINDOW_DATA)
{
@ -3665,10 +3695,10 @@ Update_t CmdCursorLineDown (int nArgs)
#endif
g_nDisasmCurAddress += nOpbytes;
_6502_GetOpmodeOpbytes( g_nDisasmTopAddress, iOpmode, nOpbytes );
_6502_GetOpmodeOpbyte( g_nDisasmTopAddress, iOpmode, nOpbytes );
g_nDisasmTopAddress += nOpbytes;
_6502_GetOpmodeOpbytes( g_nDisasmBotAddress, iOpmode, nOpbytes );
_6502_GetOpmodeOpbyte( g_nDisasmBotAddress, iOpmode, nOpbytes );
g_nDisasmBotAddress += nOpbytes;
if (g_bDisasmCurBad)
@ -3768,8 +3798,8 @@ Update_t CmdCursorLineUp (int nArgs)
{
g_nDisasmTopAddress--;
// _6502_GetOpcodeOpmodeOpbytes( iOpcode, iOpmode, nOpbytes );
iOpcode = _6502_GetOpmodeOpbytes( g_nDisasmTopAddress, iOpmode, nOpbytes );
// _6502_GetOpcodeOpmodeOpbyte( iOpcode, iOpmode, nOpbytes );
iOpcode = _6502_GetOpmodeOpbyte( g_nDisasmTopAddress, iOpmode, nOpbytes );
aOpBytes[ 1 ] = nOpbytes;
// Disasm is kept in sync. Maybe bad opcode, but if no other choices...
@ -3785,7 +3815,7 @@ Update_t CmdCursorLineUp (int nArgs)
g_nDisasmTopAddress--;
DisasmCalcCurFromTopAddress();
iOpcode = _6502_GetOpmodeOpbytes( g_nDisasmTopAddress, iOpmode, nOpbytes );
iOpcode = _6502_GetOpmodeOpbyte( g_nDisasmTopAddress, iOpmode, nOpbytes );
aOpBytes[ 2 ] = nOpbytes;
if ( (iOpmode == AM_1)
@ -3797,7 +3827,7 @@ Update_t CmdCursorLineUp (int nArgs)
g_nDisasmTopAddress--;
DisasmCalcCurFromTopAddress();
iOpcode = _6502_GetOpmodeOpbytes( g_nDisasmTopAddress, iOpmode, nOpbytes );
iOpcode = _6502_GetOpmodeOpbyte( g_nDisasmTopAddress, iOpmode, nOpbytes );
aOpBytes[ 3 ] = nOpbytes;
if ( (iOpmode == AM_1)
@ -3840,14 +3870,14 @@ Update_t CmdCursorLineUp (int nArgs)
for (int iLine = 0; iLine < MAX_LOOK_AHEAD; iLine++ )
{
iOpcode = _6502_GetOpmodeOpbytes( nCur, iOpmode, nOpbytes );
iOpcode = _6502_GetOpmodeOpbyte( nCur, iOpmode, nOpbytes );
// If address on iLine = g_nDisasmCurLine + 1
if (iLine == (g_nDisasmCurLine + 1))
{
if (nCur == (g_nDisasmCurAddress))
{
iOpcode = _6502_GetOpmodeOpbytes( nTop, iOpmode, nOpbytes );
iOpcode = _6502_GetOpmodeOpbyte( nTop, iOpmode, nOpbytes );
tCandidate._nAddress = nTop;
tCandidate._iOpcode = iOpcode;
@ -3988,8 +4018,8 @@ WORD _ClampAddress( int nAddress )
{
if (nAddress < 0)
nAddress = 0;
if (nAddress > 0xFFFF)
nAddress = 0xFFFF;
if (nAddress > _6502_MEM_END)
nAddress = _6502_MEM_END;
return (WORD) nAddress;
}
@ -5626,7 +5656,7 @@ Update_t CmdOutputRun (int nArgs)
// Source Level Debugging _________________________________________________________________________
//===========================================================================
bool BufferAssemblyListing( TCHAR *pFileName )
bool BufferAssemblyListing( char *pFileName )
{
bool bStatus = false; // true = loaded
@ -5997,13 +6027,13 @@ Update_t CmdSymbolsInfo (int nArgs)
if (bDisplayMain && bDisplayUser && bDisplaySrc)
{
sprintf( sText, " Symbols Main: %s%d%s User: %s%d%s Source: %s%d%s"
, CHC_NUMBER
, CHC_NUM_DEC
, nSymbolsMain
, CHC_DEFAULT
, CHC_NUMBER
, CHC_NUM_DEC
, nSymbolsUser
, CHC_DEFAULT
, CHC_NUMBER
, CHC_NUM_DEC
, nSymbolsSrc
, CHC_DEFAULT
);
@ -6013,7 +6043,7 @@ Update_t CmdSymbolsInfo (int nArgs)
if (bDisplayMain)
{
sprintf( sText, " Main symbols: %s%d%s"
, CHC_NUMBER
, CHC_NUM_DEC
, nSymbolsMain
, CHC_DEFAULT
);
@ -6023,7 +6053,7 @@ Update_t CmdSymbolsInfo (int nArgs)
if (bDisplayUser)
{
sprintf( sText, " User symbols: %s%d%s"
, CHC_NUMBER
, CHC_NUM_DEC
, nSymbolsUser
, CHC_DEFAULT
);
@ -6033,7 +6063,7 @@ Update_t CmdSymbolsInfo (int nArgs)
if (bDisplaySrc)
{
sprintf( sText, " Source symbols: %s%d%s"
, CHC_NUMBER
, CHC_NUM_DEC
, nSymbolsSrc
, CHC_DEFAULT
);
@ -6054,7 +6084,7 @@ void _CmdPrintSymbol( LPCTSTR pSymbol, WORD nAddress, int iTable )
, CHC_ADDRESS
, nAddress
, CHC_DEFAULT
, CHC_USAGE
, CHC_STRING
, g_aSymbolTableNames[ iTable ]
, CHC_DEFAULT
, CHC_SYMBOL
@ -7259,11 +7289,20 @@ _Help:
}
Update_t _ZeroPage_Error()
{
// return ConsoleDisplayError( "There are no (ZP) pointers defined." );
char sText[ CONSOLE_WIDTH ];
sprintf( sText, " There are no current (ZP) pointers. (Max: %d)", MAX_ZEROPAGE_POINTERS );
// ConsoleBufferPush( sText );
return ConsoleDisplayError( sText );
}
//===========================================================================
Update_t CmdZeroPageClear (int nArgs)
{
if (!g_nBreakpoints)
return ConsoleDisplayError(TEXT("There are no (ZP) pointers defined."));
return _ZeroPage_Error();
// CHECK FOR ERRORS
if (!nArgs)
@ -7286,7 +7325,7 @@ Update_t CmdZeroPageDisable (int nArgs)
if (!nArgs)
return Help_Arg_1( CMD_ZEROPAGE_POINTER_DISABLE );
if (! g_nZeroPagePointers)
return ConsoleDisplayError(TEXT("There are no (ZP) pointers defined."));
return _ZeroPage_Error();
_BWZ_EnableDisableViaArgs( nArgs, g_aZeroPagePointers, MAX_ZEROPAGE_POINTERS, false );
@ -7297,7 +7336,7 @@ Update_t CmdZeroPageDisable (int nArgs)
Update_t CmdZeroPageEnable (int nArgs)
{
if (! g_nZeroPagePointers)
return ConsoleDisplayError(TEXT("There are no (ZP) pointers defined."));
return _ZeroPage_Error();
if (!nArgs)
return Help_Arg_1( CMD_ZEROPAGE_POINTER_ENABLE );
@ -7312,9 +7351,7 @@ Update_t CmdZeroPageList (int nArgs)
{
if (! g_nZeroPagePointers)
{
TCHAR sText[ CONSOLE_WIDTH ];
wsprintf( sText, TEXT(" There are no current (ZP) pointers. (Max: %d)"), MAX_ZEROPAGE_POINTERS );
ConsoleBufferPush( sText );
_ZeroPage_Error();
}
else
{
@ -7504,7 +7541,7 @@ void DisplayAmbigiousCommands( int nFound )
{
char sText[ CONSOLE_WIDTH * 2 ];
sprintf( sText, "Ambiguous %s%d%s Commands:"
, CHC_NUMBER
, CHC_NUM_DEC
, g_vPotentialCommands.size()
, CHC_DEFAULT
);
@ -7617,7 +7654,7 @@ Update_t ExecuteCommand (int nArgs)
g_iCommand = CMD_MEMORY_ENTER_BYTE;
// replace: addr :
// with: comamnd addr
// with: command addr
pArg[1] = pArg[0];
strcpy( pArg->sArg, g_aCommands[ g_iCommand ].m_sName );
@ -7657,7 +7694,7 @@ Update_t ExecuteCommand (int nArgs)
nArgsCooked = ArgsCook( nArgs ); // nCookMask
if (nArgsCooked == ARG_SYNTAX_ERROR)
return ConsoleDisplayError(TEXT("Syntax Error"));
return ConsoleDisplayError( "Syntax Error" );
if (pFunction)
return pFunction( nArgsCooked ); // Eat them
@ -7665,7 +7702,7 @@ Update_t ExecuteCommand (int nArgs)
return UPDATE_CONSOLE_DISPLAY;
}
else
return ConsoleDisplayError(TEXT("Illegal Command"));
return ConsoleDisplayError( "Illegal Command" );
}
@ -7710,19 +7747,47 @@ bool InternalSingleStep ()
//===========================================================================
void OutputTraceLine ()
{
char sDisassembly[ CONSOLE_WIDTH ]; DrawDisassemblyLine( 0,regs.pc, sDisassembly); // Get Disasm String
DisasmLine_t line;
GetDisassemblyLine( regs.pc, line );
char sDisassembly[ CONSOLE_WIDTH ]; // DrawDisassemblyLine( 0,regs.pc, sDisassembly); // Get Disasm String
FormatDisassemblyLine( line, sDisassembly, CONSOLE_WIDTH );
char sFlags[ _6502_NUM_FLAGS + 1 ]; DrawFlags( 0, regs.ps, sFlags ); // Get Flags String
// _ftprintf(g_hTraceFile,
fprintf( g_hTraceFile,
"a=%02x x=%02x y=%02x sp=%03x ps=%s %s\n",
(unsigned)regs.a,
(unsigned)regs.x,
(unsigned)regs.y,
(unsigned)regs.sp,
(char*) sFlags,
(char*) sDisassembly
);
if (g_hTraceFile)
{
if (g_bTraceHeader)
{
g_bTraceHeader = false;
fprintf( g_hTraceFile,
// "00 00 00 0000-------- 0000:90 90 90 NOP"
"A: X: Y: SP: Flags Addr:Opcode Mnemonic\n"
);
}
char sTarget[ 16 ];
if (line.bTargetValue)
{
sprintf( sTarget, "%s:%s"
, line.sTargetPointer
, line.sTargetValue
);
}
fprintf( g_hTraceFile,
// "a=%02x x=%02x y=%02x sp=%03x ps=%s %s\n",
"%02X %02X %02X %04X %s %s\n",
(unsigned)regs.a,
(unsigned)regs.x,
(unsigned)regs.y,
(unsigned)regs.sp,
(char*) sFlags
, sDisassembly
, sTarget
);
}
}
//===========================================================================
@ -7843,7 +7908,22 @@ void ProfileFormat( bool bExport, ProfileFormat_e eFormatMode )
nOpcodeTotal = 1;
bOpcodeGood = false;
}
char *pColorOperator = "";
char *pColorNumber = "";
char *pColorOpcode = "";
char *pColorMnemonic = "";
char *pColorOpmode = "";
char *pColorTotal = "";
if (! bExport)
{
pColorOperator = CHC_ARG_SEP; // grey
pColorNumber = CHC_NUM_DEC; // cyan
pColorOpcode = CHC_NUM_HEX; // yellow
pColorMnemonic = CHC_COMMAND; // green
pColorOpmode = CHC_USAGE ; // yellow
pColorTotal = CHC_DEFAULT; // white
}
// Opcode
if (bExport) // Export = SeperateColumns
@ -7897,11 +7977,18 @@ void ProfileFormat( bool bExport, ProfileFormat_e eFormatMode )
// BUG: Yeah 100% is off by 1 char. Profiling only one opcode isn't worth fixing this visual alignment bug.
sprintf( pText,
"%7.4f%%" DELIM "%9u" DELIM "%s" DELIM "%s" DELIM "%s\n"
, nPercent, sSeperator2
"%s%7.4f%s%%" DELIM "%s%9u" DELIM "%s%s" DELIM "%s%s" DELIM "%s%s\n"
, pColorNumber
, nPercent
, pColorOperator
, sSeperator2
, pColorNumber
, static_cast<unsigned int>(nCount), sSeperator2
, pColorOpcode
, sOpcode, sSeperator2
, pColorMnemonic
, g_aOpcodes[ nOpcode ].sMnemonic, sSeperator2
, pColorOpmode
, sAddress
);
pText = ProfileLinePush();
@ -7911,8 +7998,9 @@ void ProfileFormat( bool bExport, ProfileFormat_e eFormatMode )
nOpcodeTotal = 0;
sprintf( pText
, "Total: " DELIM "%9u\n"
, "Total: " DELIM "%s%9u\n"
, sSeperator2
, pColorTotal
, static_cast<unsigned int>(nOpcodeTotal) );
pText = ProfileLinePush();
@ -7964,9 +8052,14 @@ void ProfileFormat( bool bExport, ProfileFormat_e eFormatMode )
// BUG: Yeah 100% is off by 1 char. Profiling only one opcode isn't worth fixing this visual alignment bug.
sprintf( pText
, "%7.4f%%" DELIM "%9u" DELIM "%s\n"
, nPercent, sSeperator2
, "%s%7.4f%s%%" DELIM "%s%9u" DELIM "%s%s\n"
, pColorNumber
, nPercent
, pColorOperator
, sSeperator2
, pColorNumber
, static_cast<unsigned int>(nCount), sSeperator2
, pColorOpmode
, sAddress
);
pText = ProfileLinePush();
@ -7976,8 +8069,9 @@ void ProfileFormat( bool bExport, ProfileFormat_e eFormatMode )
nOpmodeTotal = 0;
sprintf( pText
, "Total: " DELIM "%9u\n"
, "Total: " DELIM "%s%9u\n"
, sSeperator2
, pColorTotal
, static_cast<unsigned int>(nOpmodeTotal) );
pText = ProfileLinePush();
@ -8012,11 +8106,11 @@ bool ProfileSave()
{
bool bStatus = false;
TCHAR filename[MAX_PATH];
_tcscpy(filename,g_sProgramDir);
_tcscat(filename,g_FileNameProfile ); // TEXT("Profile.txt")); // =PATCH MJP
char sFilename[MAX_PATH];
strcpy( sFilename, g_sProgramDir ); // TODO: Allow user to decide?
strcat( sFilename, g_FileNameProfile );
FILE *hFile = fopen(filename,TEXT("wt"));
FILE *hFile = fopen( sFilename, "wt" );
if (hFile)
{

View File

@ -402,7 +402,7 @@ bool _6502_CalcRelativeOffset( int nOpcode, int nBaseAddress, int nTargetAddress
//===========================================================================
int _6502_GetOpmodeOpbytes ( const int iAddress, int & iOpmode_, int & nOpbytes_ )
int _6502_GetOpmodeOpbyte ( const int iAddress, int & iOpmode_, int & nOpbyte_ )
{
#if _DEBUG
if (! g_aOpcodes)
@ -411,9 +411,9 @@ int _6502_GetOpmodeOpbytes ( const int iAddress, int & iOpmode_, int & nOpbytes
}
#endif
int iOpcode_ = *(mem + iAddress);
iOpmode_ = g_aOpcodes[ iOpcode_ ].nAddressMode;
nOpbytes_ = g_aOpmodes[ iOpmode_ ].m_nBytes;
int iOpcode_ = *(mem + iAddress);
iOpmode_ = g_aOpcodes[ iOpcode_ ].nAddressMode;
nOpbyte_ = g_aOpmodes[ iOpmode_ ].m_nBytes;
#if _DEBUG
if (iOpcode_ >= NUM_OPCODES)
@ -427,9 +427,9 @@ int _6502_GetOpmodeOpbytes ( const int iAddress, int & iOpmode_, int & nOpbytes
//===========================================================================
void _6502_GetOpcodeOpmodeOpbytes ( int & iOpcode_, int & iOpmode_, int & nOpbytes_ )
void _6502_GetOpcodeOpmodeOpbyte ( int & iOpcode_, int & iOpmode_, int & nOpbyte_ )
{
iOpcode_ = _6502_GetOpmodeOpbytes( regs.pc, iOpmode_, nOpbytes_ );
iOpcode_ = _6502_GetOpmodeOpbyte( regs.pc, iOpmode_, nOpbyte_ );
}
//===========================================================================
@ -606,7 +606,7 @@ bool _6502_GetTargetAddress ( const WORD & nAddress, WORD & nTarget_ )
int iOpcode;
int iOpmode;
int nOpbytes;
iOpcode = _6502_GetOpmodeOpbytes( nAddress, iOpmode, nOpbytes );
iOpcode = _6502_GetOpmodeOpbyte( nAddress, iOpmode, nOpbytes );
// Composite string that has the target nAddress
// WORD nTarget = 0;

View File

@ -41,9 +41,9 @@
// Prototypes _______________________________________________________________
int _6502_GetOpmodeOpbytes( const int iAddress, int & iOpmode_, int & nOpbytes_ );
int _6502_GetOpmodeOpbyte( const int iAddress, int & iOpmode_, int & nOpbytes_ );
// void _6502_GetOpcodeOpmode( int & iOpcode_, int & iOpmode_, int & nOpbytes_ );
void _6502_GetOpcodeOpmodeOpbytes( int & iOpcode_, int & iOpmode_, int & nOpbytes_ );
void _6502_GetOpcodeOpmodeOpbyte( int & iOpcode_, int & iOpmode_, int & nOpbytes_ );
bool _6502_GetStackReturnAddress( WORD & nAddress_ );
bool _6502_GetTargets( WORD nAddress, int *pTargetPartial_, int *pTargetPointer_, int * pBytes_
, const bool bIgnoreJSRJMP = true, bool bIgnoreBranch = true );

View File

@ -53,7 +53,8 @@
#define CHC_ARG_MAND "`7" // < >
#define CHC_ARG_OPT "`4" // [ ]
#define CHC_ARG_SEP "`9" // | grey
#define CHC_NUMBER "`3"
#define CHC_NUM_DEC "`6" // cyan looks better then yellow
#define CHC_NUM_HEX "`3"
#define CHC_SYMBOL "`2"
#define CHC_ADDRESS "`8"
#define CHC_ERROR "`1"

View File

@ -182,12 +182,6 @@ static char ColorizeSpecialChar( char * sText, BYTE nData, const MemoryView_e iV
const int iLowBackground = BG_INFO_CHAR, const int iLowForeground = FG_INFO_CHAR_LO );
char FormatCharTxtAsci ( const BYTE b, bool * pWasAsci_ );
int FormatDisassemblyLine( WORD nOffset, int iOpcode, int iOpmode, int nOpbytes,
char *sAddress_, char *sOpCodes_,
char *sTarget_, char *sTargetOffset_, int & nTargetOffset_, char *sTargetValue_,
char * sImmediate_, char & nImmediate_, char *sBranch_ );
void DrawSubWindow_Code ( int iWindow );
void DrawSubWindow_IO (Update_t bUpdate);
@ -819,212 +813,6 @@ char FormatChar4Font ( const BYTE b, bool *pWasHi_, bool *pWasLo_ )
}
// Disassembly formatting flags returned
// @parama sTargetValue_ indirect/indexed final value
//===========================================================================
int FormatDisassemblyLine( WORD nBaseAddress, int iOpcode, int iOpmode, int nOpBytes,
char *sAddress_, char *sOpCodes_,
char *sTarget_, char *sTargetOffset_, int & nTargetOffset_,
char *sTargetPointer_, char *sTargetValue_,
char *sImmediate_, char & nImmediate_, char *sBranch_ )
{
const int nMaxOpcodes = 3;
unsigned int nMinBytesLen = (nMaxOpcodes * (2 + g_bConfigDisasmOpcodeSpaces)); // 2 char for byte (or 3 with space)
int bDisasmFormatFlags = 0;
// Composite string that has the symbol or target nAddress
WORD nTarget = 0;
nTargetOffset_ = 0;
// if (g_aOpmodes[ iMode ]._sFormat[0])
if ((iOpmode != AM_IMPLIED) &&
(iOpmode != AM_1) &&
(iOpmode != AM_2) &&
(iOpmode != AM_3))
{
nTarget = *(LPWORD)(mem+nBaseAddress+1);
if (nOpBytes == 2)
nTarget &= 0xFF;
if (iOpmode == AM_R) // Relative ADDR_REL)
{
nTarget = nBaseAddress+2+(int)(signed char)nTarget;
// Always show branch indicators
// if ((nBaseAddress == regs.pc) && CheckJump(nAddress))
bDisasmFormatFlags |= DISASM_FORMAT_BRANCH;
if (nTarget < nBaseAddress)
{
sprintf( sBranch_, "%s", g_sConfigBranchIndicatorUp[ g_iConfigDisasmBranchType ] );
}
else
if (nTarget > nBaseAddress)
{
sprintf( sBranch_, "%s", g_sConfigBranchIndicatorDown[ g_iConfigDisasmBranchType ] );
}
else
{
sprintf( sBranch_, "%s", g_sConfigBranchIndicatorEqual[ g_iConfigDisasmBranchType ] );
}
}
// if (strstr(g_aOpmodes[ iOpmode ]._sFormat,"%s"))
// if ((iOpmode >= ADDR_ABS) && (iOpmode <= ADDR_IABS))
if ((iOpmode == AM_A ) || // Absolute
(iOpmode == AM_Z ) || // Zeropage
(iOpmode == AM_AX ) || // Absolute, X
(iOpmode == AM_AY ) || // Absolute, Y
(iOpmode == AM_ZX ) || // Zeropage, X
(iOpmode == AM_ZY ) || // Zeropage, Y
(iOpmode == AM_R ) || // Relative
(iOpmode == AM_IZX) || // Indexed (Zeropage Indirect, X)
(iOpmode == AM_IAX) || // Indexed (Absolute Indirect, X)
(iOpmode == AM_NZY) || // Indirect (Zeropage) Index, Y
(iOpmode == AM_NZ ) || // Indirect (Zeropage)
(iOpmode == AM_NA )) // Indirect Absolute
{
LPCTSTR pTarget = NULL;
LPCTSTR pSymbol = FindSymbolFromAddress( nTarget );
if (pSymbol)
{
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
pTarget = pSymbol;
}
if (! (bDisasmFormatFlags & DISASM_FORMAT_SYMBOL))
{
pSymbol = FindSymbolFromAddress( nTarget - 1 );
if (pSymbol)
{
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
bDisasmFormatFlags |= DISASM_FORMAT_OFFSET;
pTarget = pSymbol;
nTargetOffset_ = +1; // U FA82 LDA #3F1 BREAK+1
}
}
if (! (bDisasmFormatFlags & DISASM_FORMAT_SYMBOL))
{
pSymbol = FindSymbolFromAddress( nTarget + 1 );
if (pSymbol)
{
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
bDisasmFormatFlags |= DISASM_FORMAT_OFFSET;
pTarget = pSymbol;
nTargetOffset_ = -1; // U FA82 LDA #3F3 BREAK-1
}
}
if (! (bDisasmFormatFlags & DISASM_FORMAT_SYMBOL))
{
pTarget = FormatAddress( nTarget, nOpBytes );
}
// sprintf( sTarget, g_aOpmodes[ iOpmode ]._sFormat, pTarget );
if (bDisasmFormatFlags & DISASM_FORMAT_OFFSET)
{
int nAbsTargetOffset = (nTargetOffset_ > 0) ? nTargetOffset_ : -nTargetOffset_;
sprintf( sTargetOffset_, "%d", nAbsTargetOffset );
}
sprintf( sTarget_, "%s", pTarget );
// Indirect / Indexed
int nTargetPartial;
int nTargetPointer;
WORD nTargetValue = 0; // de-ref
int nTargetBytes;
_6502_GetTargets( nBaseAddress, &nTargetPartial, &nTargetPointer, &nTargetBytes );
if (nTargetPointer != NO_6502_TARGET)
{
bDisasmFormatFlags |= DISASM_FORMAT_TARGET_POINTER;
nTargetValue = *(LPWORD)(mem+nTargetPointer);
// if (((iOpmode >= AM_A) && (iOpmode <= AM_NZ)) && (iOpmode != AM_R))
// nTargetBytes refers to size of pointer, not size of value
// sprintf( sTargetValue_, "%04X", nTargetValue ); // & 0xFFFF
if (g_iConfigDisasmTargets & DISASM_TARGET_ADDR)
sprintf( sTargetPointer_, "%04X", nTargetPointer & 0xFFFF );
if (iOpmode != AM_NA ) // Indirect Absolute
{
bDisasmFormatFlags |= DISASM_FORMAT_TARGET_VALUE;
if (g_iConfigDisasmTargets & DISASM_TARGET_VAL)
sprintf( sTargetValue_, "%02X", nTargetValue & 0xFF );
bDisasmFormatFlags |= DISASM_FORMAT_CHAR;
nImmediate_ = (BYTE) nTargetValue;
unsigned _char = FormatCharTxtCtrl( FormatCharTxtHigh( nImmediate_, NULL ), NULL );
sprintf( sImmediate_, "%c", _char );
// if (ConsoleColorIsEscapeMeta( nImmediate_ ))
#if OLD_CONSOLE_COLOR
if (ConsoleColorIsEscapeMeta( _char ))
sprintf( sImmediate_, "%c%c", _char, _char );
else
sprintf( sImmediate_, "%c", _char );
#endif
}
// if (iOpmode == AM_NA ) // Indirect Absolute
// sprintf( sTargetValue_, "%04X", nTargetPointer & 0xFFFF );
// else
// // sprintf( sTargetValue_, "%02X", nTargetValue & 0xFF );
// sprintf( sTargetValue_, "%04X:%02X", nTargetPointer & 0xFFFF, nTargetValue & 0xFF );
}
}
else
if (iOpmode == AM_M)
{
// sprintf( sTarget, g_aOpmodes[ iOpmode ]._sFormat, (unsigned)nTarget );
sprintf( sTarget_, "%02X", (unsigned)nTarget );
if (iOpmode == AM_M)
{
bDisasmFormatFlags |= DISASM_FORMAT_CHAR;
nImmediate_ = (BYTE) nTarget;
unsigned _char = FormatCharTxtCtrl( FormatCharTxtHigh( nImmediate_, NULL ), NULL );
sprintf( sImmediate_, "%c", _char );
#if OLD_CONSOLE_COLOR
if (ConsoleColorIsEscapeMeta( _char ))
sprintf( sImmediate_, "%c%c", _char, _char );
else
sprintf( sImmediate_, "%c", _char );
#endif
}
}
}
sprintf( sAddress_, "%04X", nBaseAddress );
// Opcode Bytes
char *pDst = sOpCodes_;
for( int iBytes = 0; iBytes < nOpBytes; iBytes++ )
{
BYTE nMem = (unsigned)*(mem+nBaseAddress+iBytes);
sprintf( pDst, "%02X", nMem ); // sBytes+strlen(sBytes)
pDst += 2;
if (g_bConfigDisasmOpcodeSpaces)
{
strcat( pDst, " " );
pDst++; // 2.5.3.3 fix
}
}
while (strlen(sOpCodes_) < nMinBytesLen)
{
strcat( sOpCodes_, " " );
}
return bDisasmFormatFlags;
}
//===========================================================================
@ -1412,60 +1200,338 @@ void DrawConsoleInput ()
// Disassembly ____________________________________________________________________________________
// Disassembly formatting flags returned
// @parama sTargetValue_ indirect/indexed final value
//===========================================================================
WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
int GetDisassemblyLine( WORD nBaseAddress, DisasmLine_t & line_ )
// char *sAddress_, char *sOpCodes_,
// char *sTarget_, char *sTargetOffset_, int & nTargetOffset_,
// char *sTargetPointer_, char *sTargetValue_,
// char *sImmediate_, char & nImmediate_, char *sBranch_ )
{
if (! ((g_iWindowThis == WINDOW_CODE) || ((g_iWindowThis == WINDOW_DATA))))
return 0;
const int nMaxAddressLen = 40;
const int nMaxOpcodes = 3;
line_.Clear();
int iOpcode;
int iOpmode;
int nOpbytes;
iOpcode = _6502_GetOpmodeOpbytes( nBaseAddress, iOpmode, nOpbytes );
int nOpbyte;
iOpcode = _6502_GetOpmodeOpbyte( nBaseAddress, iOpmode, nOpbyte );
line_.iOpcode = iOpcode;
line_.iOpmode = iOpmode;
line_.nOpbyte = nOpbyte;
#if _DEBUG
// if (iLine != 41)
// return nOpbytes;
#endif
const int CHARS_FOR_ADDRESS = 8; // 4 digits plus null
char sAddress [ CHARS_FOR_ADDRESS ];
char sOpcodes [(nMaxOpcodes*3)+1] = "";
char sTarget [nMaxAddressLen] = "";
char sTargetOffset[ CHARS_FOR_ADDRESS ] = ""; // +/- 255, realistically +/-1
int nTargetOffset;
char sTargetPointer[ CHARS_FOR_ADDRESS ] = "";
char sTargetValue [ CHARS_FOR_ADDRESS ] = "";
char nImmediate = 0;
char sImmediate[ 4 ]; // 'c'
char sBranch [ 4 ]; // ^
bool bTargetIndirect = false;
bool bTargetX = false;
bool bTargetY = false; // need to dislay ",Y"
bool bTargetValue = false;
if (iOpmode == AM_M)
line_.bTargetImmediate = true;
if ((iOpmode >= AM_IZX) && (iOpmode <= AM_NA))
bTargetIndirect = true;
line_.bTargetIndirect = true; // ()
if (((iOpmode >= AM_A) && (iOpmode <= AM_ZY)) || bTargetIndirect)
bTargetValue = true;
if ((iOpmode >= AM_IZX) && (iOpmode <= AM_NZY))
line_.bTargetIndexed = true; // ()
if (((iOpmode >= AM_A) && (iOpmode <= AM_ZY)) || line_.bTargetIndirect)
line_.bTargetValue = true; // #$
if ((iOpmode == AM_AX) || (iOpmode == AM_ZX) || (iOpmode == AM_IZX) || (iOpmode == AM_IAX))
bTargetX = true;
line_.bTargetX = true; // ,X
if ((iOpmode == AM_AY) || (iOpmode == AM_ZY)) // Note: AM_NZY is checked and triggered by bTargetIndirect
bTargetY = true;
if ((iOpmode == AM_AY) || (iOpmode == AM_ZY) || (iOpmode == AM_NZY))
line_.bTargetY = true; // ,Y
int bDisasmFormatFlags = FormatDisassemblyLine( nBaseAddress, iOpcode, iOpmode, nOpbytes,
sAddress, sOpcodes, sTarget, sTargetOffset, nTargetOffset, sTargetPointer, sTargetValue, sImmediate, nImmediate, sBranch );
const int nMaxOpcodes = 3;
unsigned int nMinBytesLen = (nMaxOpcodes * (2 + g_bConfigDisasmOpcodeSpaces)); // 2 char for byte (or 3 with space)
int bDisasmFormatFlags = 0;
// Composite string that has the symbol or target nAddress
WORD nTarget = 0;
line_.nTargetOffset = 0;
// if (g_aOpmodes[ iMode ]._sFormat[0])
if ((iOpmode != AM_IMPLIED) &&
(iOpmode != AM_1) &&
(iOpmode != AM_2) &&
(iOpmode != AM_3))
{
nTarget = *(LPWORD)(mem+nBaseAddress+1);
if (nOpbyte == 2)
nTarget &= 0xFF;
if (iOpmode == AM_R) // Relative ADDR_REL)
{
line_.bTargetRelative = true;
nTarget = nBaseAddress+2+(int)(signed char)nTarget;
line_.nTarget = nTarget;
sprintf( line_.sTargetValue, "%04X", nTarget & 0xFFFF );
// Always show branch indicators
// if ((nBaseAddress == regs.pc) && CheckJump(nAddress))
bDisasmFormatFlags |= DISASM_FORMAT_BRANCH;
if (nTarget < nBaseAddress)
{
sprintf( line_.sBranch, "%s", g_sConfigBranchIndicatorUp[ g_iConfigDisasmBranchType ] );
}
else
if (nTarget > nBaseAddress)
{
sprintf( line_.sBranch, "%s", g_sConfigBranchIndicatorDown[ g_iConfigDisasmBranchType ] );
}
else
{
sprintf( line_.sBranch, "%s", g_sConfigBranchIndicatorEqual[ g_iConfigDisasmBranchType ] );
}
}
// if (strstr(g_aOpmodes[ iOpmode ]._sFormat,"%s"))
// if ((iOpmode >= ADDR_ABS) && (iOpmode <= ADDR_IABS))
if ((iOpmode == AM_A ) || // Absolute
(iOpmode == AM_Z ) || // Zeropage
(iOpmode == AM_AX ) || // Absolute, X
(iOpmode == AM_AY ) || // Absolute, Y
(iOpmode == AM_ZX ) || // Zeropage, X
(iOpmode == AM_ZY ) || // Zeropage, Y
(iOpmode == AM_R ) || // Relative
(iOpmode == AM_IZX) || // Indexed (Zeropage Indirect, X)
(iOpmode == AM_IAX) || // Indexed (Absolute Indirect, X)
(iOpmode == AM_NZY) || // Indirect (Zeropage) Index, Y
(iOpmode == AM_NZ ) || // Indirect (Zeropage)
(iOpmode == AM_NA )) // Indirect Absolute
{
line_.nTarget = nTarget;
LPCTSTR pTarget = NULL;
LPCTSTR pSymbol = FindSymbolFromAddress( nTarget );
if (pSymbol)
{
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
pTarget = pSymbol;
}
if (! (bDisasmFormatFlags & DISASM_FORMAT_SYMBOL))
{
pSymbol = FindSymbolFromAddress( nTarget - 1 );
if (pSymbol)
{
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
bDisasmFormatFlags |= DISASM_FORMAT_OFFSET;
pTarget = pSymbol;
line_.nTargetOffset = +1; // U FA82 LDA #3F1 BREAK+1
}
}
if (! (bDisasmFormatFlags & DISASM_FORMAT_SYMBOL))
{
pSymbol = FindSymbolFromAddress( nTarget + 1 );
if (pSymbol)
{
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
bDisasmFormatFlags |= DISASM_FORMAT_OFFSET;
pTarget = pSymbol;
line_.nTargetOffset = -1; // U FA82 LDA #3F3 BREAK-1
}
}
if (! (bDisasmFormatFlags & DISASM_FORMAT_SYMBOL))
{
pTarget = FormatAddress( nTarget, nOpbyte );
}
// sprintf( sTarget, g_aOpmodes[ iOpmode ]._sFormat, pTarget );
if (bDisasmFormatFlags & DISASM_FORMAT_OFFSET)
{
int nAbsTargetOffset = (line_.nTargetOffset > 0) ? line_.nTargetOffset : - line_.nTargetOffset;
sprintf( line_.sTargetOffset, "%d", nAbsTargetOffset );
}
sprintf( line_.sTarget, "%s", pTarget );
// Indirect / Indexed
int nTargetPartial;
int nTargetPointer;
WORD nTargetValue = 0; // de-ref
int nTargetBytes;
_6502_GetTargets( nBaseAddress, &nTargetPartial, &nTargetPointer, &nTargetBytes );
if (nTargetPointer != NO_6502_TARGET)
{
bDisasmFormatFlags |= DISASM_FORMAT_TARGET_POINTER;
nTargetValue = *(LPWORD)(mem+nTargetPointer);
// if (((iOpmode >= AM_A) && (iOpmode <= AM_NZ)) && (iOpmode != AM_R))
// nTargetBytes refers to size of pointer, not size of value
// sprintf( sTargetValue_, "%04X", nTargetValue ); // & 0xFFFF
if (g_iConfigDisasmTargets & DISASM_TARGET_ADDR)
sprintf( line_.sTargetPointer, "%04X", nTargetPointer & 0xFFFF );
if (iOpmode != AM_NA ) // Indirect Absolute
{
bDisasmFormatFlags |= DISASM_FORMAT_TARGET_VALUE;
if (g_iConfigDisasmTargets & DISASM_TARGET_VAL)
sprintf( line_.sTargetValue, "%02X", nTargetValue & 0xFF );
bDisasmFormatFlags |= DISASM_FORMAT_CHAR;
line_.nImmediate = (BYTE) nTargetValue;
unsigned _char = FormatCharTxtCtrl( FormatCharTxtHigh( line_.nImmediate, NULL ), NULL );
sprintf( line_.sImmediate, "%c", _char );
// if (ConsoleColorIsEscapeMeta( nImmediate_ ))
#if OLD_CONSOLE_COLOR
if (ConsoleColorIsEscapeMeta( _char ))
sprintf( line_.sImmediate, "%c%c", _char, _char );
else
sprintf( line_.sImmediate, "%c", _char );
#endif
}
// if (iOpmode == AM_NA ) // Indirect Absolute
// sprintf( sTargetValue_, "%04X", nTargetPointer & 0xFFFF );
// else
// // sprintf( sTargetValue_, "%02X", nTargetValue & 0xFF );
// sprintf( sTargetValue_, "%04X:%02X", nTargetPointer & 0xFFFF, nTargetValue & 0xFF );
}
}
else
if (iOpmode == AM_M)
{
// sprintf( sTarget, g_aOpmodes[ iOpmode ]._sFormat, (unsigned)nTarget );
sprintf( line_.sTarget, "%02X", (unsigned)nTarget );
if (iOpmode == AM_M)
{
bDisasmFormatFlags |= DISASM_FORMAT_CHAR;
line_.nImmediate = (BYTE) nTarget;
unsigned _char = FormatCharTxtCtrl( FormatCharTxtHigh( line_.nImmediate, NULL ), NULL );
sprintf( line_.sImmediate, "%c", _char );
#if OLD_CONSOLE_COLOR
if (ConsoleColorIsEscapeMeta( _char ))
sprintf( line_.sImmediate, "%c%c", _char, _char );
else
sprintf( line_.sImmediate, "%c", _char );
#endif
}
}
}
sprintf( line_.sAddress, "%04X", nBaseAddress );
// Opcode Bytes
char *pDst = line_.sOpCodes;
for( int iByte = 0; iByte < nOpbyte; iByte++ )
{
BYTE nMem = (unsigned)*(mem+nBaseAddress + iByte);
sprintf( pDst, "%02X", nMem ); // sBytes+strlen(sBytes)
pDst += 2;
if (g_bConfigDisasmOpcodeSpaces)
{
strcat( pDst, " " );
pDst++; // 2.5.3.3 fix
}
}
int nSpaces = strlen( line_.sOpCodes );
while (nSpaces < nMinBytesLen)
{
strcat( line_.sOpCodes, " " );
nSpaces++;
}
return bDisasmFormatFlags;
}
void FormatDisassemblyLine( const DisasmLine_t & line, char * sDisassembly, const int nBufferSize )
{
//> Address Seperator Opcodes Label Mnemonic Target [Immediate] [Branch]
const char * pMnemonic = g_aOpcodes[ line.iOpcode ].sMnemonic;
sprintf( sDisassembly, "%s:%s %s "
, line.sAddress
, line.sOpCodes
, pMnemonic
);
/*
if (line.bTargetIndexed || line.bTargetIndirect)
{
strcat( sDisassembly, "(" );
}
if (line.bTargetImmediate)
strcat( sDisassembly, "#$" );
if (line.bTargetValue)
strcat( sDisassembly, line.sTarget );
if (line.bTargetIndirect)
{
if (line.bTargetX)
strcat( sDisassembly, ", X" );
if (line.bTargetY)
strcat( sDisassembly, ", Y" );
}
if (line.bTargetIndexed || line.bTargetIndirect)
{
strcat( sDisassembly, ")" );
}
if (line.bTargetIndirect)
{
if (line.bTargetY)
strcat( sDisassembly, ", Y" );
}
*/
char sTarget[ 32 ];
if (line.bTargetValue || line.bTargetRelative || line.bTargetImmediate)
{
if (line.bTargetRelative)
strcpy( sTarget, line.sTargetValue );
else
if (line.bTargetImmediate)
{
strcat( sDisassembly, "#" );
strcpy( sTarget, line.sTarget ); // sTarget
}
else
sprintf( sTarget, g_aOpmodes[ line.iOpmode ].m_sFormat, line.nTarget );
strcat( sDisassembly, "$" );
strcat( sDisassembly, sTarget );
}
}
//===========================================================================
WORD DrawDisassemblyLine ( int iLine, const WORD nBaseAddress )
{
if (! ((g_iWindowThis == WINDOW_CODE) || ((g_iWindowThis == WINDOW_DATA))))
return 0;
int iOpcode;
int iOpmode;
int nOpbyte;
DisasmLine_t line;
int bDisasmFormatFlags = GetDisassemblyLine( nBaseAddress, line );
iOpcode = line.iOpcode;
iOpmode = line.iOpmode;
nOpbyte = line.nOpbyte;
// sAddress, sOpcodes, sTarget, sTargetOffset, nTargetOffset, sTargetPointer, sTargetValue, sImmediate, nImmediate, sBranch );
//> Address Seperator Opcodes Label Mnemonic Target [Immediate] [Branch]
//
@ -1474,7 +1540,6 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
//> 6 17 27 41 46
const int nDefaultFontWidth = 7; // g_aFontConfig[FONT_DISASM_DEFAULT]._nFontWidth or g_nFontWidthAvg
enum TabStop_e
{
TS_OPCODE
@ -1647,7 +1712,7 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
// DebuggerSetColorBG( dc, DebuggerGetColor( FG_DISASM_BOOKMARK ) ); // swapped
// DebuggerSetColorFG( dc, DebuggerGetColor( BG_DISASM_BOOKMARK ) ); // swapped
// }
PrintTextCursorX( (LPCTSTR) sAddress, linerect );
PrintTextCursorX( (LPCTSTR) line.sAddress, linerect );
if (bAddressIsBookmark)
{
@ -1670,7 +1735,7 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
// PrintTextCursorX( " ", linerect );
if (g_bConfigDisasmOpcodesView)
PrintTextCursorX( (LPCTSTR) sOpcodes, linerect );
PrintTextCursorX( (LPCTSTR) line.sOpCodes, linerect );
// PrintTextCursorX( " ", linerect );
// Label
@ -1692,27 +1757,27 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( iForeground ) );
LPCTSTR pMnemonic = g_aOpcodes[ iOpcode ].sMnemonic;
const char * pMnemonic = g_aOpcodes[ iOpcode ].sMnemonic;
PrintTextCursorX( pMnemonic, linerect );
PrintTextCursorX( " ", linerect );
// Target
if (iOpmode == AM_M)
if (line.bTargetImmediate)
{
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ));
PrintTextCursorX( "#$", linerect );
}
if (bTargetIndirect)
if (line.bTargetIndexed || line.bTargetIndirect)
{
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ));
PrintTextCursorX( "(", linerect );
}
char *pTarget = sTarget;
char *pTarget = line.sTarget;
if (*pTarget == '$')
{
pTarget++;
@ -1749,46 +1814,52 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ));
if (nTargetOffset > 0)
if (line.nTargetOffset > 0)
PrintTextCursorX( "+", linerect );
if (nTargetOffset < 0)
else
if (line.nTargetOffset < 0)
PrintTextCursorX( "-", linerect );
if (! bCursorLine)
{
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPCODE )); // Technically, not a hex number, but decimal
}
PrintTextCursorX( sTargetOffset, linerect );
PrintTextCursorX( line.sTargetOffset, linerect );
}
// Indirect Target Regs
if (bTargetIndirect || bTargetX || bTargetY)
// Inside Parenthesis = Indirect Target Regs
if (line.bTargetIndirect || line.bTargetX || line.bTargetY)
{
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ));
if (bTargetX)
if (line.bTargetX)
{
PrintTextCursorX( ",", linerect );
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_REG ) );
PrintTextCursorX( "X", linerect );
}
if (bTargetY)
else
if ((line.bTargetY) && (! line.bTargetIndirect))
{
PrintTextCursorX( ",", linerect );
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_REG ) );
PrintTextCursorX( "Y", linerect );
}
}
if (line.bTargetIndexed || line.bTargetIndirect)
{
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ));
if (bTargetIndirect)
PrintTextCursorX( ")", linerect );
PrintTextCursorX( ")", linerect );
}
if (iOpmode == AM_NZY)
if (line.bTargetIndexed)
{
if (line.bTargetY)
{
PrintTextCursorX( ",", linerect );
if (! bCursorLine)
@ -1807,7 +1878,7 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS ));
PrintTextCursorX( sTargetPointer, linerect );
PrintTextCursorX( line.sTargetPointer, linerect );
if (bDisasmFormatFlags & DISASM_FORMAT_TARGET_VALUE)
{
@ -1820,7 +1891,7 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
if (! bCursorLine)
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPCODE ));
PrintTextCursorX( sTargetValue, linerect );
PrintTextCursorX( line.sTargetValue, linerect );
PrintTextCursorX( " ", linerect );
}
}
@ -1840,10 +1911,10 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
if (! bCursorLine)
{
ColorizeSpecialChar( NULL, nImmediate, MEM_VIEW_ASCII, iBackground );
ColorizeSpecialChar( NULL, line.nImmediate, MEM_VIEW_ASCII, iBackground );
// iBackground, FG_INFO_CHAR_HI, FG_DISASM_CHAR, FG_INFO_CHAR_LO );
}
PrintTextCursorX( sImmediate, linerect );
PrintTextCursorX( line.sImmediate, linerect );
DebuggerSetColorBG( DebuggerGetColor( iBackground ) ); // Hack: Colorize can "color bleed to EOL"
if (! bCursorLine)
@ -1871,7 +1942,7 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
#endif
// PrintTextColor( sBranch, linerect );
PrintText( sBranch, linerect );
PrintText( line.sBranch, linerect );
#if !USE_APPLE_FONT
if (g_iConfigDisasmBranchType)
@ -1880,7 +1951,7 @@ WORD DrawDisassemblyLine ( int iLine, WORD nBaseAddress, LPTSTR text)
}
}
return nOpbytes;
return nOpbyte;
}
@ -3194,7 +3265,7 @@ void DrawSubWindow_Code ( int iWindow )
WORD nAddress = g_nDisasmTopAddress; // g_nDisasmCurAddress;
for (int iLine = 0; iLine < nLines; iLine++ )
{
nAddress += DrawDisassemblyLine( iLine, nAddress, NULL);
nAddress += DrawDisassemblyLine( iLine, nAddress );
}
#if !USE_APPLE_FONT

View File

@ -73,7 +73,14 @@
void DrawConsoleLine ( const char * pText, int y);
void DrawConsoleCursor ();
WORD DrawDisassemblyLine ( int line, WORD offset, LPTSTR text);
int GetDisassemblyLine( const WORD nOffset, DisasmLine_t & line_ );
// , int iOpcode, int iOpmode, int nOpbytes
// char *sAddress_, char *sOpCodes_,
// char *sTarget_, char *sTargetOffset_, int & nTargetOffset_, char *sTargetValue_,
// char * sImmediate_, char & nImmediate_, char *sBranch_ );
WORD DrawDisassemblyLine ( int line, const WORD offset );
void FormatDisassemblyLine( const DisasmLine_t & line, char *sDisassembly_, const int nBufferSize );
void DrawFlags ( int line, WORD nRegFlags, LPTSTR pFlagNames_);
void DrawMemory ( int line, int iMem );
void DrawRegister ( int line, LPCTSTR name, int bytes, WORD value, int iSource = 0 );

View File

@ -871,7 +871,7 @@ Update_t CmdHelpSpecific (int nArgs)
, g_aParameters[ PARAM_RESET ].m_sName );
Colorize( sText, sTemp );
ConsolePrint( sText );
sprintf( sText, " Maximum breakpoints: %s%d", CHC_NUMBER, MAX_BREAKPOINTS );
sprintf( sText, " Maximum breakpoints: %s%d", CHC_NUM_DEC, MAX_BREAKPOINTS );
ConsolePrint( sText );
ConsoleBufferPush( " Set breakpoint at PC if no args." );
ConsoleBufferPush( " Loading/Saving not yet implemented." );

View File

@ -30,7 +30,7 @@
/*
+---------------------+--------------------------+
| g_nAppMode | assembler format |
| Opmode e | assembler format |
+=====================+==========================+
| Immediate | #aa |
| Absolute | aaaa |
@ -876,6 +876,75 @@
, DISASM_TARGET_BOTH // Note: Also treated as bit flag !!
, NUM_DISASM_TARGET_TYPES
};
enum DisasmText_e
{
nMaxAddressLen = 40,
nMaxOpcodes = 3,
CHARS_FOR_ADDRESS = 8, // 4 digits plus null
};
struct DisasmLine_t
{
int iOpcode;
int iOpmode;
int nOpbyte;
char sAddress [ CHARS_FOR_ADDRESS ];
char sOpCodes [(nMaxOpcodes*3)+1];
int nTarget;
char sTarget [nMaxAddressLen];
char sTargetOffset[ CHARS_FOR_ADDRESS ]; // +/- 255, realistically +/-1
int nTargetOffset;
char sTargetPointer[ CHARS_FOR_ADDRESS ];
char sTargetValue [ CHARS_FOR_ADDRESS ];
// char sTargetAddress[ CHARS_FOR_ADDRESS ];
char sImmediate[ 4 ]; // 'c'
char nImmediate;
char sBranch [ 4 ]; // ^
bool bTargetImmediate;
bool bTargetIndirect;
bool bTargetIndexed ;
bool bTargetRelative;
bool bTargetX ;
bool bTargetY ;
bool bTargetValue ;
void Clear()
{
sAddress [ 0 ] = 0;
sOpCodes [ 0 ] = 0;
nTarget = 0;
sTarget [ 0 ] = 0;
sTargetOffset[ 0 ] = 0;
nTargetOffset = 0;
sTargetPointer[ 0 ] = 0;
sTargetValue [ 0 ] = 0;
sImmediate[ 0 ] = 0;
nImmediate = 0;
sBranch [ 0 ] = 0;
bTargetImmediate = false;
bTargetIndexed = false;
bTargetIndirect = false;
// bTargetInside = false;
// bTargetOutside = false;
bTargetRelative = false;
bTargetX = false;
bTargetY = false; // need to dislay ",Y"
bTargetValue = false;
}
};
// Font ___________________________________________________________________________________________
enum FontType_e