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/>. */
30 /* An abstraction used to read machine code from a source. */
31 struct mem_read_abstraction_base
33 int (*read
) (struct mem_read_abstraction_base
*, int, size_t, bfd_byte
*);
34 void (*advance
) (struct mem_read_abstraction_base
*);
35 bfd_vma (*posn
) (struct mem_read_abstraction_base
*);
39 /* Machine code operators.
40 These *roughly* correspond to opcodes.
41 But describe their purpose rather than their form. */
48 /* Test and branch. */
49 OP_tbNE
, OP_tbEQ
, OP_tbPL
, OP_tbMI
, OP_tbGT
, OP_tbLE
,
50 /* Decrement and branch. */
51 OP_dbNE
, OP_dbEQ
, OP_dbPL
, OP_dbMI
, OP_dbGT
, OP_dbLE
,
53 /* Note: sex and exg are the same opcode.
54 They are mnemonic changes according to the operands. */
62 /* Bit field operations. */
156 /* Used for operands which mutate their index/base registers.
167 /* The class of an operand. */
173 OPND_CL_REGISTER_ALL
, /* Used only for psh/pul. */
174 OPND_CL_REGISTER_ALL16
, /* Used only for psh/pul. */
175 OPND_CL_SIMPLE_MEMORY
,
180 /* Base structure of all operands. */
185 /* OSIZE determines the size of memory access for
186 the operation in which the operand participates.
187 It may be -1 which indicates either unknown
188 (must be determined by other operands) or if
189 it is not applicable for this operation. */
193 /* Immediate operands. Eg: #23 */
194 struct immediate_operand
196 struct operand parent
;
200 /* Bitfield operands. Used only in bfext and bfins
202 struct bitfield_operand
204 struct operand parent
;
209 /* Register operands. */
210 struct register_operand
212 struct operand parent
;
217 /* Simple memory operands. ie, direct memory,
218 no index, no pre/post inc/dec. May be either relative or absolute.
219 Eg st d0, 0x123456 */
220 struct simple_memory_operand
222 struct operand parent
;
230 /* Memory operands. Should be able to represent all memory
231 operands in the S12Z instruction set which are not simple
233 struct memory_operand
235 struct operand parent
;
237 /* True for indirect operands: eg [0x123456] */
240 /* The value of any offset. eg 45 in (45,d7) */
243 /* Does this operand increment or decrement
244 its participating registers. Eg (-s) */
245 enum op_reg_mutation mutation
;
247 /* The number of registers participating in this operand.
248 For S12Z this is always in the range [0, 6] (but for most
249 instructions it's <= 2). */
252 /* The participating registers. */
257 /* Decode a single instruction.
258 OPERATOR, OSIZE, N_OPERANDS and OPERANDS are pointers to
259 variables which must be provided by the caller.
260 N_OPERANDS will be incremented by the number of operands read, so
261 you should assign it to something before calling this function.
262 OPERANDS must be large enough to contain all operands read
263 (which may be up to 6).
264 It is the responsibility of the caller to free all operands
265 when they are no longer needed.
266 Returns the number of bytes read. */
267 int decode_s12z (enum optr
*myoperator
, short *osize
,
268 int *n_operands
, struct operand
**operands
,
269 struct mem_read_abstraction_base
*);
274 #endif /* S12Z_OPC_H */