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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
/*
Epson C33 STD Core (S1C33000)
*/
#include "emu.h"
#include "c33std.h"
#include "c33dasm.h"
#include <algorithm>
#include <iterator>
#include <utility>
#include "c33helpers.ipp"
c33std_cpu_device_base::c33std_cpu_device_base(
machine_config const &mconfig,
device_type type,
char const *tag,
device_t *owner,
u32 clock,
address_map_constructor internal_map) :
cpu_device(mconfig, type, tag, owner, clock),
m_memory_config("memory", ENDIANNESS_LITTLE, 16, 28, 0, internal_map),
m_icount(0)
{
}
void c33std_cpu_device_base::device_start()
{
set_icountptr(m_icount);
space(AS_PROGRAM).cache(m_opcodes);
space(AS_PROGRAM).specific(m_data);
std::fill(std::begin(m_gprs), std::end(m_gprs), 0);
m_pc = 0;
m_psr = 0;
m_sp = 0;
m_alr = 0;
m_ahr = 0;
save_item(NAME(m_gprs));
save_item(NAME(m_pc));
save_item(NAME(m_psr));
save_item(NAME(m_sp));
save_item(NAME(m_alr));
save_item(NAME(m_ahr));
state_add(STATE_GENPC, "PC", m_pc ).mask(0xffff'fffe);
state_add(STATE_GENPCBASE, "PCBASE", m_pc ).mask(0xffff'fffe).noshow();
state_add(STATE_GENFLAGS, "GENGLAGS", m_psr ).mask(0x0000'0fdf).formatstr("%4s").noshow();
state_add(C33_R0, "R0", m_gprs[0] );
state_add(C33_R1, "R1", m_gprs[1] );
state_add(C33_R2, "R2", m_gprs[2] );
state_add(C33_R3, "R3", m_gprs[3] );
state_add(C33_R4, "R4", m_gprs[4] );
state_add(C33_R5, "R5", m_gprs[5] );
state_add(C33_R6, "R6", m_gprs[6] );
state_add(C33_R7, "R7", m_gprs[7] );
state_add(C33_R8, "R8", m_gprs[8] );
state_add(C33_R9, "R9", m_gprs[9] );
state_add(C33_R10, "R10", m_gprs[10]);
state_add(C33_R11, "R11", m_gprs[11]);
state_add(C33_R12, "R12", m_gprs[12]);
state_add(C33_R13, "R13", m_gprs[13]);
state_add(C33_R14, "R14", m_gprs[14]);
state_add(C33_R15, "R15", m_gprs[15]);
state_add(C33_PSR, "PSR", m_psr ).mask(0x0000'0fdf);
state_add(C33_SP, "SP", m_sp );
state_add(C33_ALR, "ALR", m_alr );
state_add(C33_AHR, "AHR", m_ahr );
}
void c33std_cpu_device_base::device_reset()
{
m_psr = 0;
}
void c33std_cpu_device_base::execute_run()
{
debugger_instruction_hook(m_pc);
m_icount = 0;
}
device_memory_interface::space_config_vector c33std_cpu_device_base::memory_space_config() const
{
return space_config_vector{ std::make_pair(AS_PROGRAM, &m_memory_config) };
}
std::unique_ptr<util::disasm_interface> c33std_cpu_device_base::create_disassembler()
{
return std::make_unique<c33_disassembler>();
}
void c33std_cpu_device_base::state_string_export(device_state_entry const &entry, std::string &str) const
{
switch (entry.index())
{
case STATE_GENFLAGS:
str = util::string_format("%c%c%c%c",
(m_psr & PSR_MASK_C) ? 'C' : 'c',
(m_psr & PSR_MASK_V) ? 'V' : 'v',
(m_psr & PSR_MASK_Z) ? 'Z' : 'z',
(m_psr & PSR_MASK_N) ? 'N' : 'n');
break;
}
}
|