Various binary patten fixes.
[deliverable/binutils-gdb.git] / include / h8300-opcode.h
1 /* Opcode table for the H8-300
2 Copyright (C) 1989, 1991 Free Software Foundation.
3
4 This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler.
5
6 Both GDB and GAS are free software; you can redistribute and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
9 any later version.
10
11 GDB and GAS are distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GDB or GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20
21 By steve@cygnus.com
22 */
23
24 typedef enum
25 {
26 Hex0=0,
27 Hex1,Hex2,Hex3,Hex4,Hex5,Hex6,Hex7,Hex8,Hex9,HexA,HexB,HexC,HexD,HexE,HexF,
28 START = 0x20,
29 KBIT, /* K is #1, or #2, yielding 0x0 or 0x8 */
30 IMM3, /* bit number */
31 RD8, /* 8 bit reg as 2nd op */
32 RD16, /* 16 bit reg as 2nd op */
33 RS8, /* 8 bit reg as 1st op */
34 RS16, /* 16 bit reg 1st op */
35 IMM8, /* constant which fits into 8 bits */
36 IMM16, /* constant which fits into 16 bits */
37 CCR, /* CCR reg */
38 ABS8SRC, /* abs 8 address mode */
39 ABS8DST, /* abs 8 address mode */
40 DISP8, /* pc rel displacement */
41 ABS16SRC, /* abs 16 address mode */
42 ABS16DST, /* abs 16 address mode */
43 DISPSRC, /* @(r:16) address mode src */
44 DISPDST, /* @(r:16) address mode dst*/
45 DISPREG, /* register from DISP address mode */
46 RDDEC, /* @-rn mode */
47 RSINC, /* @rn+ mode */
48 RDIND, /* @R mode dst */
49 RSIND, /* @R mode src */
50 MEMIND, /* @@r8 mode */
51 IGNORE,
52 B30 = 0x40, /* bit 3 must be low */
53 B31 = 0x80, /* bit 3 must be high */
54
55 E /* End of list */
56 } op_enum_type;
57
58
59 struct code {
60
61 op_enum_type nib[9];
62 } ;
63
64 struct h8_opcode {
65 int length;
66 int noperands; /* Number of operands this opcode takes */
67 int nopcodes; /* Number of opcodes with same mnemonic */
68 char *name;
69 struct code args;
70 struct code data;
71 int value;
72 };
73
74
75
76 struct h8_opcode h8_opcodes[]
77 #ifdef DEFINE_TABLE
78
79 #define BITOP(n,imm, name, op00, op01,op10,op11, op20,op21)\
80 { 2, 2,n, name, {imm,RD8,E}, {op00, op01, imm, RD8,E}},\
81 { 4, 2,n, name, {imm,RDIND,E}, {op10, op11, RDIND, 0, op00,op01, imm, 0,E}},\
82 { 4, 2,n, name, {imm,ABS8DST,E}, {op20, op21, ABS8DST, IGNORE, op00,op01, imm, 0,E}}
83
84 #define EBITOP(n,imm, name, op00, op01,op10,op11, op20,op21)\
85 BITOP(n,imm, name, op00+1, op01, op10,op11, op20,op21),\
86 BITOP(n, RS8, name, op00, op01, op10,op11, op20,op21)
87
88 #define BRANCH(name, op) \
89 { 2, 1, 1,name,{DISP8,E}, { Hex4, op, DISP8,IGNORE,E }}
90
91 #define TWOOP(name, op1, op2,op3) \
92 { 2, 2, 2, name, {IMM8, RD8,E}, { op1, RD8, IMM8,IGNORE,E}},\
93 { 2, 2, 2, name, {RS8, RD8, E}, { op2, op3, RS8, RD8 ,E}}
94
95 #define UNOP(name, op1, op2) \
96 { 2, 1, 1, name, {RS8, E}, { op1, op2, 0, RS8, E}}
97
98 #define UNOP3(name, op1, op2, op3) \
99 {2, 1, 1, name , {RS8, E}, {op1, op2, op3, RS8, E}}
100
101 #define WTWOP(name, op1, op2) \
102 {2, 2, 1, name, {RS16, RD16, E}, { op1, op2, RS16, RD16, E}}
103
104 =
105 {
106 TWOOP("add.b", Hex8, Hex0,Hex8),
107 WTWOP("add.w", Hex0, Hex9),
108 { 2, 2, 1, "adds", {KBIT,RD16|B30, E},{Hex0, HexB, KBIT, RD16|B30, E}},
109 TWOOP("addx", Hex9,Hex0,HexE),
110 TWOOP("and", HexE,Hex1,Hex6),
111 { 2, 2, 1, "andc", {IMM8, CCR, E}, { Hex0, Hex6, IMM8,IGNORE, E}},
112 BITOP(3,IMM3|B30, "band", Hex7, Hex6, Hex7, HexC, Hex7, HexE),
113 BRANCH("bra", Hex0),
114 BRANCH("bt", Hex0),
115 BRANCH("brn", Hex1),
116 BRANCH("bf", Hex1),
117 BRANCH("bhi", Hex2),
118 BRANCH("bls", Hex3),
119 BRANCH("bcc", Hex4),
120 BRANCH("bhs", Hex4),
121 BRANCH("bcs", Hex5),
122 BRANCH("blo", Hex5),
123 BRANCH("bne", Hex6),
124 BRANCH("beq", Hex7),
125 BRANCH("bvc", Hex8),
126 BRANCH("bvs", Hex9),
127 BRANCH("bpl", HexA),
128 BRANCH("bmi", HexB),
129 BRANCH("bge", HexC),
130 BRANCH("blt", HexD),
131 BRANCH("bgt", HexE),
132 BRANCH("ble", HexF),
133 EBITOP(6,IMM3|B30,"bclr", Hex6, Hex2, Hex7, HexD, Hex7, HexF),
134 BITOP(3,IMM3|B31,"biand", Hex7, Hex6, Hex7, HexC, Hex7, HexE),
135 BITOP(3,IMM3|B31, "bild", Hex7, Hex7,Hex7, HexC, Hex7, HexE),
136 BITOP(3,IMM3|B31, "bior", Hex7, Hex4,Hex7, HexC, Hex7, HexE),
137 BITOP(3,IMM3|B31, "bist", Hex6, Hex7,Hex7, HexD, Hex7, HexE),
138 BITOP(3,IMM3|B31, "bixor", Hex7, Hex5,Hex7, HexC, Hex7, HexE),
139 BITOP(3,IMM3|B30, "bld", Hex7, Hex7,Hex7, HexC, Hex7, HexE),
140 EBITOP(6,IMM3|B30,"bnot", Hex6, Hex1, Hex7, HexD, Hex7, HexF),
141 BITOP(3,IMM3|B30,"bor", Hex7, Hex4,Hex7, HexC, Hex7, HexE),
142 EBITOP(6,IMM3|B30,"bset", Hex6, Hex0,Hex7, HexD, Hex7, HexF),
143 { 2, 1, 1, "bsr",{DISP8, E},{ Hex5, Hex5, DISP8,IGNORE, E}},
144 BITOP(3,IMM3|B30, "bst", Hex6, Hex7,Hex7, HexD, Hex7, HexF),
145 EBITOP(6,IMM3|B30, "btst", Hex6, Hex3,Hex7, HexC, Hex7, HexE),
146 BITOP(3,IMM3|B30, "bxor", Hex7,Hex5,Hex7, HexC, Hex7, HexE),
147 TWOOP( "cmp.b",HexA, Hex1, HexC),
148 WTWOP( "cmp.w",Hex1,HexD),
149 UNOP( "daa",Hex0, HexF),
150 UNOP( "das",Hex1, HexF),
151 UNOP( "dec",Hex1, HexA),
152 { 2, 2, 1, "divxu",{RS8, RD16|B30, E}, { Hex5, Hex1, RS8, RD16|B30, E}},
153 { 4, 0, 1, "eepmov",{ E}, {Hex7, HexB, Hex5, HexC, Hex5, Hex9, Hex8, HexF,E}},
154 UNOP( "inc", Hex0, HexA),
155 { 2, 1, 3, "jmp",{RSIND|B30, E}, {Hex5, Hex9, RSIND|B30, Hex0, E}},
156 { 4, 1, 3, "jmp",{ABS16SRC, E}, {Hex5, HexA, Hex0, Hex0, ABS16SRC, IGNORE,IGNORE,IGNORE,E}},
157 { 2, 1, 3, "jmp",{MEMIND, E}, {Hex5, HexB, MEMIND,IGNORE, E}},
158 { 2, 1, 3, "jsr",{RSIND|B30, E}, {Hex5, HexD, RSIND|B30, Hex0, E}},
159 { 4, 1, 3, "jsr",{ABS16SRC, E}, {Hex5, HexE, Hex0, Hex0, ABS16SRC,IGNORE,IGNORE,IGNORE, E}},
160 { 2, 1, 3, "jsr",{MEMIND, E}, {Hex5, HexF, MEMIND, IGNORE,E}},
161 { 2, 2, 2, "ldc", {IMM8, CCR, E}, { Hex0, Hex7, IMM8,IGNORE, E}},
162 { 2, 2, 2, "ldc", {RS8, CCR, E}, { Hex0, Hex3, Hex0, RS8, E}},
163
164 { 2, 2,13, "mov.b", {RS8, RD8, E}, { Hex0, HexC, RS8, RD8, E}},
165 { 2, 2,13, "mov.b", {IMM8, RD8, E}, { HexF, RD8, IMM8,IGNORE, E}},
166 { 2, 2,13, "mov.b", {RSIND|B30,RD8, E}, { Hex6, Hex8, RSIND|B30, RD8, E}},
167 { 4, 2,13, "mov.b", {DISPSRC,RD8, E}, { Hex6, HexE, DISPREG|B30, RD8, DISPSRC, IGNORE, IGNORE, IGNORE, E}} ,
168 { 2, 2,13, "mov.b", {RSINC|B30, RD8, E}, { Hex6, HexC, RSINC|B30, RD8, E}},
169
170 { 4, 2,13, "mov.b", {ABS16SRC, RD8, E}, { Hex6, HexA, Hex0, RD8,ABS16SRC, IGNORE,IGNORE,IGNORE,E}},
171 { 2, 2,13, "mov.b", {ABS8SRC, RD8, E}, { Hex2, RD8, ABS8SRC,IGNORE, E}},
172 { 2, 2,13, "mov.b", {RS8, RDIND|B30, E}, { Hex6, Hex8, RDIND|B31, RS8, E}},
173 { 4, 2,13, "mov.b", {RS8, DISPDST, E}, { Hex6, HexE, DISPREG|B31, RS8,DISPDST, IGNORE, IGNORE, IGNORE, E}},
174 { 2, 2,13, "mov.b", {RS8, RDDEC|B31, E}, { Hex6, HexC, RDDEC|B31, RS8, E}},
175 /* Put the 16 bit one in first so it matches first */
176 { 4, 2,13, "mov.b", {RS8, ABS16DST, E}, { Hex6, HexA, Hex8, RS8, ABS16DST,IGNORE,IGNORE,IGNORE, E}},
177 { 2, 2,13, "mov.b", {RS8, ABS8DST, E}, { Hex3, RS8, ABS8DST,IGNORE, E}},
178 { 2, 2,11, "mov.w", {RS16|B30, RD16|B30, E},{ Hex0, HexD, RS16|B30, RD16|B30, E}},
179 { 4, 2,11, "mov.w", {IMM16, RD16|B30, E}, { Hex7, Hex9, Hex0, RD16|B30, IMM16,IGNORE,IGNORE,IGNORE, E}},
180 { 2, 2,11, "mov.w", {RSIND|B30,RD16|B30, E},{ Hex6, Hex9, RSIND|B30, RD16|B30, E}},
181 { 4, 2,11, "mov.w", {DISPSRC,RD16|B30, E}, { Hex6, HexF, DISPREG|B30, RD16|B30, DISPSRC, IGNORE, IGNORE, IGNORE,E}} ,
182 { 2, 2,11, "mov.w", {RSINC|B30, RD16|B30, E}, { Hex6, HexD, RSINC|B30, RD16|B30, E}},
183 { 4, 2,11, "mov.w", {ABS16SRC, RD16|B30, E}, { Hex6, HexB, Hex0, RD16|B30,ABS16SRC,IGNORE,IGNORE,IGNORE, E}},
184 { 2, 2,11, "mov.w", {RS16|B30, RDIND|B30, E},{ Hex6, Hex9, RDIND|B31, RS16|B30, E}},
185 { 4, 2,11, "mov.w", {RS16|B30, DISPDST, E}, { Hex6, HexF, DISPREG|B31, RS16|B30,DISPDST, IGNORE,IGNORE,IGNORE,E}},
186 { 2, 2,11, "mov.w", {RS16|B30, RDDEC|B30, E},{ Hex6, HexD, RDDEC|B31, RS16|B30, E}},
187 { 4, 2,11, "mov.w", {RS16|B30, ABS16DST, E}, { Hex6, HexB, Hex8, RS16|B30, ABS16DST, IGNORE, IGNORE, IGNORE, E}},
188
189
190 { 4, 2,1, "movfpe", {ABS16SRC, RD8, E}, { Hex6, HexA, Hex4, RD8, ABS16SRC,IGNORE,IGNORE,IGNORE, E}},
191 { 4, 2,1, "movtpe", {RS8, ABS16DST, E}, { Hex6, HexA, HexC, RS8, ABS16DST,IGNORE,IGNORE,IGNORE, E}},
192 { 2, 2,1, "mulxu", {RS8, RD16|B30, E}, { Hex5, Hex0, RS8, RD16|B30, E}},
193 { 2, 1,1, "neg", {RS8, E}, { Hex1, Hex7, Hex8, RS8, E}},
194 { 2, 0,1, "nop", {E}, { Hex0, Hex0, Hex0, Hex0,E}},
195 { 2, 1,1, "not", {RS8,E}, { Hex1, Hex7, Hex0, RS8,E}},
196 TWOOP("or", HexC, Hex1, Hex4),
197 { 2, 2,1, "orc", {IMM8, CCR,E}, { Hex0, Hex4, IMM8,IGNORE,E}},
198 { 2, 1,1, "pop", {RS16|B30,E}, { Hex6, HexD, Hex7, RS16|B30,E}},
199 { 2, 1,1, "push", {RS16|B30,E}, { Hex6, HexD, HexF, RS16|B30,E}},
200 UNOP3( "rotl",Hex1, Hex2,Hex8),
201 UNOP3( "rotr",Hex1, Hex3, Hex8),
202 UNOP3( "rotxl",Hex1, Hex2, Hex0),
203 UNOP3( "rotxr",Hex1, Hex3, Hex0),
204 { 2, 0, 1, "rte", {E}, { Hex5, Hex6, Hex7, Hex0,E}},
205 { 2, 0, 1, "rts", {E}, { Hex5, Hex4, Hex7, Hex0,E}},
206 UNOP3( "shal", Hex1, Hex0, Hex8),
207 UNOP3( "shar", Hex1, Hex1, Hex8),
208 UNOP3( "shll", Hex1, Hex0, Hex0),
209 UNOP3( "shlr", Hex1, Hex1, Hex0),
210 { 2, 0, 1, "sleep", {E}, { Hex0, Hex1, Hex8, Hex0,E}},
211 { 2, 2, 1, "stc", {CCR, RD8,E}, { Hex0, Hex2, Hex0, RD8,E}},
212 { 2, 2, 1, "sub.b", {RS8,RD8,E}, { Hex1, Hex8, RS8, RD8,E}},
213 { 2, 2, 1, "sub.w", {RS16|B30, RD16|B30,E}, {Hex1, Hex9, RS16|B30, RD16|B30,E}},
214 { 2, 2, 1, "subs", {KBIT,RD16|B30,E}, { Hex1, HexB, KBIT, RD16|B30,E}},
215 TWOOP("subx",HexB, Hex1, HexE),
216 TWOOP("xor", HexD, Hex1, Hex5),
217 { 2, 2, 1,"xorc", {IMM8, CCR,E}, { Hex0, Hex5, IMM8,IGNORE,E}},
218 { 2, 0,1, "bad 52", {E, IMM8}, { Hex5, Hex2, IMM8, IGNORE,E}},
219 { 2, 0,1, "bad 53", {E, IMM8}, { Hex5, Hex3, IMM8, IGNORE,E}},
220 { 2, 0,1, "bad 57", {E, IMM8}, { Hex5, Hex7, IMM8, IGNORE,E}},
221 { 2, 0,1, "bad 58", {E, IMM8}, { Hex5, Hex8, IMM8, IGNORE,E}},
222 { 2, 0,1, "bad 64", {E, IMM8}, { Hex6, Hex4, IMM8, IGNORE,E}},
223 { 2, 0,1, "bad 65", {E, IMM8}, { Hex6, Hex5, IMM8, IGNORE,E}},
224 { 2, 0,1, "bad 66", {E, IMM8}, { Hex6, Hex6, IMM8, IGNORE,E}},
225 { 2, 0,1, "bad 78", {E, IMM8}, { Hex7, Hex8, IMM8, IGNORE,E}},
226 { 2, 0,1, "bad 7a", {E, IMM8}, { Hex7, HexA, IMM8, IGNORE,E}},
227 { 2, 0,1, "bad 5c", {E, IMM8}, { Hex5, HexC, IMM8, IGNORE,E}},
228
229 0
230 }
231
232
233
234 #endif
235
236 ;
This page took 0.048409 seconds and 4 git commands to generate.