/
apexc.h
103 lines (80 loc) · 3.48 KB
/
apexc.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// license:BSD-3-Clause
// copyright-holders:Raphael Nabet
/* register names for apexc_get_reg & apexc_set_reg */
#ifndef MAME_CPU_APEXC_APEXC_H
#define MAME_CPU_APEXC_APEXC_H
#pragma once
#define MCFG_APEXC_TAPE_READ_CB(_devcb) \
devcb = &apexc_cpu_device::set_tape_read_cb(*device, DEVCB_##_devcb);
#define MCFG_APEXC_TAPE_PUNCH_CB(_devcb) \
devcb = &apexc_cpu_device::set_tape_punch_cb(*device, DEVCB_##_devcb);
enum
{
APEXC_CR =1, /* control register */
APEXC_A, /* accumulator */
APEXC_R, /* register */
APEXC_ML, /* memory location */
APEXC_WS, /* working store */
APEXC_STATE, /* whether CPU is running */
};
class apexc_cpu_device : public cpu_device
{
public:
// construction/destruction
apexc_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// static configuration
template<class Object>
static devcb_base &set_tape_read_cb(device_t &device, Object &&object)
{
return downcast<apexc_cpu_device &>(device).m_tape_read_cb.set_callback(std::forward<Object>(object));
}
template<class Object>
static devcb_base &set_tape_punch_cb(device_t &device, Object &&object)
{
return downcast<apexc_cpu_device &>(device).m_tape_punch_cb.set_callback(std::forward<Object>(object));
}
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
// device_execute_interface overrides
virtual uint32_t execute_min_cycles() const override { return 2; }
virtual uint32_t execute_max_cycles() const override { return 75; }
virtual uint32_t execute_input_lines() const override { return 0; }
virtual void execute_run() override;
// device_memory_interface overrides
virtual space_config_vector memory_space_config() const override;
// device_state_interface overrides
virtual void state_import(const device_state_entry &entry) override;
// device_disasm_interface overrides
virtual util::disasm_interface *create_disassembler() override;
inline uint32_t apexc_readmem(uint32_t address) { return m_program->read_dword((address)<<2); }
inline void apexc_writemem(uint32_t address, uint32_t data) { m_program->write_dword((address)<<2, (data)); }
inline void apexc_writemem_masked(uint32_t address, uint32_t data, uint32_t mask) { apexc_writemem((address), (apexc_readmem(address) & ~(mask)) | ((data) & (mask))); }
uint32_t effective_address(uint32_t address);
uint32_t word_read(uint32_t address, uint32_t special);
void word_write(uint32_t address, uint32_t data, uint32_t mask);
uint8_t papertape_read();
void papertape_punch(uint8_t data);
uint32_t load_ml(uint32_t address, uint32_t vector);
void execute();
address_space_config m_program_config;
devcb_read8 m_tape_read_cb;
devcb_write8 m_tape_punch_cb;
uint32_t m_a; /* accumulator */
uint32_t m_r; /* register */
uint32_t m_cr; /* control register (i.e. instruction register) */
int m_ml; /* memory location (current track in working store, and requested word position within track) (10 bits) */
int m_working_store; /* current working store (group of 16 tracks) (1-15) */
int m_current_word; /* current word position within track (0-31) */
int m_running; /* 1 flag: */
/* running: flag implied by the existence of the stop instruction */
uint32_t m_pc; /* address of next instruction for the disassembler */
address_space *m_program;
int m_icount;
// For state
uint32_t m_ml_full;
uint32_t m_genpc;
};
DECLARE_DEVICE_TYPE(APEXC, apexc_cpu_device)
#endif // MAME_CPU_APEXC_APEXC_H