summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/e132xs/e1dasm.h
blob: 4a3803cc513a9b5a85cc4e470b8d363d43e66b92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// license:BSD-3-Clause
// copyright-holders:Pierpaolo Prazzoli
/*

 Hyperstone E1 disassembler
 written by Pierpaolo Prazzoli

*/

#ifndef MAME_CPU_E132XS_E1DASM_H
#define MAME_CPU_E132XS_E1DASM_H

#pragma once

#include <iosfwd>
#include <string_view>


class hyperstone_disassembler : public util::disasm_interface
{
public:
	struct config
	{
		virtual ~config() = default;

		virtual bool get_h() const = 0;
	};

	hyperstone_disassembler(config *conf);
	virtual ~hyperstone_disassembler() = default;

	virtual u32 opcode_alignment() const override;
	virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;

	offs_t disassemble_one(std::ostream &stream, offs_t pc, const uint16_t *opptr);

private:
	config *m_config;

	int size; // FIXME: not concurrency-safe

	template <typename T> offs_t do_disassemble(std::ostream &stream, offs_t pc, T &&read_hw);

	template <typename T> uint32_t LRconst_format(std::string_view &source, std::string_view &dest, uint16_t op, offs_t pc, T &&read_hw);
	template <typename T> uint32_t RRconst_format(std::string_view &source, std::string_view &dest, uint16_t op, offs_t pc, T &&read_hw);
	template <typename T> int32_t Rimm_format(std::string_view &dest, uint16_t op, offs_t pc, T &&read_hw, unsigned h_flag);
	template <typename T> int32_t PCrel_format(uint16_t op, offs_t pc, T &&read_hw);
	template <typename T> uint32_t RRdis_format(std::string_view &source, std::string_view &dest, uint16_t op, uint16_t next_op, offs_t pc, T &&read_hw);
};

#endif // MAME_CPU_E132XS_E1DASM_H