1 /*
2  * readcpu.h - UAE CPU core
3  *
4  * This file is distributed under the GNU General Public License, version 2
5  * or at your option any later version. Read the file gpl.txt for details.
6  */
7 
8 #ifndef UAE_READCPU_H
9 #define UAE_READCPU_H
10 
11 #include "sysdeps.h"
12 
13 
14 ENUMDECL {
15   Dreg, Areg, Aind, Aipi, Apdi, Ad16, Ad8r,
16   absw, absl, PC16, PC8r, imm, imm0, imm1, imm2, immi, am_unknown, am_illg
17 } ENUMNAME (amodes);
18 
19 ENUMDECL {
20     i_ILLG,
21 
22     i_OR, i_AND, i_EOR, i_ORSR, i_ANDSR, i_EORSR,
23     i_SUB, i_SUBA, i_SUBX, i_SBCD,
24     i_ADD, i_ADDA, i_ADDX, i_ABCD,
25     i_NEG, i_NEGX, i_NBCD, i_CLR, i_NOT, i_TST,
26     i_BTST, i_BCHG, i_BCLR, i_BSET,
27     i_CMP, i_CMPM, i_CMPA,
28     i_MVPRM, i_MVPMR, i_MOVE, i_MOVEA, i_MVSR2, i_MV2SR,
29     i_SWAP, i_EXG, i_EXT, i_MVMEL, i_MVMLE,
30     i_TRAP, i_MVR2USP, i_MVUSP2R, i_RESET, i_NOP, i_STOP, i_RTE, i_RTD,
31     i_LINK, i_UNLK,
32     i_RTS, i_TRAPV, i_RTR,
33     i_JSR, i_JMP, i_BSR, i_Bcc,
34     i_LEA, i_PEA, i_DBcc, i_Scc,
35     i_DIVU, i_DIVS, i_MULU, i_MULS,
36     i_ASR, i_ASL, i_LSR, i_LSL, i_ROL, i_ROR, i_ROXL, i_ROXR,
37     i_ASRW, i_ASLW, i_LSRW, i_LSLW, i_ROLW, i_RORW, i_ROXLW, i_ROXRW,
38     i_CHK,i_CHK2,
39     i_MOVEC2, i_MOVE2C, i_CAS, i_CAS2, i_DIVL, i_MULL,
40     i_BFTST,i_BFEXTU,i_BFCHG,i_BFEXTS,i_BFCLR,i_BFFFO,i_BFSET,i_BFINS,
41     i_PACK, i_UNPK, i_TAS, i_BKPT, i_CALLM, i_RTM, i_TRAPcc, i_MOVES,
42     i_FPP, i_FDBcc, i_FScc, i_FTRAPcc, i_FBcc, i_FSAVE, i_FRESTORE,
43     i_CINVL, i_CINVP, i_CINVA, i_CPUSHL, i_CPUSHP, i_CPUSHA, i_MOVE16,
44     i_MMUOP,
45 
46     MAX_OPCODE_FAMILY				/* should always be last of the list */
47 } ENUMNAME (instrmnem);
48 
49 extern const struct mnemolookup {
50     instrmnem mnemo;
51     const char *name;
52 } lookuptab[];
53 
54 ENUMDECL {
55     sz_byte, sz_word, sz_long
56 } ENUMNAME (wordsizes);
57 
58 ENUMDECL {
59     fa_set, fa_unset, fa_zero, fa_one, fa_dontcare, fa_unknown, fa_isjmp,
60     fa_isbranch
61 } ENUMNAME (flagaffect);
62 
63 ENUMDECL {
64     fu_used, fu_unused, fu_maybecc, fu_unknown, fu_isjmp
65 } ENUMNAME (flaguse);
66 
67 ENUMDECL {
68     bit0, bit1, bitc, bitC, bitf, biti, bitI, bitj, bitJ, bitk, bitK,
69     bits, bitS, bitd, bitD, bitr, bitR, bitz, bitp, lastbit
70 } ENUMNAME (bitvals);
71 
72 struct instr_def {
73     unsigned int bits;
74     int n_variable;
75     char bitpos[16];
76     unsigned int mask;
77     int cpulevel;
78     int plevel;
79     struct {
80 	unsigned int flaguse:3;
81 	unsigned int flagset:3;
82     } flaginfo[5];
83     unsigned char sduse;
84     const char *opcstr;
85 };
86 
87 extern const struct instr_def defs68k[];
88 extern int n_defs68k;
89 
90 extern struct instr {
91     long int handler;
92     unsigned char dreg;
93     unsigned char sreg;
94     signed char dpos;
95     signed char spos;
96     unsigned char sduse;
97     int flagdead:8, flaglive:8;
98     unsigned int mnemo:8;
99     unsigned int cc:4;
100     unsigned int plev:2;
101     unsigned int size:2;
102     unsigned int smode:5;
103     unsigned int stype:3;
104     unsigned int dmode:5;
105     unsigned int suse:1;
106     unsigned int duse:1;
107     unsigned int unused1:1;
108     unsigned int clev:3;
109     unsigned int isjmp:1;
110     unsigned int unused2:4;
111 } *table68k;
112 
113 extern void read_table68k (void);
114 extern void do_merges (void);
115 extern int get_no_mismatches (void);
116 extern int nr_cpuop_funcs;
117 
118 #endif /* ifndef UAE_READCPU_H */
119