1 /* s12z-dis.h -- Header file for s12z-dis.c and s12z-decode.c
2 Copyright (C) 2019 Free Software Foundation, Inc.
4 This file is part of the GNU opcodes library.
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 It is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING3. If not,
18 see <http://www.gnu.org/licenses/>. */
25 /* An abstraction used to read machine code from a source. */
26 struct mem_read_abstraction_base
28 int (*read
) (struct mem_read_abstraction_base
*, int, size_t, bfd_byte
*);
29 void (*advance
) (struct mem_read_abstraction_base
*);
30 bfd_vma (*posn
) (struct mem_read_abstraction_base
*);
34 /* Machine code operators.
35 These *roughly* correspond to opcodes.
36 But describe their purpose rather than their form. */
43 /* Test and branch. */
44 OP_tbNE
, OP_tbEQ
, OP_tbPL
, OP_tbMI
, OP_tbGT
, OP_tbLE
,
45 /* Decrement and branch. */
46 OP_dbNE
, OP_dbEQ
, OP_dbPL
, OP_dbMI
, OP_dbGT
, OP_dbLE
,
48 /* Note: sex and exg are the same opcode.
49 They are mnemonic changes according to the operands. */
57 /* Bit field operations. */
151 /* Used for operands which mutate their index/base registers.
162 /* The class of an operand. */
168 OPND_CL_REGISTER_ALL
, /* Used only for psh/pul. */
169 OPND_CL_REGISTER_ALL16
, /* Used only for psh/pul. */
170 OPND_CL_SIMPLE_MEMORY
,
175 /* Base structure of all operands. */
180 /* OSIZE determines the size of memory access for
181 the operation in which the operand participates.
182 It may be -1 which indicates either unknown
183 (must be determined by other operands) or if
184 it is not applicable for this operation. */
188 /* Immediate operands. Eg: #23 */
189 struct immediate_operand
191 struct operand parent
;
195 /* Bitfield operands. Used only in bfext and bfins
197 struct bitfield_operand
199 struct operand parent
;
204 /* Register operands. */
205 struct register_operand
207 struct operand parent
;
212 /* Simple memory operands. ie, direct memory,
213 no index, no pre/post inc/dec. May be either relative or absolute.
214 Eg st d0, 0x123456 */
215 struct simple_memory_operand
217 struct operand parent
;
225 /* Memory operands. Should be able to represent all memory
226 operands in the S12Z instruction set which are not simple
228 struct memory_operand
230 struct operand parent
;
232 /* True for indirect operands: eg [0x123456] */
235 /* The value of any offset. eg 45 in (45,d7) */
238 /* Does this operand increment or decrement
239 its participating registers. Eg (-s) */
240 enum op_reg_mutation mutation
;
242 /* The number of registers participating in this operand.
243 For S12Z this is always in the range [0, 6] (but for most
244 instructions it's <= 2). */
247 /* The participating registers. */
252 /* Decode a single instruction.
253 OPERATOR, OSIZE, N_OPERANDS and OPERANDS are pointers to
254 variables which must be provided by the caller.
255 N_OPERANDS will be incremented by the number of operands read, so
256 you should assign it to something before calling this function.
257 OPERANDS must be large enough to contain all operands read
258 (which may be up to 6).
259 It is the responsibility of the caller to free all operands
260 when they are no longer needed.
261 Returns the number of bytes read. */
262 int decode_s12z (enum operator *myoperator
, short *osize
,
263 int *n_operands
, struct operand
**operands
,
264 struct mem_read_abstraction_base
*);
267 #endif /* S12Z_OPC_H */