mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-12-26 05:31:30 +00:00
2.6.2.2 data disassembly prep and implementation
This commit is contained in:
parent
b2bcf6eb07
commit
35b413924d
@ -1203,6 +1203,7 @@ void DrawConsoleInput ()
|
|||||||
// Disassembly ____________________________________________________________________________________
|
// Disassembly ____________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
// Get the data needed to disassemble one line of opcodes
|
||||||
// Disassembly formatting flags returned
|
// Disassembly formatting flags returned
|
||||||
// @parama sTargetValue_ indirect/indexed final value
|
// @parama sTargetValue_ indirect/indexed final value
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
@ -1267,7 +1268,7 @@ int GetDisassemblyLine( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
if (nOpbyte == 2)
|
if (nOpbyte == 2)
|
||||||
nTarget &= 0xFF;
|
nTarget &= 0xFF;
|
||||||
|
|
||||||
if (iOpmode == AM_R) // Relative ADDR_REL)
|
if (iOpmode == AM_R) // Relative
|
||||||
{
|
{
|
||||||
line_.bTargetRelative = true;
|
line_.bTargetRelative = true;
|
||||||
|
|
||||||
@ -1294,9 +1295,9 @@ int GetDisassemblyLine( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
sprintf( line_.sBranch, "%s", g_sConfigBranchIndicatorEqual[ g_iConfigDisasmBranchType ] );
|
sprintf( line_.sBranch, "%s", g_sConfigBranchIndicatorEqual[ g_iConfigDisasmBranchType ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// intentional re-test AM_R ...
|
||||||
|
|
||||||
// if (strstr(g_aOpmodes[ iOpmode ]._sFormat,"%s"))
|
// if ((iOpmode >= AM_A) && (iOpmode <= AM_NA))
|
||||||
// if ((iOpmode >= ADDR_ABS) && (iOpmode <= ADDR_IABS))
|
|
||||||
if ((iOpmode == AM_A ) || // Absolute
|
if ((iOpmode == AM_A ) || // Absolute
|
||||||
(iOpmode == AM_Z ) || // Zeropage
|
(iOpmode == AM_Z ) || // Zeropage
|
||||||
(iOpmode == AM_AX ) || // Absolute, X
|
(iOpmode == AM_AX ) || // Absolute, X
|
||||||
@ -1328,7 +1329,7 @@ int GetDisassemblyLine( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
|
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
|
||||||
bDisasmFormatFlags |= DISASM_FORMAT_OFFSET;
|
bDisasmFormatFlags |= DISASM_FORMAT_OFFSET;
|
||||||
pTarget = pSymbol;
|
pTarget = pSymbol;
|
||||||
line_.nTargetOffset = +1; // U FA82 LDA #3F1 BREAK+1
|
line_.nTargetOffset = +1; // U FA82 LDA $3F1 BREAK-1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1340,7 +1341,7 @@ int GetDisassemblyLine( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
|
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
|
||||||
bDisasmFormatFlags |= DISASM_FORMAT_OFFSET;
|
bDisasmFormatFlags |= DISASM_FORMAT_OFFSET;
|
||||||
pTarget = pSymbol;
|
pTarget = pSymbol;
|
||||||
line_.nTargetOffset = -1; // U FA82 LDA #3F3 BREAK-1
|
line_.nTargetOffset = -1; // U FA82 LDA $3F3 BREAK+1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1432,6 +1433,23 @@ int GetDisassemblyLine( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
sprintf( line_.sAddress, "%04X", nBaseAddress );
|
sprintf( line_.sAddress, "%04X", nBaseAddress );
|
||||||
|
|
||||||
// Opcode Bytes
|
// Opcode Bytes
|
||||||
|
FormatOpcodeBytes( nBaseAddress, line_ );
|
||||||
|
|
||||||
|
int nSpaces = strlen( line_.sOpCodes );
|
||||||
|
while (nSpaces < (int)nMinBytesLen)
|
||||||
|
{
|
||||||
|
strcat( line_.sOpCodes, " " );
|
||||||
|
nSpaces++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bDisasmFormatFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void FormatOpcodeBytes ( WORD nBaseAddress, DisasmLine_t & line_ )
|
||||||
|
{
|
||||||
|
int nOpbyte = line_.nOpbyte;
|
||||||
|
|
||||||
char *pDst = line_.sOpCodes;
|
char *pDst = line_.sOpCodes;
|
||||||
for( int iByte = 0; iByte < nOpbyte; iByte++ )
|
for( int iByte = 0; iByte < nOpbyte; iByte++ )
|
||||||
{
|
{
|
||||||
@ -1445,20 +1463,64 @@ int GetDisassemblyLine( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
pDst++; // 2.5.3.3 fix
|
pDst++; // 2.5.3.3 fix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int nSpaces = strlen( line_.sOpCodes );
|
// Formats Target string with bytes,words, string, etc...
|
||||||
while (nSpaces < (int)nMinBytesLen)
|
//===========================================================================
|
||||||
|
void FormatNopcodeBytes ( WORD nBaseAddress, DisasmLine_t & line_ )
|
||||||
{
|
{
|
||||||
strcat( line_.sOpCodes, " " );
|
char *pDst = line_.sTarget;
|
||||||
nSpaces++;
|
for( int iByte = 0; iByte < line_.nOpbyte; )
|
||||||
|
{
|
||||||
|
BYTE nTarget8 = *(LPBYTE)(mem + nBaseAddress + iByte);
|
||||||
|
WORD nTarget16 = *(LPWORD)(mem + nBaseAddress + iByte);
|
||||||
|
|
||||||
|
switch( line_.iNoptype )
|
||||||
|
{
|
||||||
|
case NOP_BYTE_1:
|
||||||
|
sprintf( pDst, "$%02X", nTarget8 ); // sBytes+strlen(sBytes)
|
||||||
|
pDst += 3;
|
||||||
|
iByte++;
|
||||||
|
if( iByte < line_.nOpbyte )
|
||||||
|
{
|
||||||
|
*pDst++ = ',';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NOP_WORD_1:
|
||||||
|
sprintf( pDst, "$%04X", nTarget16 ); // sBytes+strlen(sBytes)
|
||||||
|
pDst += 5;
|
||||||
|
iByte+= 2;
|
||||||
|
if( iByte < line_.nOpbyte )
|
||||||
|
{
|
||||||
|
*pDst++ = ',';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NOP_STRING_APPLESOFT:
|
||||||
|
iByte = line_.nOpbyte;
|
||||||
|
strncpy( pDst, (const char*)(mem + nBaseAddress), iByte );
|
||||||
|
pDst += iByte;
|
||||||
|
*pDst = 0;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// else // 4 bytes
|
||||||
|
// if( line_.nOpbyte == 4)
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// else // 8 bytes
|
||||||
|
// if( line_.nOpbyte == 8)
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bDisasmFormatFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FormatDisassemblyLine( const DisasmLine_t & line, char * sDisassembly, const int nBufferSize )
|
void FormatDisassemblyLine( const DisasmLine_t & line, char * sDisassembly, const int nBufferSize )
|
||||||
{
|
{
|
||||||
//> Address Seperator Opcodes Label Mnemonic Target [Immediate] [Branch]
|
//> Address Seperator Opcodes Label Mnemonic Target [Immediate] [Branch]
|
||||||
|
//
|
||||||
|
// Data Disassembler
|
||||||
|
// Label Directive [Immediate]
|
||||||
const char * pMnemonic = g_aOpcodes[ line.iOpcode ].sMnemonic;
|
const char * pMnemonic = g_aOpcodes[ line.iOpcode ].sMnemonic;
|
||||||
|
|
||||||
sprintf( sDisassembly, "%s:%s %s "
|
sprintf( sDisassembly, "%s:%s %s "
|
||||||
@ -1528,14 +1590,29 @@ WORD DrawDisassemblyLine ( int iLine, const WORD nBaseAddress )
|
|||||||
int iOpmode;
|
int iOpmode;
|
||||||
int nOpbyte;
|
int nOpbyte;
|
||||||
DisasmLine_t line;
|
DisasmLine_t line;
|
||||||
|
LPCSTR pSymbol = NULL;
|
||||||
|
const char * pMnemonic = NULL;
|
||||||
|
|
||||||
int bDisasmFormatFlags = GetDisassemblyLine( nBaseAddress, line );
|
int bDisasmFormatFlags = GetDisassemblyLine( nBaseAddress, line );
|
||||||
|
DisasmData_t *pData = Disassembly_IsDataAddress( nBaseAddress );
|
||||||
|
if( pData )
|
||||||
|
{
|
||||||
|
Disassembly_GetData( nBaseAddress, pData, line );
|
||||||
|
// pSymbol = line.sLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
pSymbol = FindSymbolFromAddress( nBaseAddress );
|
||||||
|
// strcpy( line.sLabel, pSymbol );
|
||||||
|
}
|
||||||
|
|
||||||
iOpcode = line.iOpcode;
|
iOpcode = line.iOpcode;
|
||||||
iOpmode = line.iOpmode;
|
iOpmode = line.iOpmode;
|
||||||
nOpbyte = line.nOpbyte;
|
nOpbyte = line.nOpbyte;
|
||||||
|
|
||||||
|
// Data Disassembler
|
||||||
|
//
|
||||||
// sAddress, sOpcodes, sTarget, sTargetOffset, nTargetOffset, sTargetPointer, sTargetValue, sImmediate, nImmediate, sBranch );
|
// sAddress, sOpcodes, sTarget, sTargetOffset, nTargetOffset, sTargetPointer, sTargetValue, sImmediate, nImmediate, sBranch );
|
||||||
|
|
||||||
//> Address Seperator Opcodes Label Mnemonic Target [Immediate] [Branch]
|
//> Address Seperator Opcodes Label Mnemonic Target [Immediate] [Branch]
|
||||||
//
|
//
|
||||||
//> xxxx: xx xx xx LABEL MNEMONIC 'E' =
|
//> xxxx: xx xx xx LABEL MNEMONIC 'E' =
|
||||||
@ -1767,15 +1844,23 @@ WORD DrawDisassemblyLine ( int iLine, const WORD nBaseAddress )
|
|||||||
// linerect.left += (g_nFontWidthAvg * DISASM_SYMBOL_LEN);
|
// linerect.left += (g_nFontWidthAvg * DISASM_SYMBOL_LEN);
|
||||||
// PrintTextCursorX( " ", linerect );
|
// PrintTextCursorX( " ", linerect );
|
||||||
|
|
||||||
// Instruction
|
// Instruction / Mnemonic
|
||||||
linerect.left = (int) aTabs[ TS_INSTRUCTION ];
|
linerect.left = (int) aTabs[ TS_INSTRUCTION ];
|
||||||
|
|
||||||
if (! bCursorLine)
|
if (! bCursorLine)
|
||||||
DebuggerSetColorFG( DebuggerGetColor( iForeground ) );
|
DebuggerSetColorFG( DebuggerGetColor( iForeground ) );
|
||||||
|
|
||||||
const char * pMnemonic = g_aOpcodes[ iOpcode ].sMnemonic;
|
if( pData )
|
||||||
PrintTextCursorX( pMnemonic, linerect );
|
{
|
||||||
|
// pMnemonic = g_aAssemblerDirectives[ line.iNopcode ].sMnemonic;
|
||||||
|
pMnemonic = line.sMnemonic;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pMnemonic = g_aOpcodes[ iOpcode ].sMnemonic;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintTextCursorX( pMnemonic, linerect );
|
||||||
PrintTextCursorX( " ", linerect );
|
PrintTextCursorX( " ", linerect );
|
||||||
|
|
||||||
// Target
|
// Target
|
||||||
@ -1824,6 +1909,11 @@ WORD DrawDisassemblyLine ( int iLine, const WORD nBaseAddress )
|
|||||||
PrintTextCursorX( pTarget, linerect );
|
PrintTextCursorX( pTarget, linerect );
|
||||||
// PrintTextCursorX( " ", linerect );
|
// PrintTextCursorX( " ", linerect );
|
||||||
|
|
||||||
|
if( pData )
|
||||||
|
{
|
||||||
|
return nOpbyte;
|
||||||
|
}
|
||||||
|
|
||||||
// Target Offset +/-
|
// Target Offset +/-
|
||||||
if (bDisasmFormatFlags & DISASM_FORMAT_OFFSET)
|
if (bDisasmFormatFlags & DISASM_FORMAT_OFFSET)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user