summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/pic16/pic16d.h
blob: 8ebde81740c5388cad6c412712d0b625e69b3f52 (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
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert

// PIC16 generic disassembler, with extended opcodes

#ifndef MAME_CPU_PIC16_PIC16D_H
#define MAME_CPU_PIC16_PIC16D_H

#pragma once

class pic16_disassembler : public util::disasm_interface
{
public:
	pic16_disassembler() = default;
	virtual ~pic16_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:
	struct instruction {
		u16 value;
		u16 mask;
		u32 (*cb)(std::ostream &, const pic16_disassembler *, u16, u16);
	};

	static const instruction instructions[];

	std::string freg(u16 opcode) const;
	static char fw(u16 opcode);
	static std::string imm8(u16 opcode);
	static std::string imm7(u16 opcode);
	static std::string imm6(u16 opcode);
	static std::string imm6s(u16 opcode);
	static std::string imm5(u16 opcode);
	static std::string rel9(u16 opcode, u16 pc);
	std::string abs11(u16 opcode, u16 pc) const;
};

#endif // MAME_CPU_PIC16_PIC16D_H