OK, this is the first pass at a huge reorganization of the debugger
classes. First off, the distella code has been integrated into a
DiStella class. This code isn't yet tied to the debugger, but it does
at least compile and generate valid output.
The RamDebug class has been replaced by a CartDebug class, which
takes responsibility for the previous RamDebug stuff as well as
things related to Cart address space (read from write ports,
disassembly, etc).
Fixed E7 bankswitching when reading from the write port in the upper
256byte area.
Fixed 'read from write port functionality' in general for all carts
that supported it previously. Basically, if _rwport is enabled, the
address is checked to be an actual read (vs. one that's part of a
normal write cycle), *and* it's actually an illegal access (each
cart/bankswitch type now provides a hint to indicate this condition).
Still TODO is clean up the rework, properly integrate DiStella, and
fix labels and defines (which seem to be completely broken).
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1922 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-01-17 16:48:45 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2010-01-31 02:07:19 +00:00
|
|
|
// Copyright (c) 1995-2010 by Bradford W. Mott and the Stella team
|
OK, this is the first pass at a huge reorganization of the debugger
classes. First off, the distella code has been integrated into a
DiStella class. This code isn't yet tied to the debugger, but it does
at least compile and generate valid output.
The RamDebug class has been replaced by a CartDebug class, which
takes responsibility for the previous RamDebug stuff as well as
things related to Cart address space (read from write ports,
disassembly, etc).
Fixed E7 bankswitching when reading from the write port in the upper
256byte area.
Fixed 'read from write port functionality' in general for all carts
that supported it previously. Basically, if _rwport is enabled, the
address is checked to be an actual read (vs. one that's part of a
normal write cycle), *and* it's actually an illegal access (each
cart/bankswitch type now provides a hint to indicate this condition).
Still TODO is clean up the rework, properly integrate DiStella, and
fix labels and defines (which seem to be completely broken).
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1922 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-01-17 16:48:45 +00:00
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef DISTELLA_HXX
|
|
|
|
#define DISTELLA_HXX
|
|
|
|
|
|
|
|
#include <queue>
|
2010-01-31 02:07:19 +00:00
|
|
|
#include <sstream>
|
OK, this is the first pass at a huge reorganization of the debugger
classes. First off, the distella code has been integrated into a
DiStella class. This code isn't yet tied to the debugger, but it does
at least compile and generate valid output.
The RamDebug class has been replaced by a CartDebug class, which
takes responsibility for the previous RamDebug stuff as well as
things related to Cart address space (read from write ports,
disassembly, etc).
Fixed E7 bankswitching when reading from the write port in the upper
256byte area.
Fixed 'read from write port functionality' in general for all carts
that supported it previously. Basically, if _rwport is enabled, the
address is checked to be an actual read (vs. one that's part of a
normal write cycle), *and* it's actually an illegal access (each
cart/bankswitch type now provides a hint to indicate this condition).
Still TODO is clean up the rework, properly integrate DiStella, and
fix labels and defines (which seem to be completely broken).
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1922 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-01-17 16:48:45 +00:00
|
|
|
|
|
|
|
#include "Array.hxx"
|
|
|
|
#include "bspf.hxx"
|
|
|
|
|
|
|
|
//#include "CartDebug.hxx"
|
|
|
|
|
|
|
|
//// The following will go in CartDebug
|
|
|
|
struct DisassemblyTag {
|
2010-01-31 19:41:57 +00:00
|
|
|
uInt16 address;
|
|
|
|
string label;
|
OK, this is the first pass at a huge reorganization of the debugger
classes. First off, the distella code has been integrated into a
DiStella class. This code isn't yet tied to the debugger, but it does
at least compile and generate valid output.
The RamDebug class has been replaced by a CartDebug class, which
takes responsibility for the previous RamDebug stuff as well as
things related to Cart address space (read from write ports,
disassembly, etc).
Fixed E7 bankswitching when reading from the write port in the upper
256byte area.
Fixed 'read from write port functionality' in general for all carts
that supported it previously. Basically, if _rwport is enabled, the
address is checked to be an actual read (vs. one that's part of a
normal write cycle), *and* it's actually an illegal access (each
cart/bankswitch type now provides a hint to indicate this condition).
Still TODO is clean up the rework, properly integrate DiStella, and
fix labels and defines (which seem to be completely broken).
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1922 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-01-17 16:48:45 +00:00
|
|
|
string disasm;
|
|
|
|
string bytes;
|
|
|
|
};
|
|
|
|
typedef Common::Array<DisassemblyTag> DisassemblyList;
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2010-01-31 02:07:19 +00:00
|
|
|
/**
|
|
|
|
This class is a wrapper around the Distella code. Much of the code remains
|
2010-01-31 19:41:57 +00:00
|
|
|
exactly the same, except that generated data is now redirected to a
|
|
|
|
DisassemblyList structure rather than being printed.
|
|
|
|
|
|
|
|
All 7800-related stuff has been removed, as well as all commandline options.
|
|
|
|
For now, the only configurable item is whether to automatically determine
|
|
|
|
code vs. data sections (which is on by default). Over time, some of the
|
|
|
|
configurability of Distella may be added again.
|
2010-01-31 02:07:19 +00:00
|
|
|
|
|
|
|
@author Stephen Anthony
|
|
|
|
*/
|
OK, this is the first pass at a huge reorganization of the debugger
classes. First off, the distella code has been integrated into a
DiStella class. This code isn't yet tied to the debugger, but it does
at least compile and generate valid output.
The RamDebug class has been replaced by a CartDebug class, which
takes responsibility for the previous RamDebug stuff as well as
things related to Cart address space (read from write ports,
disassembly, etc).
Fixed E7 bankswitching when reading from the write port in the upper
256byte area.
Fixed 'read from write port functionality' in general for all carts
that supported it previously. Basically, if _rwport is enabled, the
address is checked to be an actual read (vs. one that's part of a
normal write cycle), *and* it's actually an illegal access (each
cart/bankswitch type now provides a hint to indicate this condition).
Still TODO is clean up the rework, properly integrate DiStella, and
fix labels and defines (which seem to be completely broken).
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1922 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-01-17 16:48:45 +00:00
|
|
|
class DiStella
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DiStella();
|
|
|
|
~DiStella();
|
|
|
|
|
|
|
|
public:
|
2010-01-31 19:41:57 +00:00
|
|
|
uInt32 disassemble(DisassemblyList& list, uInt16 PC, const char* datafile, bool autocode = true);
|
OK, this is the first pass at a huge reorganization of the debugger
classes. First off, the distella code has been integrated into a
DiStella class. This code isn't yet tied to the debugger, but it does
at least compile and generate valid output.
The RamDebug class has been replaced by a CartDebug class, which
takes responsibility for the previous RamDebug stuff as well as
things related to Cart address space (read from write ports,
disassembly, etc).
Fixed E7 bankswitching when reading from the write port in the upper
256byte area.
Fixed 'read from write port functionality' in general for all carts
that supported it previously. Basically, if _rwport is enabled, the
address is checked to be an actual read (vs. one that's part of a
normal write cycle), *and* it's actually an illegal access (each
cart/bankswitch type now provides a hint to indicate this condition).
Still TODO is clean up the rework, properly integrate DiStella, and
fix labels and defines (which seem to be completely broken).
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1922 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-01-17 16:48:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Marked bits
|
|
|
|
// This is a reference sheet of bits that can be set for a given address, which
|
|
|
|
// are stored in the labels[] array.
|
|
|
|
enum MarkType {
|
|
|
|
REFERENCED = 1 << 0, /* code somewhere in the program references it, i.e. LDA $F372 referenced $F372 */
|
|
|
|
VALID_ENTRY = 1 << 1, /* addresses that can have a label placed in front of it. A good counterexample
|
|
|
|
would be "FF00: LDA $FE00"; $FF01 would be in the middle of a multi-byte
|
|
|
|
instruction, and therefore cannot be labelled. */
|
|
|
|
DATA = 1 << 2,
|
|
|
|
GFX = 1 << 3,
|
|
|
|
REACHABLE = 1 << 4 /* disassemble-able code segments */
|
|
|
|
};
|
|
|
|
|
2010-01-31 19:41:57 +00:00
|
|
|
// Indicate that a new line of disassembly has been completed
|
|
|
|
// In the original Distella code, this indicated a new line to be printed
|
2010-01-31 02:07:19 +00:00
|
|
|
// Here, we add a new entry to the DisassemblyList
|
2010-01-31 19:41:57 +00:00
|
|
|
void addEntry(DisassemblyList& list);
|
2010-01-31 02:07:19 +00:00
|
|
|
|
|
|
|
// These functions are part of the original Distella code
|
|
|
|
uInt32 filesize(FILE *stream);
|
|
|
|
uInt32 read_adr();
|
|
|
|
int file_load(const char* file);
|
2010-01-31 19:41:57 +00:00
|
|
|
void disasm(DisassemblyList& list, uInt32 distart, int pass);
|
2010-01-31 02:07:19 +00:00
|
|
|
int mark(uInt32 address, MarkType bit);
|
|
|
|
int check_bit(uInt8 bitflags, int i);
|
|
|
|
void showgfx(uInt8 c);
|
|
|
|
|
|
|
|
private:
|
2010-01-31 19:41:57 +00:00
|
|
|
stringstream myBuf;
|
2010-01-31 02:07:19 +00:00
|
|
|
queue<uInt16> myAddressQueue;
|
|
|
|
uInt32 myOffset, myPC, myPCBeg, myPCEnd, myLineCount;
|
|
|
|
|
|
|
|
struct resource {
|
|
|
|
uInt16 start;
|
|
|
|
uInt16 load;
|
|
|
|
uInt32 length;
|
|
|
|
uInt16 end;
|
|
|
|
int disp_data;
|
|
|
|
} myAppData;
|
|
|
|
|
|
|
|
/* Memory */
|
|
|
|
uInt8* mem;
|
|
|
|
uInt8* labels;
|
|
|
|
|
OK, this is the first pass at a huge reorganization of the debugger
classes. First off, the distella code has been integrated into a
DiStella class. This code isn't yet tied to the debugger, but it does
at least compile and generate valid output.
The RamDebug class has been replaced by a CartDebug class, which
takes responsibility for the previous RamDebug stuff as well as
things related to Cart address space (read from write ports,
disassembly, etc).
Fixed E7 bankswitching when reading from the write port in the upper
256byte area.
Fixed 'read from write port functionality' in general for all carts
that supported it previously. Basically, if _rwport is enabled, the
address is checked to be an actual read (vs. one that's part of a
normal write cycle), *and* it's actually an illegal access (each
cart/bankswitch type now provides a hint to indicate this condition).
Still TODO is clean up the rework, properly integrate DiStella, and
fix labels and defines (which seem to be completely broken).
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1922 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-01-17 16:48:45 +00:00
|
|
|
/**
|
|
|
|
Enumeration of the 6502 addressing modes
|
|
|
|
*/
|
|
|
|
enum AddressingMode
|
|
|
|
{
|
|
|
|
IMPLIED, ACCUMULATOR, IMMEDIATE,
|
|
|
|
ZERO_PAGE, ZERO_PAGE_X, ZERO_PAGE_Y,
|
|
|
|
ABSOLUTE, ABSOLUTE_X, ABSOLUTE_Y,
|
|
|
|
ABS_INDIRECT, INDIRECT_X, INDIRECT_Y,
|
|
|
|
RELATIVE, ASS_CODE
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Enumeration of the 6502 access modes
|
|
|
|
*/
|
|
|
|
enum AccessMode
|
|
|
|
{
|
|
|
|
M_NONE, M_AC, M_XR, M_YR, M_SP, M_SR, M_PC, M_IMM, M_ZERO, M_ZERX, M_ZERY,
|
|
|
|
M_ABS, M_ABSX, M_ABSY, M_AIND, M_INDX, M_INDY, M_REL, M_FC, M_FD, M_FI,
|
|
|
|
M_FV, M_ADDR, M_,
|
|
|
|
|
|
|
|
M_ACIM, /* Source: AC & IMMED (bus collision) */
|
|
|
|
M_ANXR, /* Source: AC & XR (bus collision) */
|
|
|
|
M_AXIM, /* Source: (AC | #EE) & XR & IMMED (bus collision) */
|
|
|
|
M_ACNC, /* Dest: M_AC and Carry = Negative */
|
|
|
|
M_ACXR, /* Dest: M_AC, M_XR */
|
|
|
|
|
|
|
|
M_SABY, /* Source: (ABS_Y & SP) (bus collision) */
|
|
|
|
M_ACXS, /* Dest: M_AC, M_XR, M_SP */
|
|
|
|
M_STH0, /* Dest: Store (src & Addr_Hi+1) to (Addr +0x100) */
|
|
|
|
M_STH1,
|
|
|
|
M_STH2,
|
|
|
|
M_STH3
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Instruction_tag {
|
|
|
|
const char* mnemonic;
|
|
|
|
AddressingMode addr_mode;
|
|
|
|
AccessMode source;
|
|
|
|
AccessMode destination;
|
|
|
|
uInt8 cycles;
|
|
|
|
};
|
|
|
|
static const Instruction_tag ourLookup[256];
|
|
|
|
|
|
|
|
/// Table of instruction mnemonics
|
|
|
|
static const char* ourTIAMnemonic[62];
|
|
|
|
static const char* ourIOMnemonic[24];
|
|
|
|
|
|
|
|
static const int ourCLength[14];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|