1 // license:BSD-3-Clause
2 // copyright-holders:Wilbert Pol
3 #ifndef MAME_CPU_MINX_MINX_H
4 #define MAME_CPU_MINX_MINX_H
5 
6 #pragma once
7 
8 
9 enum
10 {
11 		MINX_PC=1, MINX_SP, MINX_BA, MINX_HL, MINX_X, MINX_Y,
12 		MINX_U, MINX_V, MINX_F, MINX_E, MINX_N, MINX_I,
13 		MINX_XI, MINX_YI
14 };
15 
16 
17 class minx_cpu_device :  public cpu_device
18 {
19 public:
20 	// construction/destruction
21 	minx_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
22 
23 protected:
24 	// device-level overrides
25 	virtual void device_start() override;
26 	virtual void device_reset() override;
27 
28 	// device_execute_interface overrides
execute_min_cycles()29 	virtual uint32_t execute_min_cycles() const noexcept override { return 1; }
execute_max_cycles()30 	virtual uint32_t execute_max_cycles() const noexcept override { return 4; }
execute_input_lines()31 	virtual uint32_t execute_input_lines() const noexcept override { return 1; }
32 	virtual void execute_run() override;
33 	virtual void execute_set_input(int inputnum, int state) override;
34 
35 	// device_memory_interface overrides
36 	virtual space_config_vector memory_space_config() const override;
37 
38 	// device_state_interface overrides
39 	virtual void state_string_export(const device_state_entry &entry, std::string &str) const override;
40 
41 	// device_disasm_interface overrides
42 	virtual std::unique_ptr<util::disasm_interface> create_disassembler() override;
43 
44 private:
45 	address_space_config m_program_config;
46 
47 	uint16_t  m_PC;
48 	uint16_t  m_SP;
49 	uint16_t  m_BA;
50 	uint16_t  m_HL;
51 	uint16_t  m_X;
52 	uint16_t  m_Y;
53 	uint8_t   m_U;
54 	uint8_t   m_V;
55 	uint8_t   m_F;
56 	uint8_t   m_E;
57 	uint8_t   m_N;
58 	uint8_t   m_I;
59 	uint8_t   m_XI;
60 	uint8_t   m_YI;
61 	uint8_t   m_halted;
62 	uint8_t   m_interrupt_pending;
63 	address_space *m_program;
64 	int m_icount;
65 	// For debugger
66 	uint32_t m_curpc;
67 	uint16_t m_flags;
68 
69 	uint16_t rd16( uint32_t offset );
70 	void wr16( uint32_t offset, uint16_t data );
71 	uint8_t rdop();
72 	uint16_t rdop16();
73 	uint8_t ADD8( uint8_t arg1, uint8_t arg2 );
74 	uint16_t ADD16( uint16_t arg1, uint16_t arg2 );
75 	uint8_t ADDC8( uint8_t arg1, uint8_t arg2 );
76 	uint16_t ADDC16( uint16_t arg1, uint16_t arg2 );
77 	uint8_t INC8( uint8_t arg );
78 	uint16_t INC16( uint16_t arg );
79 	uint8_t SUB8( uint8_t arg1, uint8_t arg2 );
80 	uint16_t SUB16( uint16_t arg1, uint16_t arg2 );
81 	uint8_t SUBC8( uint8_t arg1, uint8_t arg2 );
82 	uint16_t SUBC16( uint16_t arg1, uint16_t arg2 );
83 	uint8_t DEC8( uint8_t arg );
84 	uint16_t DEC16( uint16_t arg );
85 	uint8_t AND8( uint8_t arg1, uint8_t arg2 );
86 	uint8_t OR8( uint8_t arg1, uint8_t arg2 );
87 	uint8_t XOR8( uint8_t arg1, uint8_t arg2 );
88 	uint8_t NOT8( uint8_t arg );
89 	uint8_t NEG8( uint8_t arg );
90 	uint8_t SAL8( uint8_t arg );
91 	uint8_t SAR8( uint8_t arg );
92 	uint8_t SHL8( uint8_t arg );
93 	uint8_t SHR8( uint8_t arg );
94 	uint8_t ROLC8( uint8_t arg );
95 	uint8_t RORC8( uint8_t arg );
96 	uint8_t ROL8( uint8_t arg );
97 	uint8_t ROR8( uint8_t arg );
98 	void PUSH8( uint8_t arg );
99 	void PUSH16( uint16_t arg );
100 	uint8_t POP8();
101 	uint16_t POP16();
102 	void JMP( uint16_t arg );
103 	void CALL( uint16_t arg );
104 
105 	void execute_one();
106 	void execute_one_ce();
107 	void execute_one_cf();
108 
109 	static const int insnminx_cycles[256];
110 	static const int insnminx_cycles_CE[256];
111 	static const int insnminx_cycles_CF[256];
112 
113 };
114 
115 
116 DECLARE_DEVICE_TYPE(MINX, minx_cpu_device)
117 
118 #endif // MAME_CPU_MINX_MINX_H
119