summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/mcs51/sab80c535.cpp
blob: f61ba103de3924401450bc05af4f7b9df53f5fff (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
// license:BSD-3-Clause
// copyright-holders:Steve Ellenoff, Manuel Abadia, Couriersud

#include "emu.h"
#include "sab80c535.h"
#include "mcs51dasm.h"

DEFINE_DEVICE_TYPE(SAB80C535, sab80c535_device, "sab80c535", "Siemens SAB80C535")

// 80:*p0
// 81:*sp
// 82:*dpl
// 83:*dph
// 87:*pcon, power control
// 88:*tcon, timer control
// 89:*tmod
// 8a:*tl0
// 8b:*tl1
// 8c:*th0
// 8d:*th1
// 90:*p1
// 98:*scon, serial control
// 99:*sbuf, serial buffer
// a0:*p2
// a8:*ien0
// a9:!ip0
// b0:*p3
// b8:!ien1
// b9: ip1
// c0: ircon, interrupt request control
// c1: ccen
// c2: ccl1
// c3: cch1
// c4: ccl2
// c5: cch2
// c6: ccl3
// c7: cch3
// c8:*t2con
// ca:*crcl
// cb:*crch
// cc:*tl2
// cd:*th2
// d0:*psw
// d8: adcon, a/d control
// d9: addat, a/d data
// da: dapr, d/a program
// db: p6 (also a/d)
// e0:*acc
// e8: p4
// f0:*b
// f8: p5


void sab80c535_device::p4_w(u8 data)
{
	m_p4 = data;
	m_port_out_cb[4](m_p4);
}

u8 sab80c535_device::p4_r()
{
	if (m_p4 == 0)
		return 0;
	return m_p4 & m_port_in_cb[4]();
}

void sab80c535_device::p5_w(u8 data)
{
	m_p5 = data;
	m_port_out_cb[5](m_p5);
}

u8 sab80c535_device::p5_r()
{
	if (m_p5 == 0)
		return 0;
	return m_p5 & m_port_in_cb[5]();
}

void sab80c535_device::adcon_w(u8 data)
{
	m_adcon = data;
}

u8 sab80c535_device::adcon_r()
{
	return m_adcon;
}

u8 sab80c535_device::addat_r()
{
	return m_an_func[m_adcon & 7]() * 2;
}


void sab80c535_device::sfr_map(address_map &map)
{
	i8052_device::sfr_map(map);
	map(0xd8, 0xd8).rw(FUNC(sab80c535_device::adcon_r), FUNC(sab80c535_device::adcon_w));
	map(0xd9, 0xd9).r(FUNC(sab80c535_device::addat_r));
	map(0xe8, 0xe8).rw(FUNC(sab80c535_device::p4_r), FUNC(sab80c535_device::p4_w));
	map(0xf8, 0xf8).rw(FUNC(sab80c535_device::p5_r), FUNC(sab80c535_device::p5_w));
}

sab80c535_device::sab80c535_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: i8052_device(mconfig, SAB80C535, tag, owner, clock, 0)
	, m_an_func(*this, 0)
{
}

void sab80c535_device::device_start()
{
	i8052_device::device_start();
	save_item(NAME(m_p4));
	save_item(NAME(m_p5));
	save_item(NAME(m_adcon));
}

void sab80c535_device::device_reset()
{
	i8052_device::device_reset();
	m_p4 = 0xff;
	m_p5 = 0xff;
	m_adcon = 0x00;
}

std::unique_ptr<util::disasm_interface> sab80c535_device::create_disassembler()
{
	return std::make_unique<sab80c515_disassembler>();
}