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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
// license:BSD-3-Clause
// copyright-holders:David Haywood
#include "emu.h"
#include "arcompact_helper.ipp"
inline uint32_t arcompact_device::branch_common(uint16_t op, bool cond, unsigned width)
{
if (cond)
{
int s = util::sext(op, width);
uint32_t realaddress = (m_pc & 0xfffffffc) + (s * 2);
return realaddress;
}
return m_pc + 2;
}
// #######################################################################################################################
// IIII I s
// BREQ_S b,0,s8 1110 1bbb 0sss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BREQ_S_b_0_s8(uint16_t op) // BREQ_S b,0,s8
{
uint8_t breg = common16_get_and_expand_breg(op);
return branch_common(op, !m_regs[breg], 7);
}
// #######################################################################################################################
// IIII I s
// BRNE_S b,0,s8 1110 1bbb 1sss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BRNE_S_b_0_s8(uint16_t op) // BRNE_S b,0,s8
{
uint8_t breg = common16_get_and_expand_breg(op);
return branch_common(op, m_regs[breg], 7);
}
// #######################################################################################################################
// IIII ISS
// B_S s10 1111 000s ssss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_B_S_s10(uint16_t op) // B_S s10 (branch always)
{
return branch_common(op, true, 9);
}
// #######################################################################################################################
// IIII ISS
// BEQ_S s10 1111 001s ssss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BEQ_S_s10(uint16_t op) // BEQ_S s10 (branch is zero bit is set)
{
return branch_common(op ,status32_check_z(), 9);
}
// #######################################################################################################################
// IIII ISS
// BNE_S s10 1111 010s ssss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BNE_S_s10(uint16_t op) // BNE_S s10 (branch if zero bit isn't set)
{
return branch_common(op ,!status32_check_z(), 9);
}
// #######################################################################################################################
// IIII ISSs ss
// BGT_S s7 1111 0110 00ss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BGT_S_s7(uint16_t op)
{
return branch_common(op, condition_GT(), 6);
}
// #######################################################################################################################
// IIII ISSs ss
// BGE_S s7 1111 0110 01ss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BGE_S_s7(uint16_t op)
{
return branch_common(op, condition_GE(), 6);
}
// #######################################################################################################################
// IIII ISSs ss
// BLT_S s7 1111 0110 10ss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BLT_S_s7(uint16_t op) // BLT_S
{
return branch_common(op, condition_LT(), 6);
}
// #######################################################################################################################
// IIII ISSs ss
// BLE_S s7 1111 0110 11ss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BLE_S_s7(uint16_t op) // BLE_S
{
return branch_common(op, condition_LE(), 6);
}
// #######################################################################################################################
// IIII ISSs ss
// BHI_S s7 1111 0111 00ss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BHI_S_s7(uint16_t op)
{
return branch_common(op, condition_HI(), 6);
}
// #######################################################################################################################
// IIII ISSs ss
// BHS_S s7 1111 0111 01ss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BHS_S_s7(uint16_t op)
{
return branch_common(op, condition_HS(), 6);
}
// #######################################################################################################################
// IIII ISSs ss
// BLO_S s7 1111 0111 10ss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BLO_S_s7(uint16_t op)
{
return branch_common(op, condition_CS(), 6);
}
// #######################################################################################################################
// IIII ISSs ss
// BLS_S s7 1111 0111 11ss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BLS_S_s7(uint16_t op)
{
return branch_common(op, condition_LS(), 6);
}
// #######################################################################################################################
// IIII I
// BL_S s13 1111 1sss ssss ssss
// #######################################################################################################################
uint32_t arcompact_device::handleop_BL_S_s13(uint16_t op) // BL_S s13
{
int s = util::sext(op, 11);
uint32_t realaddress = (m_pc & 0xfffffffc) + (s * 4);
m_regs[REG_BLINK] = m_pc + 2;
return realaddress;
}
|