mirror of
https://github.com/holub/mame
synced 2025-06-07 13:23:50 +03:00
ns32000dasm: rewrite
* simplified/consolidated logic * corrected scaled mode decoding
This commit is contained in:
parent
37e4c7d146
commit
29e2393076
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,5 @@
|
|||||||
// license:BSD-3-Clause
|
// license:BSD-3-Clause
|
||||||
// copyright-holders:Nigel Barnes
|
// copyright-holders:Patrick Mackinlay
|
||||||
/*****************************************************************************
|
|
||||||
*
|
|
||||||
* ns32000dasm.cpp
|
|
||||||
*
|
|
||||||
* NS32000 CPU Disassembly
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MAME_CPU_NS32000_NS32000DASM_H
|
#ifndef MAME_CPU_NS32000_NS32000DASM_H
|
||||||
#define MAME_CPU_NS32000_NS32000DASM_H
|
#define MAME_CPU_NS32000_NS32000DASM_H
|
||||||
@ -16,113 +9,42 @@
|
|||||||
class ns32000_disassembler : public util::disasm_interface
|
class ns32000_disassembler : public util::disasm_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ns32000_disassembler() = default;
|
ns32000_disassembler() = default;
|
||||||
virtual ~ns32000_disassembler() = default;
|
virtual ~ns32000_disassembler() = default;
|
||||||
|
|
||||||
virtual u32 opcode_alignment() const override { return 1; }
|
virtual u32 opcode_alignment() const override { return 1; }
|
||||||
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) override;
|
virtual offs_t disassemble(std::ostream &stream, offs_t pc, data_buffer const &opcodes, data_buffer const ¶ms) override;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
/* implied operand attributes */
|
enum size_code : unsigned
|
||||||
enum
|
|
||||||
{
|
{
|
||||||
REG = 16,
|
SIZE_B = 0,
|
||||||
QUICK,
|
SIZE_W = 1,
|
||||||
SHORT,
|
SIZE_D = 3,
|
||||||
IMM,
|
SIZE_Q = 7,
|
||||||
DISP,
|
|
||||||
GEN,
|
|
||||||
OPTIONS,
|
|
||||||
};
|
};
|
||||||
/* access classes */
|
|
||||||
enum
|
struct addr_mode
|
||||||
{
|
{
|
||||||
READ = 8,
|
addr_mode(unsigned gen)
|
||||||
WRITE,
|
: gen(gen)
|
||||||
RMW,
|
, fpu(false)
|
||||||
ADDR,
|
, mode()
|
||||||
REGADDR
|
{};
|
||||||
};
|
|
||||||
/* length attributes */
|
void size_i(size_code code) { size = code; }
|
||||||
enum
|
void size_f(size_code code) { size = code; fpu = true; }
|
||||||
{
|
|
||||||
B = 0,
|
unsigned gen;
|
||||||
W = 1,
|
size_code size;
|
||||||
D = 3,
|
bool fpu;
|
||||||
I,
|
|
||||||
I2,
|
std::string mode;
|
||||||
F,
|
|
||||||
L
|
|
||||||
};
|
|
||||||
struct NS32000_OPCODE {
|
|
||||||
const char *mnemonic;
|
|
||||||
u32 operand1;
|
|
||||||
u32 operand;
|
|
||||||
u32 operand3;
|
|
||||||
u32 operand4;
|
|
||||||
offs_t dasm_flags;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class operand_class
|
s32 displacement(offs_t pc, data_buffer const &opcodes, unsigned &bytes);
|
||||||
{
|
void decode(addr_mode *mode, offs_t pc, data_buffer const &opcodes, unsigned &bytes);
|
||||||
SOURCE,
|
std::string reglist(u8 imm);
|
||||||
BITPOS,
|
|
||||||
DESTINATION,
|
|
||||||
ADDRESS,
|
|
||||||
SCALED_INDEX
|
|
||||||
};
|
|
||||||
|
|
||||||
static const NS32000_OPCODE format0_op[1];
|
|
||||||
static const NS32000_OPCODE format1_op[16];
|
|
||||||
static const NS32000_OPCODE format2_op[8];
|
|
||||||
static const NS32000_OPCODE format3_op[16];
|
|
||||||
static const NS32000_OPCODE format4_op[16];
|
|
||||||
static const NS32000_OPCODE format5_op[16];
|
|
||||||
static const NS32000_OPCODE format6_op[16];
|
|
||||||
static const NS32000_OPCODE format7_op[16];
|
|
||||||
static const NS32000_OPCODE format8_op[16];
|
|
||||||
static const NS32000_OPCODE format9_op[16];
|
|
||||||
static const NS32000_OPCODE format11_op[16];
|
|
||||||
static const NS32000_OPCODE format14_op[16];
|
|
||||||
|
|
||||||
|
|
||||||
static char const *const Format0[];
|
|
||||||
static char const *const Format1[];
|
|
||||||
static char const *const Format2[];
|
|
||||||
static char const *const Format3[];
|
|
||||||
static char const *const Format4[];
|
|
||||||
static char const *const Format5[];
|
|
||||||
static char const *const Format6[];
|
|
||||||
static char const *const Format7[];
|
|
||||||
static char const *const Format8[];
|
|
||||||
static char const *const Format9[];
|
|
||||||
static char const *const Format11[];
|
|
||||||
static char const *const Format14[];
|
|
||||||
static char const *const iType[];
|
|
||||||
static char const *const fType[];
|
|
||||||
static char const *const cType[];
|
|
||||||
static char const *const indexSize[];
|
|
||||||
static char const *const cond[];
|
|
||||||
static char const *const areg[];
|
|
||||||
static char const *const mreg[];
|
|
||||||
static char const *const R[];
|
|
||||||
static char const *const M[];
|
|
||||||
static char const *const PR[];
|
|
||||||
static char const *const FP[];
|
|
||||||
|
|
||||||
std::string mnemonic_index(std::string form, const std::string &itype, const std::string &ftype);
|
|
||||||
uint8_t opcode_format(uint8_t byte);
|
|
||||||
int8_t short2int(uint8_t val);
|
|
||||||
static inline int32_t get_disp(offs_t &pc, const data_buffer &opcodes);
|
|
||||||
static inline std::string format_disp(int32_t disp);
|
|
||||||
static inline std::string get_option_list(uint8_t cfg);
|
|
||||||
static inline std::string get_options(uint8_t opts);
|
|
||||||
static inline std::string get_reg_list(offs_t &pc, const data_buffer &opcodes, bool reverse);
|
|
||||||
|
|
||||||
void stream_gen(std::ostream &stream, u8 gen_addr, u8 op_len, operand_class op_class, offs_t &pc, const data_buffer &opcodes, bool fpreg = false);
|
|
||||||
|
|
||||||
u32 m_base_pc;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MAME_CPU_NS32000_NS32000DASM_H
|
||||||
|
Loading…
Reference in New Issue
Block a user