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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
// license:BSD-3-Clause
// copyright-holders:Peter Trauner,Antoine Mine
/*****************************************************************************
*
* saturnds.c
* portable saturn emulator interface
* (hp calculators)
*
*****************************************************************************/
#ifndef MAME_CPU_SATURN_SATURNDS_H
#define MAME_CPU_SATURN_SATURNDS_H
#pragma once
class saturn_disassembler : public util::disasm_interface
{
public:
struct config {
virtual ~config() = default;
virtual bool get_nonstandard_mnemonics_mode() const = 0;
};
saturn_disassembler(config *conf);
virtual ~saturn_disassembler() = default;
virtual u32 opcode_alignment() const override;
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) override;
private:
// don't split branch and return, source relies on this ordering
enum MNEMONICS
{
Return, ReturnSetXM, ReturnSetCarry, ReturnClearCarry, ReturnFromInterrupt,
jump3,jump4,jump,
call3,call4,call,
branchCarrySet, returnCarrySet,
branchCarryClear, returnCarryClear,
outCS, outC, inA, inC,
unconfig, xconfig, Cid, shutdown, cp1, reset, buscc,
CcopyP, PcopyC, sreq, CswapP,
inton, AloadImm, buscb,
clearAbit, setAbit,
branchAbitclear, returnAbitclear,
branchAbitset, returnAbitset,
clearCbit, setCbit,
branchCbitclear, returnCbitclear,
branchCbitset, returnCbitset,
PCloadA, buscd, PCloadC, intoff, rsi,
jumpA, jumpC, PCcopyA, PCcopyC, AcopyPC, CcopyPC,
clearHST,
branchHSTclear, returnHSTclear,
clearBitST, setBitST,
branchSTclear, returnSTclear,
branchSTset, returnSTset,
branchPdiffers, returnPdiffers,
branchPequals, returnPequals,
branchAequalsB, returnAequalsB,
branchBequalsC, returnBequalsC,
branchAequalsC, returnAequalsC,
branchCequalsD, returnCequalsD,
branchAdiffersB, returnAdiffersB,
branchBdiffersC, returnBdiffersC,
branchAdiffersC, returnAdiffersC,
branchCdiffersD, returnCdiffersD,
branchAzero, returnAzero,
branchBzero, returnBzero,
branchCzero, returnCzero,
branchDzero, returnDzero,
branchAnotzero, returnAnotzero,
branchBnotzero, returnBnotzero,
branchCnotzero, returnCnotzero,
branchDnotzero, returnDnotzero,
branchAgreaterB, returnAgreaterB,
branchBgreaterC, returnBgreaterC,
branchCgreaterA, returnCgreaterA,
branchDgreaterC, returnDgreaterC,
branchAlowerB, returnAlowerB,
branchBlowerC, returnBlowerC,
branchClowerA, returnClowerA,
branchDlowerC, returnDlowerC,
branchAnotlowerB, returnAnotlowerB,
branchBnotlowerC, returnBnotlowerC,
branchCnotlowerA, returnCnotlowerA,
branchDnotlowerC, returnDnotlowerC,
branchAnotgreaterB, returnAnotgreaterB,
branchBnotgreaterC, returnBnotgreaterC,
branchCnotgreaterA, returnCnotgreaterA,
branchDnotgreaterC, returnDnotgreaterC,
SetHexMode, SetDecMode,
PushC, PopC,
D0loadImm2, D0loadImm4, D0loadImm5,
D1loadImm2, D1loadImm4, D1loadImm5,
PloadImm, CloadImm,
clearST,
CcopyST, STcopyC,
swapCST,
incP, decP,
R0copyA, R1copyA, R2copyA, R3copyA, R4copyA,
R0copyC, R1copyC, R2copyC, R3copyC, R4copyC,
AcopyR0, AcopyR1, AcopyR2, AcopyR3, AcopyR4,
CcopyR0, CcopyR1, CcopyR2, CcopyR3, CcopyR4,
D0copyA, D1copyA, D0copyC, D1copyC,
D0copyAShort, D1copyAShort, D0copyCShort, D1copyCShort, // other class mnemonic
SwapAR0, SwapAR1, SwapAR2, SwapAR3, SwapAR4,
SwapCR0, SwapCR1, SwapCR2, SwapCR3, SwapCR4,
SwapAD0, SwapAD1, SwapCD0, SwapCD1,
SwapAD0Short, SwapAD1Short, SwapCD0Short, SwapCD1Short, // other class mnemonic
D0storeA, D1storeA, D0storeC, D1storeC,
AloadD0, AloadD1, CloadD0, CloadD1,
D0addImm, D1addImm, D0subImm, D1subImm,
AaddImm, BaddImm, CaddImm, DaddImm,
AsubImm, BsubImm, CsubImm, DsubImm,
AandB, BandC, CandA, DandC, BandA, CandB, AandC, CandD,
AorB, BorC, CorA, DorC, BorA, CorB, AorC, CorD,
Ashiftrightbit, Bshiftrightbit, Cshiftrightbit, Dshiftrightbit,
AshiftleftCarry, BshiftleftCarry, CshiftleftCarry, DshiftleftCarry,
AshiftrightCarry, BshiftrightCarry, CshiftrightCarry, DshiftrightCarry,
AaddB, BaddC, CaddA, DaddC, AaddA, BaddB, CaddC, DaddD,
BaddA, CaddB, AaddC, CaddD, decA, decB, decC, decD,
AsubB, BsubC, CsubA, DsubC, incA, incB, incC, incD,
BsubA, CsubB, AsubC, CsubD, AsubnB, BsubnC, CsubnA, DsubnC,
clearA, clearB, clearC, clearD,
AcopyB, BcopyC, CcopyA, DcopyC, BcopyA, CcopyB, AcopyC, CcopyD,
AswapB, BswapC, CswapA, DswapC,
Ashiftleft, Bshiftleft, Cshiftleft, Dshiftleft,
Ashiftright, Bshiftright, Cshiftright, Dshiftright,
negateA, negateB, negateC, negateD,
notA, notB, notC, notD
};
enum opcode_sel
{
Complete=-1,
Illegal,
Opcode0, Opcode0E, Opcode0Ea,
Opcode1, Opcode10, Opcode11, Opcode12, Opcode13, Opcode14, Opcode15,
Opcode8, Opcode80, Opcode808, Opcode8081,
Opcode81, Opcode818, Opcode818a, Opcode819, Opcode819a,
Opcode81A, Opcode81Aa, Opcode81Aa0,Opcode81Aa1, Opcode81Aa2, Opcode81B,
Opcode8A, Opcode8B,
Opcode9, Opcode9a, Opcode9b,
OpcodeA, OpcodeAa, OpcodeAb,
OpcodeB, OpcodeBa, OpcodeBb,
OpcodeC,
OpcodeD,
OpcodeE,
OpcodeF
};
enum opcode_adr
{
AdrNone,
AdrAF, AdrA, AdrB, AdrCount,
BranchReturn, TestBranchRet, ImmBranch,
ABranchReturn, // address field A
xBranchReturn, // address field specified in previous opcode entry
Imm, ImmCount, ImmCload, Imm2, Imm4, Imm5,
Dis3, Dis3Call, Dis4, Dis4Call, Abs,
FieldP, FieldWP, FieldXS, FieldX, FieldS, FieldM, FieldB, FieldW, FieldA,
AdrImmCount
};
struct OPCODE
{
opcode_sel sel;
opcode_adr adr;
MNEMONICS mnemonic;
};
config *m_config;
static const char *const adr_b[];
static const char *const adr_af[];
static const char *const adr_a[];
static const char number_2_hex[];
static const char *const mnemonics[][2];
static const OPCODE opcs[][0x10];
static const int field_adr_af[];
static const int field_adr_a[];
static const int field_adr_b[];
const char *field_2_string(int adr_enum);
};
#endif
|