Disassembly now shows symbolic names from VCS.H

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@494 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-06-14 01:55:52 +00:00
parent 780422bd42
commit 5e911f1453
6 changed files with 157 additions and 15 deletions

View File

@ -13,7 +13,7 @@
## See the file "license" for information on usage and redistribution of ## See the file "license" for information on usage and redistribution of
## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## this file, and for a DISCLAIMER OF ALL WARRANTIES.
## ##
## $Id: makefile,v 1.94 2005-06-14 01:11:47 stephena Exp $ ## $Id: makefile,v 1.95 2005-06-14 01:55:47 urchlay Exp $
##============================================================================ ##============================================================================
##============================================================================ ##============================================================================
@ -164,7 +164,7 @@ GUI_OBJS = Font.o Menu.o Launcher.o \
ProgressDialog.o \ ProgressDialog.o \
DebuggerDialog.o PromptWidget.o CheatWidget.o DebuggerDialog.o PromptWidget.o CheatWidget.o
DBG_OBJS = Debugger.o DebuggerParser.o DBG_OBJS = Debugger.o DebuggerParser.o EquateList.o
CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \
CartE0.o CartE7.o CartF4.o CartF4SC.o CartF6.o CartF6SC.o \ CartE0.o CartE7.o CartF4.o CartF4SC.o CartF6.o CartF6SC.o \
@ -470,3 +470,6 @@ Debugger.o: $(DBG)/Debugger.cxx $(DBG)/Debugger.hxx
DebuggerParser.o: $(DBG)/DebuggerParser.cxx $(DBG)/DebuggerParser.hxx DebuggerParser.o: $(DBG)/DebuggerParser.cxx $(DBG)/DebuggerParser.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(DBG)/DebuggerParser.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(DBG)/DebuggerParser.cxx
EquateList.o: $(DBG)/EquateList.cxx $(DBG)/EquateList.hxx $(DBG)/Equate.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(DBG)/EquateList.cxx

View File

@ -0,0 +1,10 @@
#ifndef EQUATE_HXX
#define EQUATE_HXX
struct Equate {
char *label;
int address;
};
#endif

View File

@ -0,0 +1,111 @@
#include "bspf.hxx"
#include "Equate.hxx"
#include "EquateList.hxx"
// built in labels
static struct Equate ourVcsEquates[] = {
{ "VSYNC", 0x00 },
{ "VBLANK", 0x01 },
{ "WSYNC", 0x02 },
{ "RSYNC", 0x03 },
{ "NUSIZ0", 0x04 },
{ "NUSIZ1", 0x05 },
{ "COLUP0", 0x06 },
{ "COLUP1", 0x07 },
{ "COLUPF", 0x08 },
{ "COLUBK", 0x09 },
{ "CTRLPF", 0x0A },
{ "REFP0", 0x0B },
{ "REFP1", 0x0C },
{ "PF0", 0x0D },
{ "PF1", 0x0E },
{ "PF2", 0x0F },
{ "RESP0", 0x10 },
{ "RESP1", 0x11 },
{ "RESM0", 0x12 },
{ "RESM1", 0x13 },
{ "RESBL", 0x14 },
{ "AUDC0", 0x15 },
{ "AUDC1", 0x16 },
{ "AUDF0", 0x17 },
{ "AUDF1", 0x18 },
{ "AUDV0", 0x19 },
{ "AUDV1", 0x1A },
{ "GRP0", 0x1B },
{ "GRP1", 0x1C },
{ "ENAM0", 0x1D },
{ "ENAM1", 0x1E },
{ "ENABL", 0x1F },
{ "HMP0", 0x20 },
{ "HMP1", 0x21 },
{ "HMM0", 0x22 },
{ "HMM1", 0x23 },
{ "HMBL", 0x24 },
{ "VDELP0", 0x25 },
{ "VDEL01", 0x26 },
{ "VDELP1", 0x26 },
{ "VDELBL", 0x27 },
{ "RESMP0", 0x28 },
{ "RESMP1", 0x29 },
{ "HMOVE", 0x2A },
{ "HMCLR", 0x2B },
{ "CXCLR", 0x2C },
{ "CXM0P", 0x30 },
{ "CXM1P", 0x31 },
{ "CXP0FB", 0x32 },
{ "CXP1FB", 0x33 },
{ "CXM0FB", 0x34 },
{ "CXM1FB", 0x35 },
{ "CXBLPF", 0x36 },
{ "CXPPMM", 0x37 },
{ "INPT0", 0x38 },
{ "INPT1", 0x39 },
{ "INPT2", 0x3A },
{ "INPT3", 0x3B },
{ "INPT4", 0x3C },
{ "INPT5", 0x3D },
{ "SWCHA", 0x0280 },
{ "SWCHB", 0x0282 },
{ "SWACNT", 0x281 },
{ "SWBCNT", 0x283 },
{ "INTIM", 0x0284 },
{ "TIM1T", 0x0294 },
{ "TIM8T", 0x0295 },
{ "TIM64T", 0x0296 },
{ "TIM1024T", 0x0297 },
{ NULL, 0 }
};
EquateList::EquateList() {
}
// FIXME: use something smarter than a linear search in the future.
char *EquateList::getLabel(int addr) {
for(int i=0; ourVcsEquates[i].label != NULL; i++)
if(ourVcsEquates[i].address == addr)
return ourVcsEquates[i].label;
return NULL;
}
// returns either the label, or a formatted hex string
// if no label found.
char *EquateList::getFormatted(int addr, int places) {
static char fmt[10], buf[255];
char *res = getLabel(addr);
if(res != NULL)
return res;
sprintf(fmt, "$%%0%dx", places);
sprintf(buf, fmt, addr);
return buf;
}
int EquateList::getAddress(char *label) {
for(int i=0; ourVcsEquates[i].label != NULL; i++)
if( strcmp(ourVcsEquates[i].label, label) == 0 )
return ourVcsEquates[i].address;
return -1;
}

View File

@ -0,0 +1,13 @@
#ifndef EQUATELIST_HXX
#define EQUATELIST_HXX
class EquateList {
public:
EquateList();
char *getLabel(int addr);
char *EquateList::getFormatted(int addr, int places);
int getAddress(char *label);
};
#endif

View File

@ -13,23 +13,26 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: D6502.cxx,v 1.3 2005-06-13 13:35:09 urchlay Exp $ // $Id: D6502.cxx,v 1.4 2005-06-14 01:55:52 urchlay Exp $
//============================================================================ //============================================================================
#include <stdio.h> #include <stdio.h>
#include "D6502.hxx" #include "D6502.hxx"
#include "M6502.hxx" #include "M6502.hxx"
#include "System.hxx" #include "System.hxx"
#include "EquateList.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
D6502::D6502(System* system) D6502::D6502(System* system)
: mySystem(system) : mySystem(system)
{ {
equateList = new EquateList();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
D6502::~D6502() D6502::~D6502()
{ {
delete equateList;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -53,20 +56,20 @@ uInt16 D6502::disassemble(uInt16 address, char* buffer)
switch(M6502::ourAddressingModeTable[opcode]) switch(M6502::ourAddressingModeTable[opcode])
{ {
case M6502::Absolute: case M6502::Absolute:
sprintf(buffer, "%s $%04X ; %d", M6502::ourInstructionMnemonicTable[opcode], sprintf(buffer, "%s %s ; %d", M6502::ourInstructionMnemonicTable[opcode],
dpeek(mySystem, address + 1), equateList->getFormatted(dpeek(mySystem, address + 1), 4),
M6502::ourInstructionProcessorCycleTable[opcode]); M6502::ourInstructionProcessorCycleTable[opcode]);
return 3; return 3;
case M6502::AbsoluteX: case M6502::AbsoluteX:
sprintf(buffer, "%s $%04X,x ; %d", M6502::ourInstructionMnemonicTable[opcode], sprintf(buffer, "%s %s,x ; %d", M6502::ourInstructionMnemonicTable[opcode],
dpeek(mySystem, address + 1), equateList->getFormatted(dpeek(mySystem, address + 1), 4),
M6502::ourInstructionProcessorCycleTable[opcode]); M6502::ourInstructionProcessorCycleTable[opcode]);
return 3; return 3;
case M6502::AbsoluteY: case M6502::AbsoluteY:
sprintf(buffer, "%s $%04X,y ; %d", M6502::ourInstructionMnemonicTable[opcode], sprintf(buffer, "%s %s,y ; %d", M6502::ourInstructionMnemonicTable[opcode],
dpeek(mySystem, address + 1), equateList->getFormatted(dpeek(mySystem, address + 1), 4),
M6502::ourInstructionProcessorCycleTable[opcode]); M6502::ourInstructionProcessorCycleTable[opcode]);
return 3; return 3;
@ -114,14 +117,14 @@ uInt16 D6502::disassemble(uInt16 address, char* buffer)
return 2; return 2;
case M6502::ZeroX: case M6502::ZeroX:
sprintf(buffer, "%s $%02X,x ; %d", M6502::ourInstructionMnemonicTable[opcode], sprintf(buffer, "%s %s,x ; %d", M6502::ourInstructionMnemonicTable[opcode],
mySystem->peek(address + 1), equateList->getFormatted(dpeek(mySystem, address + 1), 2),
M6502::ourInstructionProcessorCycleTable[opcode]); M6502::ourInstructionProcessorCycleTable[opcode]);
return 2; return 2;
case M6502::ZeroY: case M6502::ZeroY:
sprintf(buffer, "%s $%02X,y ; %d", M6502::ourInstructionMnemonicTable[opcode], sprintf(buffer, "%s %s,y ; %d", M6502::ourInstructionMnemonicTable[opcode],
mySystem->peek(address + 1), equateList->getFormatted(dpeek(mySystem, address + 1), 2),
M6502::ourInstructionProcessorCycleTable[opcode]); M6502::ourInstructionProcessorCycleTable[opcode]);
return 2; return 2;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: D6502.hxx,v 1.2 2005-06-13 02:47:44 urchlay Exp $ // $Id: D6502.hxx,v 1.3 2005-06-14 01:55:52 urchlay Exp $
//============================================================================ //============================================================================
#ifndef D6502_HXX #ifndef D6502_HXX
@ -24,13 +24,14 @@ class M6502;
class System; class System;
#include "bspf.hxx" #include "bspf.hxx"
#include "EquateList.hxx"
/** /**
This is a base class for 6502 debuggers. This class provides the This is a base class for 6502 debuggers. This class provides the
basic functionality needed for interactive debuggers. basic functionality needed for interactive debuggers.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: D6502.hxx,v 1.2 2005-06-13 02:47:44 urchlay Exp $ @version $Id: D6502.hxx,v 1.3 2005-06-14 01:55:52 urchlay Exp $
*/ */
class D6502 class D6502
{ {
@ -149,6 +150,7 @@ class D6502
protected: protected:
// Pointer to the system I'm debugging // Pointer to the system I'm debugging
System* mySystem; System* mySystem;
EquateList *equateList;
}; };
#endif #endif