summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/cosmac/cosdasm.h
blob: 4e2cef9314bcd2737ed059a2e68ab12e02e2968a (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
52
53
54
55
56
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/***************************************************************************

    cosdasm.c

    Simple RCA COSMAC disassembler.
    Written by Curt Coder

***************************************************************************/

#ifndef MAME_CPU_COSMAC_COSDASM_H
#define MAME_CPU_COSMAC_COSDASM_H

#pragma once

class cosmac_disassembler : public util::disasm_interface
{
public:
	enum
	{
		TYPE_1801,
		TYPE_1802,
		TYPE_1805
	};

	class config {
	public:
		virtual ~config() = default;
		virtual uint8_t get_p() const = 0;
		virtual uint8_t get_x() const = 0;
	};

	cosmac_disassembler(int variant, config *conf = nullptr);
	virtual ~cosmac_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;

private:
	int m_variant;

	offs_t implied(const uint8_t opcode);
	offs_t immediate(offs_t &pc, const data_buffer &params);
	offs_t double_immediate(offs_t &pc, const data_buffer &params);
	offs_t short_branch(offs_t base_pc, offs_t &pc, const data_buffer &params);
	offs_t long_branch(offs_t &pc, const data_buffer &params);
	offs_t short_skip(offs_t pc);
	offs_t long_skip(offs_t pc);

	void disassemble_68(std::ostream &stream, offs_t base_pc, offs_t &pc, const data_buffer &opcodes, const data_buffer &params);

	config *const m_config;
};

#endif