2009-03-23 09:10:32 +00:00
|
|
|
/*====================================================================
|
|
|
|
|
|
|
|
project: GameCube DSP Tool (gcdsp)
|
|
|
|
created: 2005.03.04
|
|
|
|
mail: duddie@walla.com
|
|
|
|
|
|
|
|
Copyright (c) 2005 Duddie
|
|
|
|
|
|
|
|
This program 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.
|
|
|
|
|
|
|
|
This program 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 this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
====================================================================*/
|
|
|
|
|
2009-04-12 10:21:40 +00:00
|
|
|
#ifndef _DSP_DISASSEMBLE_H
|
|
|
|
#define _DSP_DISASSEMBLE_H
|
2009-03-23 09:10:32 +00:00
|
|
|
|
2009-04-14 22:30:31 +00:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
2009-04-02 13:07:26 +00:00
|
|
|
#include "Common.h"
|
2009-04-12 14:48:55 +00:00
|
|
|
#include "DSPTables.h"
|
2009-04-18 11:31:37 +00:00
|
|
|
#include "LabelMap.h"
|
2009-04-02 13:07:26 +00:00
|
|
|
|
2009-04-14 20:44:03 +00:00
|
|
|
struct AssemblerSettings
|
2009-03-23 09:10:32 +00:00
|
|
|
{
|
2009-04-14 20:44:03 +00:00
|
|
|
AssemblerSettings()
|
|
|
|
: print_tabs(false),
|
|
|
|
show_hex(false),
|
|
|
|
show_pc(false),
|
|
|
|
decode_names(true),
|
|
|
|
decode_registers(true),
|
2009-04-14 20:55:27 +00:00
|
|
|
ext_separator('\''),
|
2009-04-18 11:31:37 +00:00
|
|
|
lower_case_ops(true),
|
2009-04-14 20:55:27 +00:00
|
|
|
pc(0)
|
2009-04-14 20:44:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-03-23 09:10:32 +00:00
|
|
|
bool print_tabs;
|
|
|
|
bool show_hex;
|
|
|
|
bool show_pc;
|
|
|
|
bool decode_names;
|
|
|
|
bool decode_registers;
|
2009-04-14 20:44:03 +00:00
|
|
|
char ext_separator;
|
2009-04-18 11:31:37 +00:00
|
|
|
bool lower_case_ops;
|
2009-03-23 09:10:32 +00:00
|
|
|
|
2009-03-30 03:27:31 +00:00
|
|
|
u16 pc;
|
2009-04-09 14:33:34 +00:00
|
|
|
};
|
2009-03-23 09:10:32 +00:00
|
|
|
|
2009-04-12 14:48:55 +00:00
|
|
|
class DSPDisassembler
|
|
|
|
{
|
|
|
|
public:
|
2009-04-14 20:44:03 +00:00
|
|
|
DSPDisassembler(const AssemblerSettings &settings);
|
2009-04-14 22:30:31 +00:00
|
|
|
~DSPDisassembler();
|
2009-04-12 14:48:55 +00:00
|
|
|
|
2009-04-25 10:38:26 +00:00
|
|
|
bool Disassemble(int start_pc, const std::vector<u16> &code, std::string &text);
|
2009-03-23 09:10:32 +00:00
|
|
|
|
2009-04-14 22:30:31 +00:00
|
|
|
// Warning - this one is trickier to use right.
|
2009-04-18 11:31:37 +00:00
|
|
|
// Use pass == 2 if you're just using it by itself.
|
2009-04-25 10:38:26 +00:00
|
|
|
void DisOpcode(const u16 *binbuf, int pass, u16 *pc, std::string &dest);
|
2009-04-12 10:21:40 +00:00
|
|
|
|
2009-04-12 14:48:55 +00:00
|
|
|
private:
|
2009-04-14 22:30:31 +00:00
|
|
|
// Moves PC forward and writes the result to dest.
|
2009-04-25 10:38:26 +00:00
|
|
|
bool DisFile(const char* name, int pass, std::string &output);
|
2009-04-14 22:30:31 +00:00
|
|
|
|
|
|
|
char* DisParams(const DSPOPCTemplate& opc, u16 op1, u16 op2, char* strbuf);
|
|
|
|
std::map<u16, int> unk_opcodes;
|
2009-04-14 20:44:03 +00:00
|
|
|
|
|
|
|
const AssemblerSettings settings_;
|
2009-04-12 14:48:55 +00:00
|
|
|
|
2009-04-18 11:31:37 +00:00
|
|
|
LabelMap labels;
|
|
|
|
};
|
2009-04-12 10:21:40 +00:00
|
|
|
|
|
|
|
#endif // _DSP_DISASSEMBLE_H
|
2009-04-12 14:48:55 +00:00
|
|
|
|