Some minor cleanups to the Distella class.

The debugger 'disasm' command now works again for addresses below
0x1000, and it also now correctly accepts the number of lines to
output in the disassembly.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1989 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-04-06 15:15:44 +00:00
parent a94c579fec
commit e536a9ee00
5 changed files with 34 additions and 31 deletions

View File

@ -19,7 +19,7 @@ all of your favorite Atari 2600 games on your PC thanks to Stella!
Stella is a multi-platform Atari 2600 VCS emulator. It allows you to play
all of your favorite Atari 2600 games again! Stella was originally
developed for Linux by Bradford W. Mott, however, it has been ported to a
number of other platforms.
number of other platforms and is currently maintained by Stephen Anthony.
This is the 3.0 release of Stella for Linux, Mac OSX and Windows. The
distributions currently available are:

View File

@ -207,10 +207,14 @@ bool CartDebug::disassemble(const string& autocode, bool force)
{
// Test current disassembly; don't re-disassemble if it hasn't changed
// Also check if the current PC is in the current list
// Note that for now, we don't re-disassemble if the PC isn't in cart
// address space, since Distella doesn't yet support disassembling from
// zero-page RAM and ROM at the same time
uInt16 PC = myDebugger.cpuDebug().pc();
int pcline = addressToLine(PC);
bool changed = (force || myConsole.cartridge().bankChanged() ||
(pcline == -1) || mySystem.isPageDirty(0x1000, 0x1FFF));
(pcline == -1 && (PC & 0x1000)) ||
mySystem.isPageDirty(0x1000, 0x1FFF));
if(changed)
{
// Look at previous accesses to this bank to begin
@ -278,22 +282,23 @@ int CartDebug::addressToLine(uInt16 address) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartDebug::disassemble(uInt16 start, uInt16 lines) const
{
if(!(start & 0x1000))
return DebuggerParser::red("Disassembly below 0x1000 not yet supported");
// if(!(start & 0x1000))
// return DebuggerParser::red("Disassembly below 0x1000 not yet supported");
// FIXME
DisassemblyList list;
DiStella distella(list, start, false);
// Fill the string with disassembled data
start &= 0xFFF;
ostringstream buffer;
for(uInt32 i = 0; i < list.size() && lines > 0; ++i, --lines)
for(uInt32 i = 0; i < list.size() && lines > 0; ++i)
{
const CartDebug::DisassemblyTag& tag = list[i];
if((tag.address & 0xfff) >= start)
{
buffer << uppercase << hex << setw(4) << setfill('0') << tag.address
<< ": " << tag.disasm << " " << tag.bytes << endl;
--lines;
}
}

View File

@ -1511,7 +1511,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
"Disassemble from address (default=pc)",
false,
false,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_WORD, kARG_MULTI_BYTE },
&DebuggerParser::executeDisasm
},

View File

@ -23,25 +23,16 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DiStella::DiStella(CartDebug::DisassemblyList& list, uInt16 start,
bool autocode)
: myList(list),
labels(NULL) /* array of information about addresses */
: myList(list)
{
while(!myAddressQueue.empty())
myAddressQueue.pop();
myAppData.start = 0x0;
myAppData.length = 4096;
myAppData.end = 0x0FFF;
myAppData.start = 0x0000;
myAppData.end = 0x0FFF;
myAppData.length = 4096;
/*====================================*/
/* Allocate memory for "labels" variable */
labels=(uInt8*) malloc(myAppData.length);
if (labels == NULL)
{
fprintf (stderr, "Malloc failed for 'labels' variable\n");
return;
}
memset(labels,0,myAppData.length);
memset(labels, 0, 0x1000);
/*============================================
The offset is the address where the code segment
@ -88,8 +79,6 @@ DiStella::DiStella(CartDebug::DisassemblyList& list, uInt16 start,
// Third pass
disasm(myOffset, 3);
free(labels); /* Free dynamic memory before program ends */
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -501,6 +490,9 @@ void DiStella::disasm(uInt32 distart, int pass)
if (d1 >= 128)
ad = d1 - 256;
// uInt16 address = PC + (Int8)operand;
labfound = mark(myPC+ad+myOffset, REFERENCED);
if (pass == 1)
{
@ -600,8 +592,8 @@ int DiStella::mark(uInt32 address, MarkType bit)
We sweep for hardware/system equates, which are valid addresses,
outside the scope of the code/data range. For these, we mark its
corresponding hardware/system array element, and return "2" or "3"
(depending on which system/hardware element was accessed). If this
was not the case...
(depending on which system/hardware element was accessed), or "5"
for zero-page RAM. If this was not the case...
Next we check if it is a code "mirror". For the 2600, address ranges
are limited with 13 bits, so other addresses can exist outside of the
@ -614,6 +606,8 @@ int DiStella::mark(uInt32 address, MarkType bit)
===========================================================
$00-$3d = system equates (WSYNC, etc...); mark the array's element
with the appropriate bit; return 2.
$0080-$00FF = zero-page RAM; mark the array's element
with the appropriate bit; return 5.
$0280-$0297 = system equates (INPT0, etc...); mark the array's element
with the appropriate bit; return 3.
$1000-$1FFF = CODE/DATA, mark the code/data array for the mirrored address
@ -643,12 +637,16 @@ int DiStella::mark(uInt32 address, MarkType bit)
}
else if (address >= 0 && address <= 0x3f)
{
// reserved[address] = 1;
return 2;
}
/* This isn't supported by the core code yet, so why waste time checking
else if (address >= 0x80 && address <= 0xff)
{
return 5;
}
*/
else if (address >= 0x280 && address <= 0x297)
{
// ioresrvd[address-0x280] = 1;
return 3;
}
else if (address > 0x1000)

View File

@ -82,16 +82,16 @@ class DiStella
CartDebug::DisassemblyList& myList;
stringstream myDisasmBuf;
queue<uInt16> myAddressQueue;
uInt32 myOffset, myPC, myPCBeg, myPCEnd;
uInt16 myOffset, myPC, myPCBeg, myPCEnd;
struct resource {
uInt16 start;
uInt32 length;
uInt16 end;
uInt16 length;
} myAppData;
/* Memory */
uInt8* labels;
/* Stores info on how each address is marked */
uInt8 labels[0x1000];
/**
Enumeration of the 6502 addressing modes