2010-06-11 15:38:22 +00:00
|
|
|
/*
|
|
|
|
AppleWin : An Apple //e emulator for Windows
|
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
Copyright (C) 2006-2014, Tom Charlesworth, Michael Pohoreski
|
2010-12-18 14:55:21 +00:00
|
|
|
|
|
|
|
AppleWin is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
AppleWin is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with AppleWin; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
/* Description: Data Blocks shown in Disassembler
|
|
|
|
*
|
2010-12-18 14:55:21 +00:00
|
|
|
* Author: Copyright (C) 2009 - 2010 Michael Pohoreski
|
2010-06-11 15:38:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
2014-08-13 20:30:35 +00:00
|
|
|
#include "Debug.h"
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
|
|
|
|
// Disassembler Data ______________________________________________________________________________
|
|
|
|
|
2014-08-29 15:51:29 +00:00
|
|
|
// __ Debugger Interface ____________________________________________________________________________
|
2010-06-11 15:38:22 +00:00
|
|
|
|
2022-05-01 13:08:45 +00:00
|
|
|
std::string _GetAutoSymbolName(const Nopcode_e& nopcode, const WORD nStartAddress)
|
2022-01-04 05:05:37 +00:00
|
|
|
{
|
|
|
|
switch (nopcode)
|
|
|
|
{
|
|
|
|
case NOP_ADDRESS:
|
2022-05-01 13:08:45 +00:00
|
|
|
return StrFormat( "A_%04X", nStartAddress ); // DA range
|
2022-01-04 05:05:37 +00:00
|
|
|
|
2022-01-06 18:10:09 +00:00
|
|
|
case NOP_FAC:
|
2022-05-01 13:08:45 +00:00
|
|
|
return StrFormat( "F_%04X", nStartAddress ); // DF range
|
2022-01-06 18:10:09 +00:00
|
|
|
|
2022-01-04 05:05:37 +00:00
|
|
|
case NOP_STRING_ASCII:
|
|
|
|
case NOP_STRING_APPLE:
|
2022-05-01 13:08:45 +00:00
|
|
|
return StrFormat( "T_%04X", nStartAddress ); // ASC range
|
2022-01-04 05:05:37 +00:00
|
|
|
|
|
|
|
case NOP_WORD_1:
|
|
|
|
case NOP_WORD_2:
|
|
|
|
case NOP_WORD_4:
|
2022-05-01 13:08:45 +00:00
|
|
|
return StrFormat( "W_%04X", nStartAddress ); // DW range
|
2022-01-04 05:05:37 +00:00
|
|
|
|
|
|
|
case NOP_BYTE_1:
|
|
|
|
case NOP_BYTE_2:
|
|
|
|
case NOP_BYTE_4:
|
|
|
|
case NOP_BYTE_8:
|
|
|
|
default:
|
2022-05-01 13:08:45 +00:00
|
|
|
return StrFormat( "B_%04X", nStartAddress ); // DB range
|
2022-01-04 05:05:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// @param tData_ Filled out with range data
|
2010-06-11 15:38:22 +00:00
|
|
|
//===========================================================================
|
2022-01-04 05:07:49 +00:00
|
|
|
WORD _GetDataRange (int nArgs, int iArg, DisasmData_t& tData_)
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
|
|
|
WORD nAddress = 0;
|
|
|
|
WORD nAddress2 = 0;
|
|
|
|
WORD nEnd = 0;
|
|
|
|
int nLen = 0;
|
|
|
|
|
2010-12-16 06:43:05 +00:00
|
|
|
memset( (void*) &tData_, 0, sizeof(tData_) );
|
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
// DB address
|
|
|
|
// DB symbol
|
|
|
|
// bool bisAddress ...
|
|
|
|
|
2022-01-04 05:07:49 +00:00
|
|
|
if (nArgs < 1)
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
|
|
|
nAddress = g_nDisasmCurAddress;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-04 05:07:49 +00:00
|
|
|
// DB foo = 300 // nArgs == 3
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
RangeType_t eRange = Range_Get( nAddress, nAddress2, iArg);
|
|
|
|
if ((eRange == RANGE_HAS_END) ||
|
|
|
|
(eRange == RANGE_HAS_LEN))
|
|
|
|
{
|
|
|
|
Range_CalcEndLen( eRange, nAddress, nAddress2, nEnd, nLen );
|
2014-08-28 18:13:02 +00:00
|
|
|
nLen--; // Disassembly_IsDataAddress() is *inclusive* // KEEP IN SYNC: _CmdDefineByteRange() CmdDisasmDataList() _6502_GetOpmodeOpbyte() FormatNopcodeBytes()
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-04 05:11:25 +00:00
|
|
|
if (nArgs > 1)
|
|
|
|
{
|
|
|
|
// 2.9.1.1 Add: Support for equal sign, also make it optional for command DB
|
|
|
|
// DB FOO 300
|
|
|
|
// DB FOO = 300
|
|
|
|
if (g_aArgs[2].bType == TOKEN_EQUAL)
|
|
|
|
nAddress = g_aArgs[ 3 ].nValue;
|
|
|
|
else
|
|
|
|
nAddress = g_aArgs[ 2 ].nValue;
|
|
|
|
}
|
2014-08-28 18:13:02 +00:00
|
|
|
else
|
|
|
|
nAddress = g_aArgs[ 1 ].nValue;
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-01 16:49:55 +00:00
|
|
|
// 2.7.0.35 DW address -- round the length up to even number for convenience.
|
|
|
|
// Example: 'DW 6062' is equivalent to: 'DW 6062:6063'
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( g_iCommand == CMD_DEFINE_DATA_WORD1 )
|
2014-09-01 16:49:55 +00:00
|
|
|
{
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( ~nLen & 1 )
|
2014-09-01 16:49:55 +00:00
|
|
|
nLen++;
|
|
|
|
}
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
tData_.nStartAddress = nAddress;
|
|
|
|
tData_.nEndAddress = nAddress + nLen;
|
2022-01-04 05:07:49 +00:00
|
|
|
|
|
|
|
return nAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
WORD _CmdDefineByteRange(int nArgs,int iArg,DisasmData_t & tData_)
|
|
|
|
{
|
|
|
|
WORD nAddress = 0;
|
|
|
|
WORD nAddress2 = 0;
|
|
|
|
WORD nEnd = 0;
|
|
|
|
int nLen = 0;
|
|
|
|
|
|
|
|
nAddress = _GetDataRange(nArgs,iArg,tData_);
|
2014-08-28 18:13:02 +00:00
|
|
|
|
2022-05-01 13:08:45 +00:00
|
|
|
std::string sSymbolName;
|
2022-01-04 05:07:49 +00:00
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
SymbolTable_Index_e eSymbolTable = SYMBOLS_ASSEMBLY;
|
2014-09-01 16:49:55 +00:00
|
|
|
bool bAutoDefineName = false; // 2.7.0.34
|
2014-08-28 18:13:02 +00:00
|
|
|
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( nArgs > 1 )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( g_aArgs[ 2 ].eToken == TOKEN_COLON ) // 2.7.0.31 Bug fix: DB range, i.e. DB 174E:174F
|
2018-11-06 19:12:10 +00:00
|
|
|
{
|
2014-09-01 16:49:55 +00:00
|
|
|
bAutoDefineName = true;
|
2018-11-06 19:12:10 +00:00
|
|
|
}
|
2014-08-29 05:23:47 +00:00
|
|
|
else
|
2018-11-06 19:12:10 +00:00
|
|
|
{
|
2021-02-10 21:05:00 +00:00
|
|
|
g_aArgs[ 1 ].sArg[MAX_SYMBOLS_LEN] = 0; // truncate to max symbol length
|
2022-05-01 13:08:45 +00:00
|
|
|
sSymbolName = g_aArgs[1].sArg;
|
2018-11-06 19:12:10 +00:00
|
|
|
}
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-01 16:49:55 +00:00
|
|
|
bAutoDefineName = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2.7.0.34 Unified auto-defined name: B_, W_, T_ for byte, word, or text respectively
|
|
|
|
// Old name: auto define D_# DB $XX
|
|
|
|
// Example 'DB' or 'DW' with 1 arg
|
|
|
|
// DB 801
|
2022-04-03 17:15:22 +00:00
|
|
|
Nopcode_e nopcode = NOP_BYTE_1;
|
2022-01-04 05:07:49 +00:00
|
|
|
|
2022-04-03 17:15:22 +00:00
|
|
|
bool isFloat = (g_iCommand == CMD_DEFINE_DATA_FLOAT);
|
|
|
|
if ( isFloat )
|
|
|
|
nopcode = NOP_FAC;
|
2022-01-06 18:10:09 +00:00
|
|
|
|
2022-04-03 17:15:22 +00:00
|
|
|
bool isString = (g_iCommand == CMD_DEFINE_DATA_STR);
|
|
|
|
if ( isString )
|
|
|
|
nopcode = NOP_STRING_ASCII;
|
2022-01-04 05:07:49 +00:00
|
|
|
|
2022-04-03 17:15:22 +00:00
|
|
|
bool isWord1 = (g_iCommand == CMD_DEFINE_DATA_WORD1);
|
|
|
|
if ( isWord1 )
|
|
|
|
nopcode = NOP_WORD_1;
|
2022-01-04 05:07:49 +00:00
|
|
|
|
2022-04-03 17:15:22 +00:00
|
|
|
bool isAddr = (g_iCommand == CMD_DEFINE_ADDR_WORD);
|
|
|
|
if ( isAddr )
|
|
|
|
nopcode = NOP_ADDRESS;
|
2014-09-01 16:49:55 +00:00
|
|
|
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( bAutoDefineName )
|
2022-01-06 18:10:09 +00:00
|
|
|
{
|
2022-05-01 13:08:45 +00:00
|
|
|
sSymbolName = _GetAutoSymbolName( nopcode, tData_.nStartAddress );
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
// bRemoveSymbol = false // use arg[2]
|
|
|
|
// bUpdateSymbol = true // add the symbol to the table
|
2022-05-01 13:08:45 +00:00
|
|
|
SymbolUpdate( eSymbolTable, sSymbolName.c_str(), nAddress, false, true );
|
2014-08-28 18:13:02 +00:00
|
|
|
|
|
|
|
// TODO: Note: need to call ConsoleUpdate(), as may print symbol has been updated
|
2022-01-06 18:10:09 +00:00
|
|
|
|
|
|
|
// NOTE: We don't set the type here
|
|
|
|
// tData_.eElementType = nopcode;
|
|
|
|
// As that is done by the caller.
|
2014-08-28 18:13:02 +00:00
|
|
|
|
2022-05-01 13:08:45 +00:00
|
|
|
strncpy_s( tData_.sSymbol, sSymbolName.c_str(), _TRUNCATE );
|
2010-06-11 15:38:22 +00:00
|
|
|
|
|
|
|
return nAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Undefine Data
|
2022-01-04 05:07:49 +00:00
|
|
|
//
|
|
|
|
// X
|
|
|
|
// X addr
|
|
|
|
// X addr:addr
|
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
// DB hgr 2000:3FFF
|
|
|
|
// U 1FFF
|
|
|
|
// X 1FFF:2001
|
2010-06-11 15:38:22 +00:00
|
|
|
//===========================================================================
|
|
|
|
Update_t CmdDisasmDataDefCode (int nArgs)
|
|
|
|
{
|
|
|
|
// treat memory (bytes) as code
|
2022-01-04 05:07:49 +00:00
|
|
|
if (! ((nArgs <= 2) || (nArgs == 4)) && (nArgs != 3))
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
|
|
|
return Help_Arg_1( CMD_DISASM_CODE );
|
|
|
|
}
|
|
|
|
|
2022-01-04 05:07:49 +00:00
|
|
|
DisasmData_t tData; // X 1FFF:2001
|
|
|
|
WORD nAddress = 0; // 8191
|
|
|
|
int iArg = 0;
|
|
|
|
|
|
|
|
if (nArgs == 3)
|
|
|
|
{
|
|
|
|
iArg = 1; // #### : ####
|
|
|
|
nAddress = _GetDataRange( nArgs, iArg, tData );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iArg = 2;
|
|
|
|
nAddress = _GetDataRange( nArgs, iArg, tData );
|
|
|
|
}
|
2010-06-11 15:38:22 +00:00
|
|
|
|
|
|
|
// Need to iterate through all blocks
|
|
|
|
// DB TEST1 300:320
|
|
|
|
// DB TEST2 310:330
|
|
|
|
// DB TEST3 320:340
|
2014-08-29 15:51:29 +00:00
|
|
|
// X TEST1
|
2010-06-11 15:38:22 +00:00
|
|
|
|
2022-01-04 05:07:49 +00:00
|
|
|
/*
|
|
|
|
// Edge cases:
|
|
|
|
U 1FFF
|
|
|
|
DB 2000:2005
|
|
|
|
X 1FFF:2001 // Chop 2 head
|
|
|
|
X 2004:2006 // Chop 2 tail
|
|
|
|
X 1FFF:2006 // Chop entire
|
|
|
|
|
|
|
|
U 1FFF
|
|
|
|
DB 2000:2000
|
|
|
|
X 2000:2000 // Chop entire
|
|
|
|
|
|
|
|
U 1FFF
|
|
|
|
DB 2000:2002
|
|
|
|
X 2001:2001 // Chop middle
|
|
|
|
|
|
|
|
U 1FFF
|
|
|
|
DB 2000:2005
|
|
|
|
X 2002:2003 // Chop middle
|
|
|
|
*/
|
|
|
|
while (nAddress <= tData.nEndAddress)
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
2022-01-04 05:07:49 +00:00
|
|
|
DisasmData_t *pData = Disassembly_IsDataAddress( nAddress );
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( pData )
|
2022-01-04 05:07:49 +00:00
|
|
|
{
|
|
|
|
if (( nAddress <= pData->nStartAddress)
|
|
|
|
&& (tData.nEndAddress >= pData->nEndAddress ))
|
|
|
|
{
|
|
|
|
// remove entire
|
|
|
|
Disassembly_DelData( *pData );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (( nAddress <= pData->nStartAddress)
|
|
|
|
&& (tData.nStartAddress < pData->nEndAddress ))
|
|
|
|
{
|
|
|
|
// head
|
|
|
|
pData->nStartAddress = nAddress+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (( nAddress > pData->nStartAddress)
|
|
|
|
&& (tData.nEndAddress >= pData->nEndAddress ))
|
|
|
|
{
|
|
|
|
// tail
|
|
|
|
pData->nEndAddress = nAddress-1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// middle
|
|
|
|
SymbolTable_Index_e eSymbolTable = SYMBOLS_ASSEMBLY;
|
2014-08-28 18:13:02 +00:00
|
|
|
|
2022-01-04 05:07:49 +00:00
|
|
|
DisasmData_t tSplit = *pData;
|
|
|
|
pData->nEndAddress = nAddress - 1;
|
|
|
|
|
|
|
|
tSplit.nStartAddress = tData.nEndAddress + 1; // nAddress + 1;
|
2022-05-01 13:08:45 +00:00
|
|
|
std::string sSymbolName = _GetAutoSymbolName( pData->eElementType, tSplit.nStartAddress );
|
|
|
|
strncpy_s(tSplit.sSymbol, sSymbolName.c_str(), _TRUNCATE);
|
2022-01-04 05:07:49 +00:00
|
|
|
|
2022-05-01 13:08:45 +00:00
|
|
|
SymbolUpdate( eSymbolTable, tSplit.sSymbol, tSplit.nStartAddress, false, true );
|
2022-01-04 05:07:49 +00:00
|
|
|
Disassembly_AddData( tSplit );
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Remove symbol 'D_FA62' from symbol table!
|
|
|
|
}
|
|
|
|
|
|
|
|
nAddress++;
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return UPDATE_DISASM | ConsoleUpdate();
|
|
|
|
}
|
|
|
|
|
2021-02-10 21:05:00 +00:00
|
|
|
const char* g_aNopcodeTypes[ NUM_NOPCODE_TYPES ] =
|
2010-12-16 07:32:59 +00:00
|
|
|
{
|
|
|
|
"-n/a-"
|
|
|
|
,"byte1"
|
|
|
|
,"byte2"
|
|
|
|
,"byte4"
|
|
|
|
,"byte8"
|
|
|
|
,"word1"
|
|
|
|
,"word2"
|
|
|
|
,"word4"
|
|
|
|
,"addr "
|
|
|
|
,"hex "
|
|
|
|
,"char "
|
|
|
|
,"ascii"
|
|
|
|
,"apple"
|
|
|
|
,"mixed"
|
|
|
|
,"FAC "
|
|
|
|
,"bmp "
|
|
|
|
};
|
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
// Command: B
|
|
|
|
// no args
|
2010-06-11 15:38:22 +00:00
|
|
|
// List the data blocks
|
|
|
|
//===========================================================================
|
|
|
|
Update_t CmdDisasmDataList (int nArgs)
|
|
|
|
{
|
2014-08-28 18:13:02 +00:00
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
// Need to iterate through all blocks
|
|
|
|
DisasmData_t* pData = NULL;
|
2010-12-16 07:32:59 +00:00
|
|
|
|
2022-03-27 19:48:26 +00:00
|
|
|
while ( (pData = Disassembly_Enumerate( pData )) )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
2010-12-16 07:32:59 +00:00
|
|
|
if (pData->iDirective != _NOP_REMOVED)
|
|
|
|
{
|
2022-05-01 13:08:45 +00:00
|
|
|
bool hasSymbol = pData->sSymbol[0] != '\0';
|
2010-12-16 07:32:59 +00:00
|
|
|
|
2022-05-01 14:15:09 +00:00
|
|
|
// <symbol> <type> <start>:<end>
|
2010-12-16 07:32:59 +00:00
|
|
|
// `TEST `300`:`320
|
2022-05-01 13:08:45 +00:00
|
|
|
ConsolePrintFormat( CHC_CATEGORY "%s %s%*s " CHC_ADDRESS "%04X" CHC_ARG_SEP ":" CHC_ADDRESS "%04X"
|
2010-12-16 07:32:59 +00:00
|
|
|
, g_aNopcodeTypes[ pData->eElementType ]
|
2022-05-01 13:08:45 +00:00
|
|
|
, hasSymbol ? CHC_SYMBOL : CHC_DEFAULT
|
2010-12-16 07:39:07 +00:00
|
|
|
, MAX_SYMBOLS_LEN
|
2022-05-01 13:08:45 +00:00
|
|
|
, hasSymbol ? pData->sSymbol : "???"
|
2010-12-16 07:32:59 +00:00
|
|
|
, pData->nStartAddress
|
2014-08-28 18:13:02 +00:00
|
|
|
, pData->nEndAddress // Disassembly_IsDataAddress() is *inclusive* // KEEP IN SYNC: _CmdDefineByteRange() CmdDisasmDataList() _6502_GetOpmodeOpbyte() FormatNopcodeBytes()
|
2010-12-16 07:32:59 +00:00
|
|
|
);
|
|
|
|
}
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return UPDATE_DISASM | ConsoleUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Common code
|
2022-01-06 18:10:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
// TODO: merge _CmdDisasmDataDefByteX() and _CmdDisasmDataDefWordX
|
|
|
|
// add params( iDirective, iOpcode ) to allow ASM_DEFINE_FLOAT, NOP_FAC
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
//===========================================================================
|
|
|
|
Update_t _CmdDisasmDataDefByteX (int nArgs)
|
|
|
|
{
|
|
|
|
// DB
|
2014-08-28 18:13:02 +00:00
|
|
|
// DB symbol // use current instruction pointer
|
2010-06-11 15:38:22 +00:00
|
|
|
// DB symbol address
|
2010-12-16 06:43:05 +00:00
|
|
|
// DB symbol range:range
|
2014-08-28 18:13:02 +00:00
|
|
|
// DB address
|
|
|
|
// To "return to code" use ."X"
|
2010-12-19 17:29:51 +00:00
|
|
|
int iCmd = g_aArgs[0].nValue - NOP_BYTE_1;
|
2010-06-11 15:38:22 +00:00
|
|
|
|
2014-08-29 05:27:24 +00:00
|
|
|
if (nArgs > 4) // 2.7.0.31 Bug fix: DB range, i.e. DB 174E:174F
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
|
|
|
return Help_Arg_1( CMD_DEFINE_DATA_BYTE1 + iCmd );
|
|
|
|
}
|
|
|
|
|
|
|
|
DisasmData_t tData;
|
|
|
|
int iArg = 2;
|
2014-08-29 05:23:47 +00:00
|
|
|
|
2014-08-29 05:27:24 +00:00
|
|
|
if (nArgs == 3 ) // 2.7.0.31 Bug fix: DB range, i.e. DB 174E:175F
|
2014-08-29 05:23:47 +00:00
|
|
|
{
|
|
|
|
if ( g_aArgs[ 2 ].eToken == TOKEN_COLON )
|
|
|
|
iArg = 1;
|
|
|
|
}
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
WORD nAddress = _CmdDefineByteRange( nArgs, iArg, tData );
|
|
|
|
|
2010-12-16 06:43:05 +00:00
|
|
|
// TODO: Allow user to select which assembler to use for displaying directives!
|
|
|
|
// tData.iDirective = FIRST_M_DIRECTIVE + ASM_M_DEFINE_BYTE;
|
|
|
|
tData.iDirective = g_aAssemblerFirstDirective[ g_iAssemblerSyntax ] + ASM_DEFINE_BYTE;
|
|
|
|
|
2010-12-19 16:56:43 +00:00
|
|
|
tData.eElementType = (Nopcode_e)( NOP_BYTE_1 + iCmd );
|
2010-06-11 15:38:22 +00:00
|
|
|
tData.bSymbolLookup = false;
|
|
|
|
tData.nTargetAddress = 0;
|
|
|
|
|
|
|
|
// Already exists, so update
|
|
|
|
DisasmData_t *pData = Disassembly_IsDataAddress( nAddress );
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( pData )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
|
|
|
*pData = tData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Disassembly_AddData( tData );
|
|
|
|
|
|
|
|
return UPDATE_DISASM | ConsoleUpdate();
|
|
|
|
}
|
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
/*
|
|
|
|
Usage:
|
|
|
|
DW
|
|
|
|
DW symbol
|
|
|
|
DW symbol address
|
|
|
|
DW symbol range:range
|
2014-08-29 15:51:29 +00:00
|
|
|
DW address Auto-define W_#### where # is the address
|
|
|
|
DW range Auto-define W_#### where # is the address
|
2014-08-28 18:13:02 +00:00
|
|
|
Examples:
|
2014-08-29 15:51:29 +00:00
|
|
|
DW 3F2:3F3
|
2014-08-28 18:13:02 +00:00
|
|
|
*/
|
2014-08-29 15:51:29 +00:00
|
|
|
//===========================================================================
|
|
|
|
Update_t _CmdDisasmDataDefWordX (int nArgs)
|
|
|
|
{
|
2010-12-19 17:29:51 +00:00
|
|
|
int iCmd = g_aArgs[0].nValue - NOP_WORD_1;
|
2010-06-11 15:38:22 +00:00
|
|
|
|
2014-08-29 15:51:29 +00:00
|
|
|
if (nArgs > 4) // 2.7.0.31 Bug fix: DB range, i.e. DB 174E:174F
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
|
|
|
return Help_Arg_1( CMD_DEFINE_DATA_WORD1 + iCmd );
|
|
|
|
}
|
|
|
|
|
|
|
|
DisasmData_t tData;
|
|
|
|
int iArg = 2;
|
2014-08-29 15:51:29 +00:00
|
|
|
|
|
|
|
if (nArgs == 3 ) // 2.7.0.33 Bug fix: DW range, i.e. DW 3F2:3F3
|
|
|
|
{
|
|
|
|
if ( g_aArgs[ 2 ].eToken == TOKEN_COLON )
|
|
|
|
iArg = 1;
|
|
|
|
}
|
|
|
|
|
2010-06-11 15:38:22 +00:00
|
|
|
WORD nAddress = _CmdDefineByteRange( nArgs, iArg, tData );
|
|
|
|
|
2010-12-16 06:43:05 +00:00
|
|
|
// tData.iDirective = FIRST_M_DIRECTIVE + ASM_M_DEFINE_WORD;
|
|
|
|
tData.iDirective = g_aAssemblerFirstDirective[ g_iAssemblerSyntax ] + ASM_DEFINE_WORD;
|
|
|
|
|
2010-12-19 16:56:43 +00:00
|
|
|
tData.eElementType = (Nopcode_e)( NOP_WORD_1 + iCmd );
|
2010-06-11 15:38:22 +00:00
|
|
|
tData.bSymbolLookup = false;
|
|
|
|
tData.nTargetAddress = 0;
|
|
|
|
|
|
|
|
// Already exists, so update
|
|
|
|
DisasmData_t *pData = Disassembly_IsDataAddress( nAddress );
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( pData )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
|
|
|
*pData = tData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Disassembly_AddData( tData );
|
|
|
|
|
|
|
|
return UPDATE_DISASM | ConsoleUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
Update_t CmdDisasmDataDefAddress8H (int nArgs)
|
|
|
|
{
|
|
|
|
return UPDATE_DISASM;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
Update_t CmdDisasmDataDefAddress8L (int nArgs)
|
|
|
|
{
|
|
|
|
return UPDATE_DISASM;
|
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command: DA
|
|
|
|
// Description: Markup data as an address (i.e. table of function pointers)
|
|
|
|
// Usage:
|
|
|
|
// DA <addr>
|
|
|
|
// Example:
|
|
|
|
// DA D000
|
|
|
|
// DA D000:D0B1
|
2010-06-11 15:38:22 +00:00
|
|
|
//===========================================================================
|
|
|
|
Update_t CmdDisasmDataDefAddress16 (int nArgs)
|
|
|
|
{
|
2010-12-19 16:56:43 +00:00
|
|
|
int iCmd = NOP_WORD_1 - g_aArgs[0].nValue;
|
|
|
|
|
|
|
|
if (! ((nArgs <= 2) || (nArgs == 4)))
|
|
|
|
{
|
|
|
|
return Help_Arg_1( CMD_DEFINE_DATA_WORD1 + iCmd );
|
|
|
|
}
|
|
|
|
|
|
|
|
DisasmData_t tData;
|
|
|
|
int iArg = 2;
|
|
|
|
WORD nAddress = _CmdDefineByteRange( nArgs, iArg, tData );
|
|
|
|
|
|
|
|
// tData.iDirective = FIRST_M_DIRECTIVE + ASM_M_DEFINE_WORD;
|
|
|
|
tData.iDirective = g_aAssemblerFirstDirective[ g_iAssemblerSyntax ] + ASM_DEFINE_ADDRESS_16;
|
|
|
|
|
|
|
|
tData.eElementType = NOP_ADDRESS;
|
|
|
|
tData.bSymbolLookup = true;
|
|
|
|
tData.nTargetAddress = 0; // dynamic -- will be filled in ...
|
|
|
|
|
|
|
|
// Already exists, so update
|
|
|
|
DisasmData_t *pData = Disassembly_IsDataAddress( nAddress );
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( pData )
|
2010-12-19 16:56:43 +00:00
|
|
|
{
|
|
|
|
*pData = tData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Disassembly_AddData( tData );
|
|
|
|
|
|
|
|
return UPDATE_DISASM | ConsoleUpdate();
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command: DB
|
|
|
|
// Usage:
|
|
|
|
// DB <addr>
|
2010-06-11 15:38:22 +00:00
|
|
|
Update_t CmdDisasmDataDefByte1 ( int nArgs )
|
|
|
|
{
|
|
|
|
g_aArgs[0].nValue = NOP_BYTE_1;
|
|
|
|
return _CmdDisasmDataDefByteX( nArgs );
|
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command: DB2
|
|
|
|
// Usage:
|
|
|
|
// DB2 <addr>
|
2010-06-11 15:38:22 +00:00
|
|
|
Update_t CmdDisasmDataDefByte2 ( int nArgs )
|
|
|
|
{
|
|
|
|
g_aArgs[0].nValue = NOP_BYTE_2;
|
|
|
|
return _CmdDisasmDataDefByteX( nArgs );
|
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command: DB4
|
|
|
|
// Usage:
|
|
|
|
// DB4 <addr>
|
2010-06-11 15:38:22 +00:00
|
|
|
Update_t CmdDisasmDataDefByte4 ( int nArgs )
|
|
|
|
{
|
|
|
|
g_aArgs[0].nValue = NOP_BYTE_4;
|
|
|
|
return _CmdDisasmDataDefByteX( nArgs );
|
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command DB8
|
|
|
|
// Usage:
|
|
|
|
// DB8 <addr>
|
2010-06-11 15:38:22 +00:00
|
|
|
Update_t CmdDisasmDataDefByte8 ( int nArgs )
|
|
|
|
{
|
|
|
|
g_aArgs[0].nValue = NOP_BYTE_8;
|
|
|
|
return _CmdDisasmDataDefByteX( nArgs );
|
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command: DF
|
|
|
|
// Usage:
|
|
|
|
// DF <addr>
|
2022-01-06 18:10:09 +00:00
|
|
|
Update_t CmdDisasmDataDefFloat(int nArgs)
|
|
|
|
{
|
|
|
|
g_aArgs[0].nValue = NOP_FAC;
|
|
|
|
return _CmdDisasmDataDefByteX( nArgs );
|
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command: DW
|
|
|
|
// Usage:
|
|
|
|
// DW <addr>
|
2010-06-11 15:38:22 +00:00
|
|
|
Update_t CmdDisasmDataDefWord1 ( int nArgs )
|
|
|
|
{
|
|
|
|
g_aArgs[0].nValue = NOP_WORD_1;
|
|
|
|
return _CmdDisasmDataDefWordX( nArgs );
|
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command: DW2
|
|
|
|
// Usage:
|
|
|
|
// DW2 <addr>
|
2010-06-11 15:38:22 +00:00
|
|
|
Update_t CmdDisasmDataDefWord2 ( int nArgs )
|
|
|
|
{
|
|
|
|
g_aArgs[0].nValue = NOP_WORD_2;
|
|
|
|
return _CmdDisasmDataDefWordX( nArgs );
|
|
|
|
}
|
|
|
|
|
2022-01-06 18:13:27 +00:00
|
|
|
// Command: DW4
|
|
|
|
// Usage:
|
|
|
|
// DW4 <addr>
|
2010-06-11 15:38:22 +00:00
|
|
|
Update_t CmdDisasmDataDefWord4 ( int nArgs )
|
|
|
|
{
|
|
|
|
g_aArgs[0].nValue = NOP_WORD_4;
|
|
|
|
return _CmdDisasmDataDefWordX( nArgs );
|
|
|
|
}
|
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
// Command: DS
|
2022-01-06 18:13:27 +00:00
|
|
|
// Usage:
|
|
|
|
// DS <addr>
|
2014-08-29 15:51:29 +00:00
|
|
|
// ASC range Auto-define T_#### where # is the address
|
2010-06-11 15:38:22 +00:00
|
|
|
Update_t CmdDisasmDataDefString ( int nArgs )
|
|
|
|
{
|
2014-08-28 18:13:02 +00:00
|
|
|
int iCmd = 0; // Define Ascii, AppleText, MixedText (DOS3.3)
|
|
|
|
|
2014-08-29 15:51:29 +00:00
|
|
|
if (nArgs > 4) // 2.7.0.31 Bug fix: DB range, i.e. DB 174E:174F
|
|
|
|
{
|
|
|
|
return Help_Arg_1( CMD_DEFINE_DATA_STR + iCmd );
|
|
|
|
}
|
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
DisasmData_t tData;
|
|
|
|
int iArg = 2;
|
2014-08-29 15:51:29 +00:00
|
|
|
|
|
|
|
if (nArgs == 3 ) // 2.7.0.32 Bug fix: ASC range, i.e. ASC 174E:175F
|
|
|
|
{
|
|
|
|
if ( g_aArgs[ 2 ].eToken == TOKEN_COLON )
|
|
|
|
iArg = 1;
|
|
|
|
}
|
|
|
|
|
2014-08-28 18:13:02 +00:00
|
|
|
WORD nAddress = _CmdDefineByteRange( nArgs, iArg, tData );
|
|
|
|
|
2014-08-28 23:52:41 +00:00
|
|
|
// tData.iDirective = g_aAssemblerFirstDirective[ g_iAssemblerSyntax ] + ASM_DEFINE_APPLE_TEXT;
|
|
|
|
tData.iDirective = FIRST_M_DIRECTIVE + ASM_M_ASCII; // ASM_MERLIN
|
2014-08-28 18:13:02 +00:00
|
|
|
|
|
|
|
tData.eElementType = (Nopcode_e)( NOP_STRING_APPLE + iCmd );
|
|
|
|
tData.bSymbolLookup = false;
|
|
|
|
tData.nTargetAddress = 0;
|
|
|
|
|
|
|
|
// Already exists, so update
|
|
|
|
DisasmData_t *pData = Disassembly_IsDataAddress( nAddress );
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( pData )
|
2014-08-28 18:13:02 +00:00
|
|
|
{
|
|
|
|
*pData = tData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Disassembly_AddData( tData );
|
|
|
|
|
|
|
|
return UPDATE_DISASM | ConsoleUpdate();
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// __ Disassembler View Interface ____________________________________________________________________
|
|
|
|
|
|
|
|
/// @param pCurrent NULL start a new serch, or continue enumerating
|
|
|
|
//===========================================================================
|
|
|
|
DisasmData_t* Disassembly_Enumerate( DisasmData_t *pCurrent )
|
|
|
|
{
|
|
|
|
DisasmData_t *pData = NULL; // bIsNopcode = false
|
2022-05-01 13:08:45 +00:00
|
|
|
size_t nDataTargets = g_aDisassemblerData.size();
|
2010-06-11 15:38:22 +00:00
|
|
|
|
2022-05-01 13:08:45 +00:00
|
|
|
if ( nDataTargets > 0 )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
2010-12-16 07:32:59 +00:00
|
|
|
DisasmData_t *pBegin = & g_aDisassemblerData[ 0 ];
|
|
|
|
DisasmData_t *pEnd = & g_aDisassemblerData[ nDataTargets - 1 ];
|
|
|
|
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( pCurrent )
|
2010-12-16 07:32:59 +00:00
|
|
|
{
|
|
|
|
pCurrent++;
|
|
|
|
if (pCurrent <= pEnd)
|
2014-08-28 18:13:02 +00:00
|
|
|
pData = pCurrent;
|
2010-12-16 07:32:59 +00:00
|
|
|
} else {
|
|
|
|
pData = pBegin;
|
|
|
|
}
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
2010-12-16 07:32:59 +00:00
|
|
|
return pData;
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// returns NULL if address has no data associated with it
|
|
|
|
//===========================================================================
|
|
|
|
DisasmData_t* Disassembly_IsDataAddress ( WORD nAddress )
|
|
|
|
{
|
|
|
|
DisasmData_t *pData = NULL; // bIsNopcode = false
|
2022-05-01 13:08:45 +00:00
|
|
|
size_t nDataTargets = g_aDisassemblerData.size();
|
2010-06-11 15:38:22 +00:00
|
|
|
|
2022-05-01 13:08:45 +00:00
|
|
|
if ( nDataTargets > 0 )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
|
|
|
// TODO: Replace with binary search -- should store data in sorted order, via start address
|
|
|
|
pData = & g_aDisassemblerData[ 0 ];
|
2022-05-01 13:08:45 +00:00
|
|
|
for ( size_t iTarget = 0; iTarget < nDataTargets; iTarget++ )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( pData->iDirective != _NOP_REMOVED )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( (nAddress >= pData->nStartAddress) && (nAddress <= pData->nEndAddress) )
|
2010-12-16 06:43:05 +00:00
|
|
|
{
|
|
|
|
return pData;
|
|
|
|
}
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
pData++;
|
|
|
|
}
|
|
|
|
pData = NULL; // bIsNopCode = false
|
|
|
|
}
|
|
|
|
return pData;
|
|
|
|
}
|
|
|
|
|
2010-12-16 06:43:05 +00:00
|
|
|
// Notes: tData.iDirective should not be _NOP_REMOVED !
|
2010-06-11 15:38:22 +00:00
|
|
|
//===========================================================================
|
|
|
|
void Disassembly_AddData( DisasmData_t tData)
|
|
|
|
{
|
|
|
|
g_aDisassemblerData.push_back( tData );
|
|
|
|
}
|
|
|
|
|
2010-12-19 16:56:43 +00:00
|
|
|
// DEPRECATED ! Inlined in _6502_GetOpmodeOpbyte() !
|
2010-06-11 15:38:22 +00:00
|
|
|
//===========================================================================
|
|
|
|
void Disassembly_GetData ( WORD nBaseAddress, const DisasmData_t *pData, DisasmLine_t & line_ )
|
|
|
|
{
|
2022-03-27 19:48:26 +00:00
|
|
|
if ( !pData )
|
2010-06-11 15:38:22 +00:00
|
|
|
{
|
2010-12-19 16:56:43 +00:00
|
|
|
#if _DEBUG
|
|
|
|
ConsoleDisplayError( "Disassembly_GetData() but we don't have a valid DisasmData_t *" );
|
|
|
|
#endif
|
|
|
|
return;
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
void Disassembly_DelData( DisasmData_t tData)
|
|
|
|
{
|
|
|
|
// g_aDisassemblerData.erase( );
|
2010-12-16 06:43:05 +00:00
|
|
|
WORD nAddress = tData.nStartAddress;
|
|
|
|
|
|
|
|
DisasmData_t *pData = NULL; // bIsNopcode = false
|
2022-05-01 13:08:45 +00:00
|
|
|
size_t nDataTargets = g_aDisassemblerData.size();
|
2010-12-16 06:43:05 +00:00
|
|
|
|
2022-05-01 13:08:45 +00:00
|
|
|
if ( nDataTargets > 0 )
|
2010-12-16 06:43:05 +00:00
|
|
|
{
|
|
|
|
// TODO: Replace with binary search -- should store data in sorted order, via start address
|
|
|
|
pData = & g_aDisassemblerData[ 0 ];
|
2022-05-01 13:08:45 +00:00
|
|
|
for ( size_t iTarget = 0; iTarget < nDataTargets; iTarget++ )
|
2010-12-16 06:43:05 +00:00
|
|
|
{
|
|
|
|
if (pData->iDirective != _NOP_REMOVED)
|
|
|
|
{
|
2022-01-04 05:09:11 +00:00
|
|
|
if ((nAddress >= pData->nStartAddress) && (nAddress <= pData->nEndAddress))
|
2010-12-16 06:43:05 +00:00
|
|
|
{
|
|
|
|
pData->iDirective = _NOP_REMOVED;
|
2022-01-04 05:09:11 +00:00
|
|
|
|
|
|
|
// TODO: delete from vector?
|
2010-12-16 06:43:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pData++;
|
|
|
|
}
|
|
|
|
pData = NULL; // bIsNopCode = false
|
|
|
|
}
|
2010-06-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
|