summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/mcs51/i80c51.cpp
blob: 40bf9f23bc1f1dc7ea0a77e35d197747e648fab2 (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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// license:BSD-3-Clause
// copyright-holders:Steve Ellenoff, Manuel Abadia, Couriersud

#include "emu.h"
#include "i80c51.h"
#include "mcs51dasm.h"

DEFINE_DEVICE_TYPE(I80C31, i80c31_device, "i80c31", "Intel 80C31")
DEFINE_DEVICE_TYPE(I80C51, i80c51_device, "i80c51", "Intel 80C51")
DEFINE_DEVICE_TYPE(I87C51, i87c51_device, "i87c51", "Intel 87C51")
DEFINE_DEVICE_TYPE(AT89C4051, at89c4051_device, "at89c4051", "Atmel AT89C4051")
DEFINE_DEVICE_TYPE(P80C552, p80c552_device, "p80c552", "Philips P80C552")
DEFINE_DEVICE_TYPE(P87C552, p87c552_device, "p87c552", "Philips P87C552")
DEFINE_DEVICE_TYPE(P80C562, p80c562_device, "p80c562", "Philips P80C562")

void i80c51_device::device_start()
{
	mcs51_cpu_device::device_start();
	m_slave_address = 0;
	m_slave_mask = 0;

	save_item(NAME(m_slave_address));
	save_item(NAME(m_slave_mask));
}

void i80c51_device::sfr_map(address_map &map)
{
	mcs51_cpu_device::sfr_map(map);
	map(0xa9, 0xa9).rw(FUNC(i80c51_device::slave_address_r), FUNC(i80c51_device::slave_address_w));
	map(0xb9, 0xb9).rw(FUNC(i80c51_device::slave_mask_r), FUNC(i80c51_device::slave_mask_w));
}

void i80c51_device::slave_address_w(u8 data)
{
	m_slave_address = data;
}

u8 i80c51_device::slave_address_r()
{
	return m_slave_address;
}

void i80c51_device::slave_mask_w(u8 data)
{
	m_slave_mask = data;
}

u8 i80c51_device::slave_mask_r()
{
	return m_slave_mask;
}

bool i80c51_device::manage_idle_on_interrupt(u8 ints)
{
	// any interrupt terminates idle mode
	set_idl(0);

	// external interrupt wakes up
	if (ints & (BIT(m_tcon, TCON_IE0) | BIT(m_tcon, TCON_IE1)))
		set_pd(0);
	return BIT(m_pcon, PCON_PD);
}


i80c31_device::i80c31_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: i80c51_device(mconfig, I80C31, tag, owner, clock, 0, 7)
{
}

i80c51_device::i80c51_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int program_width, int io_width)
	: mcs51_cpu_device(mconfig, type, tag, owner, clock, program_width, io_width)
{
	m_has_pd = true;
}

i80c51_device::i80c51_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: i80c51_device(mconfig, I80C51, tag, owner, clock, 12, 7)
{
}

i87c51_device::i87c51_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: i80c51_device(mconfig, I87C51, tag, owner, clock, 12, 7)
{
}

at89c4051_device::at89c4051_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: i80c51_device(mconfig, AT89C4051, tag, owner, clock, 12, 7)
{
}


p80c562_device::p80c562_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int program_width, int io_width)
	: i80c51_device(mconfig, type, tag, owner, clock, program_width, io_width)
{
}

p80c562_device::p80c562_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: p80c562_device(mconfig, P80C562, tag, owner, clock, 0, 8)
{
}

p80c552_device::p80c552_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: p80c562_device(mconfig, P80C552, tag, owner, clock, 0, 8)
{
}

p87c552_device::p87c552_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: p80c562_device(mconfig, P87C552, tag, owner, clock, 12, 8)
{
}

std::unique_ptr<util::disasm_interface> i80c31_device::create_disassembler()
{
	return std::make_unique<i80c51_disassembler>();
}

std::unique_ptr<util::disasm_interface> i80c51_device::create_disassembler()
{
	return std::make_unique<i80c51_disassembler>();
}

std::unique_ptr<util::disasm_interface> p80c562_device::create_disassembler()
{
	return std::make_unique<p8xc562_disassembler>();
}

std::unique_ptr<util::disasm_interface> p80c552_device::create_disassembler()
{
	return std::make_unique<p8xc552_disassembler>();
}

std::unique_ptr<util::disasm_interface> p87c552_device::create_disassembler()
{
	return std::make_unique<p8xc552_disassembler>();
}