mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-11-19 04:08:45 +00:00
2.6.2.25 Fixed: DB DW custom data byte sizes weren't scrolling properly in the disasm view.
Changed _6502_GetOpmodeOpbyte() to be aware of data bytes.
This commit is contained in:
parent
cca4aba747
commit
f19ed3b8c4
@ -488,11 +488,7 @@ int _6502_GetOpmodeOpbyte ( const int nBaseAddress, int & iOpmode_, int & nOpby
|
|||||||
|
|
||||||
switch( pData->eElementType )
|
switch( pData->eElementType )
|
||||||
{
|
{
|
||||||
case NOP_STRING_APPLESOFT:
|
default : nOpbyte_ = 1; iOpmode_ = AM_M; break;
|
||||||
// TODO: FIXME: scan memory for high byte
|
|
||||||
nOpbyte_ = 8;
|
|
||||||
iOpmode_ = AM_M;
|
|
||||||
break;
|
|
||||||
case NOP_BYTE_1: nOpbyte_ = 1; iOpmode_ = AM_M; break;
|
case NOP_BYTE_1: nOpbyte_ = 1; iOpmode_ = AM_M; break;
|
||||||
case NOP_BYTE_2: nOpbyte_ = 2; iOpmode_ = AM_M; break;
|
case NOP_BYTE_2: nOpbyte_ = 2; iOpmode_ = AM_M; break;
|
||||||
case NOP_BYTE_4: nOpbyte_ = 4; iOpmode_ = AM_M; break;
|
case NOP_BYTE_4: nOpbyte_ = 4; iOpmode_ = AM_M; break;
|
||||||
@ -500,9 +496,14 @@ int _6502_GetOpmodeOpbyte ( const int nBaseAddress, int & iOpmode_, int & nOpby
|
|||||||
case NOP_WORD_1: nOpbyte_ = 2; iOpmode_ = AM_M; break;
|
case NOP_WORD_1: nOpbyte_ = 2; iOpmode_ = AM_M; break;
|
||||||
case NOP_WORD_2: nOpbyte_ = 4; iOpmode_ = AM_M; break;
|
case NOP_WORD_2: nOpbyte_ = 4; iOpmode_ = AM_M; break;
|
||||||
case NOP_WORD_4: nOpbyte_ = 8; iOpmode_ = AM_M; break;
|
case NOP_WORD_4: nOpbyte_ = 8; iOpmode_ = AM_M; break;
|
||||||
case NOP_ADDRESS:nOpbyte_ = 2; iOpmode_ = AM_NA; break;
|
case NOP_ADDRESS:nOpbyte_ = 2; iOpmode_ = AM_NA;
|
||||||
// case NOP_ADDRESS:nOpbytes = 2; iOpmode_ = AM_NA; line_.nTarget = *(LPWORD)(mem+nBaseAddress); break;
|
pData->nTargetAddress = *(LPWORD)(mem+nBaseAddress);
|
||||||
default :nOpbyte_ = 1; iOpmode_ = AM_M; break;
|
break;
|
||||||
|
case NOP_STRING_APPLESOFT:
|
||||||
|
// TODO: FIXME: scan memory for high byte
|
||||||
|
nOpbyte_ = 8;
|
||||||
|
iOpmode_ = AM_M;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we are not element aligned ...
|
// Check if we are not element aligned ...
|
||||||
|
@ -1208,7 +1208,7 @@ void DrawConsoleInput ()
|
|||||||
// Disassembly ____________________________________________________________________________________
|
// Disassembly ____________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
// Get the data needed to disassemble one line of opcodes
|
// Get the data needed to disassemble one line of opcodes. Fills in the DisasmLine info.
|
||||||
// Disassembly formatting flags returned
|
// Disassembly formatting flags returned
|
||||||
// @parama sTargetValue_ indirect/indexed final value
|
// @parama sTargetValue_ indirect/indexed final value
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
@ -1225,12 +1225,13 @@ int GetDisassemblyLine ( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
int nOpbyte;
|
int nOpbyte;
|
||||||
|
|
||||||
iOpcode = _6502_GetOpmodeOpbyte( nBaseAddress, iOpmode, nOpbyte );
|
iOpcode = _6502_GetOpmodeOpbyte( nBaseAddress, iOpmode, nOpbyte );
|
||||||
|
DisasmData_t* pData = Disassembly_IsDataAddress( nBaseAddress );
|
||||||
|
line_.pDisasmData = pData;
|
||||||
|
|
||||||
line_.iOpcode = iOpcode;
|
line_.iOpcode = iOpcode;
|
||||||
line_.iOpmode = iOpmode;
|
line_.iOpmode = iOpmode;
|
||||||
line_.nOpbyte = nOpbyte;
|
line_.nOpbyte = nOpbyte;
|
||||||
|
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
// if (iLine != 41)
|
// if (iLine != 41)
|
||||||
// return nOpbytes;
|
// return nOpbytes;
|
||||||
@ -1261,17 +1262,23 @@ int GetDisassemblyLine ( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
|
|
||||||
// Composite string that has the symbol or target nAddress
|
// Composite string that has the symbol or target nAddress
|
||||||
WORD nTarget = 0;
|
WORD nTarget = 0;
|
||||||
line_.nTargetOffset = 0;
|
|
||||||
|
|
||||||
// if (g_aOpmodes[ iMode ]._sFormat[0])
|
|
||||||
if ((iOpmode != AM_IMPLIED) &&
|
if ((iOpmode != AM_IMPLIED) &&
|
||||||
(iOpmode != AM_1) &&
|
(iOpmode != AM_1) &&
|
||||||
(iOpmode != AM_2) &&
|
(iOpmode != AM_2) &&
|
||||||
(iOpmode != AM_3))
|
(iOpmode != AM_3))
|
||||||
{
|
{
|
||||||
nTarget = *(LPWORD)(mem+nBaseAddress+1);
|
// Assume target address starts after the opcode ...
|
||||||
if (nOpbyte == 2)
|
// BUT in the Assembler Directve / Data Disassembler case for define addr/word
|
||||||
nTarget &= 0xFF;
|
// the opcode literally IS the target address!
|
||||||
|
if( pData )
|
||||||
|
{
|
||||||
|
nTarget = pData->nTargetAddress;
|
||||||
|
} else {
|
||||||
|
nTarget = *(LPWORD)(mem+nBaseAddress+1);
|
||||||
|
if (nOpbyte == 2)
|
||||||
|
nTarget &= 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
if (iOpmode == AM_R) // Relative
|
if (iOpmode == AM_R) // Relative
|
||||||
{
|
{
|
||||||
@ -1314,12 +1321,19 @@ int GetDisassemblyLine ( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
(iOpmode == AM_IAX) || // Indexed (Absolute Indirect, X)
|
(iOpmode == AM_IAX) || // Indexed (Absolute Indirect, X)
|
||||||
(iOpmode == AM_NZY) || // Indirect (Zeropage) Index, Y
|
(iOpmode == AM_NZY) || // Indirect (Zeropage) Index, Y
|
||||||
(iOpmode == AM_NZ ) || // Indirect (Zeropage)
|
(iOpmode == AM_NZ ) || // Indirect (Zeropage)
|
||||||
(iOpmode == AM_NA )) // Indirect Absolute
|
(iOpmode == AM_NA )) //(Indirect Absolute)
|
||||||
{
|
{
|
||||||
line_.nTarget = nTarget;
|
line_.nTarget = nTarget;
|
||||||
|
|
||||||
LPCTSTR pTarget = NULL;
|
const char* pTarget = NULL;
|
||||||
LPCTSTR pSymbol = FindSymbolFromAddress( nTarget );
|
const char* pSymbol = 0;
|
||||||
|
|
||||||
|
pSymbol = FindSymbolFromAddress( nTarget );
|
||||||
|
|
||||||
|
// Data Assembler
|
||||||
|
if (pData && (!pData->bSymbolLookup))
|
||||||
|
pSymbol = 0;
|
||||||
|
|
||||||
if (pSymbol)
|
if (pSymbol)
|
||||||
{
|
{
|
||||||
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
|
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
|
||||||
@ -1440,6 +1454,18 @@ int GetDisassemblyLine ( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
// Opcode Bytes
|
// Opcode Bytes
|
||||||
FormatOpcodeBytes( nBaseAddress, line_ );
|
FormatOpcodeBytes( nBaseAddress, line_ );
|
||||||
|
|
||||||
|
// Data Disassembler
|
||||||
|
if( pData )
|
||||||
|
{
|
||||||
|
line_.iNoptype = pData->eElementType;
|
||||||
|
line_.iNopcode = pData->iDirective;
|
||||||
|
strcpy( line_.sMnemonic, g_aAssemblerDirectives[ line_.iNopcode ].m_pMnemonic );
|
||||||
|
|
||||||
|
FormatNopcodeBytes( nBaseAddress, line_ );
|
||||||
|
} else { // Regular 6502/65C02 opcode -> mnemonic
|
||||||
|
strcpy( line_.sMnemonic, g_aOpcodes[ line_.iOpcode ].sMnemonic );
|
||||||
|
}
|
||||||
|
|
||||||
int nSpaces = strlen( line_.sOpCodes );
|
int nSpaces = strlen( line_.sOpCodes );
|
||||||
while (nSpaces < (int)nMinBytesLen)
|
while (nSpaces < (int)nMinBytesLen)
|
||||||
{
|
{
|
||||||
@ -1450,6 +1476,23 @@ int GetDisassemblyLine ( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
return bDisasmFormatFlags;
|
return bDisasmFormatFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
const char* FormatAddress( WORD nAddress, int nBytes )
|
||||||
|
{
|
||||||
|
// There is no symbol for this nAddress
|
||||||
|
static TCHAR sSymbol[8] = TEXT("");
|
||||||
|
switch (nBytes)
|
||||||
|
{
|
||||||
|
case 2: wsprintf(sSymbol,TEXT("$%02X"),(unsigned)nAddress); break;
|
||||||
|
case 3: wsprintf(sSymbol,TEXT("$%04X"),(unsigned)nAddress); break;
|
||||||
|
// TODO: FIXME: Can we get called with nBytes == 16 ??
|
||||||
|
default: sSymbol[0] = 0; break; // clear since is static
|
||||||
|
}
|
||||||
|
return sSymbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void FormatOpcodeBytes ( WORD nBaseAddress, DisasmLine_t & line_ )
|
void FormatOpcodeBytes ( WORD nBaseAddress, DisasmLine_t & line_ )
|
||||||
{
|
{
|
||||||
@ -1483,7 +1526,9 @@ void FormatNopcodeBytes ( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
switch( line_.iNoptype )
|
switch( line_.iNoptype )
|
||||||
{
|
{
|
||||||
case NOP_BYTE_1:
|
case NOP_BYTE_1:
|
||||||
sprintf( pDst, "$%02X", nTarget8 ); // sBytes+strlen(sBytes)
|
case NOP_BYTE_2:
|
||||||
|
case NOP_BYTE_4:
|
||||||
|
sprintf( pDst, "%02X", nTarget8 ); // sBytes+strlen(sBytes)
|
||||||
pDst += 3;
|
pDst += 3;
|
||||||
iByte++;
|
iByte++;
|
||||||
if( iByte < line_.nOpbyte )
|
if( iByte < line_.nOpbyte )
|
||||||
@ -1492,7 +1537,9 @@ void FormatNopcodeBytes ( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NOP_WORD_1:
|
case NOP_WORD_1:
|
||||||
sprintf( pDst, "$%04X", nTarget16 ); // sBytes+strlen(sBytes)
|
case NOP_WORD_2:
|
||||||
|
case NOP_WORD_4:
|
||||||
|
sprintf( pDst, "%04X", nTarget16 ); // sBytes+strlen(sBytes)
|
||||||
pDst += 5;
|
pDst += 5;
|
||||||
iByte+= 2;
|
iByte+= 2;
|
||||||
if( iByte < line_.nOpbyte )
|
if( iByte < line_.nOpbyte )
|
||||||
@ -1506,16 +1553,13 @@ void FormatNopcodeBytes ( WORD nBaseAddress, DisasmLine_t & line_ )
|
|||||||
pDst += iByte;
|
pDst += iByte;
|
||||||
*pDst = 0;
|
*pDst = 0;
|
||||||
default:
|
default:
|
||||||
|
#if _DEBUG
|
||||||
|
int *FATAL = 0;
|
||||||
|
*FATAL = 0xDEADC0DE;
|
||||||
|
#endif
|
||||||
|
iByte++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// else // 4 bytes
|
|
||||||
// if( line_.nOpbyte == 4)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// else // 8 bytes
|
|
||||||
// if( line_.nOpbyte == 8)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1595,28 +1639,17 @@ 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* pSymbol = FindSymbolFromAddress( nBaseAddress );
|
||||||
const char * pMnemonic = NULL;
|
const char* pMnemonic = NULL;
|
||||||
|
|
||||||
|
// Data Disassembler
|
||||||
int bDisasmFormatFlags = GetDisassemblyLine( nBaseAddress, line );
|
int bDisasmFormatFlags = GetDisassemblyLine( nBaseAddress, line );
|
||||||
DisasmData_t *pData = Disassembly_IsDataAddress( nBaseAddress );
|
const DisasmData_t *pData = line.pDisasmData;
|
||||||
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]
|
||||||
//
|
//
|
||||||
@ -1839,7 +1872,6 @@ WORD DrawDisassemblyLine ( int iLine, const WORD nBaseAddress )
|
|||||||
// Label
|
// Label
|
||||||
linerect.left = (int) aTabs[ TS_LABEL ];
|
linerect.left = (int) aTabs[ TS_LABEL ];
|
||||||
|
|
||||||
LPCSTR pSymbol = FindSymbolFromAddress( nBaseAddress );
|
|
||||||
if (pSymbol)
|
if (pSymbol)
|
||||||
{
|
{
|
||||||
if (! bCursorLine)
|
if (! bCursorLine)
|
||||||
@ -1853,20 +1885,14 @@ WORD DrawDisassemblyLine ( int iLine, const WORD nBaseAddress )
|
|||||||
linerect.left = (int) aTabs[ TS_INSTRUCTION ];
|
linerect.left = (int) aTabs[ TS_INSTRUCTION ];
|
||||||
|
|
||||||
if (! bCursorLine)
|
if (! bCursorLine)
|
||||||
DebuggerSetColorFG( DebuggerGetColor( iForeground ) );
|
|
||||||
|
|
||||||
if( pData )
|
|
||||||
{
|
{
|
||||||
// pMnemonic = g_aAssemblerDirectives[ line.iNopcode ].sMnemonic;
|
if( pData ) // Assembler Data Directive / Data Disassembler
|
||||||
if (! bCursorLine) // Assembler Data Directive
|
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_DIRECTIVE ) ); // TODO: FIXME: HACK? Is the color fine?
|
||||||
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_DIRECTIVE ) ); // ZZZ TODO: FIXME:
|
else
|
||||||
pMnemonic = line.sMnemonic;
|
DebuggerSetColorFG( DebuggerGetColor( iForeground ) );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pMnemonic = g_aOpcodes[ iOpcode ].sMnemonic;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pMnemonic = line.sMnemonic;
|
||||||
PrintTextCursorX( pMnemonic, linerect );
|
PrintTextCursorX( pMnemonic, linerect );
|
||||||
PrintTextCursorX( " ", linerect );
|
PrintTextCursorX( " ", linerect );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user