File: avropc.h

package info (click to toggle)
ht 2.1.0%2Brepack1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,712 kB
  • ctags: 15,753
  • sloc: cpp: 88,932; ansic: 12,693; sh: 4,081; lex: 226; makefile: 184; yacc: 128
file content (117 lines) | stat: -rw-r--r-- 3,393 bytes parent folder | download | duplicates (4)
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
/*
 *	HT Editor
 *	avropc.cc
 *
 *	Copyright (C) 2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __AVR_OPC_H__
#define __AVR_OPC_H__

#include "io/types.h"

struct avr_opcode
{
	/* The opcode name.  */
	const char *name;

	uint32 mask;

	uint32 opcode;

	/* An array of operand codes.  Each code is an index into the
	   operand table.  They appear in the order which the operands must
	   appear in assembly code, and are terminated by a zero.  */
	byte operands[8];
};

/* The table itself is sorted by major opcode number, and is otherwise
   in the order in which the disassembler should consider
   instructions.  */
extern const struct avr_opcode avr_opcodes[];
extern const int avr_num_opcodes;

/* Values defined for the flags field of a struct powerpc_opcode.  */


/* A macro to extract the major opcode from an instruction.  */
//#define PPC_OP(i) (((i) >> 26) & 0x3f)

/* The operands table is an array of struct powerpc_operand.  */

struct avr_operand
{
	/* The number of bits in the operand.  */
	byte bits;

	/* How far the operand is left shifted in the instruction.  */
	byte shift;
	
	byte add;
	
	byte scale;

	/* Extraction function.  This is used by the disassembler.  To
	   extract this operand type from an instruction, check this field.

	If it is NULL, compute
	    op = ((i) >> o->shift) & ((1 << o->bits) - 1);
	 if ((o->flags & PPC_OPERAND_SIGNED) != 0
		&& (op & (1 << (o->bits - 1))) != 0)
	   op -= 1 << o->bits;
	(i is the instruction, o is a pointer to this structure, and op
	is the result; this assumes twos complement arithmetic).

	If this field is not NULL, then simply call it with the
	instruction value.  It will return the value of the operand.  If
	the INVALID argument is not NULL, *INVALID will be set to
	non-zero if this operand type can not actually be extracted from
	this operand (i.e., the instruction does not match).  If the
	operand is valid, *INVALID will not be changed.  */

	uint32 (*extract)(uint32 instruction, bool *invalid);

	/* One bit syntax flags.  */
	uint32 flags;
};

/* Elements in the table are retrieved by indexing with values from
   the operands field of the powerpc_opcodes table.  */

extern const struct avr_operand avr_operands[];


#define AVR_OPERAND_X   1
#define AVR_OPERAND_XP  2
#define AVR_OPERAND_XM  3
#define AVR_OPERAND_Y   4
#define AVR_OPERAND_YP  5
#define AVR_OPERAND_YM  6
#define AVR_OPERAND_Yq  7
#define AVR_OPERAND_Z   8
#define AVR_OPERAND_ZP  9
#define AVR_OPERAND_ZM  10
#define AVR_OPERAND_Zq  11
#define AVR_OPERAND_XYZ_MASK 0xf
#define AVR_OPERAND_GPR   16
#define AVR_OPERAND_GPR_2 32
#define AVR_OPERAND_IMM   64
#define AVR_OPERAND_FAKE   128
#define AVR_OPERAND_SIGNED 256
#define AVR_OPERAND_ABS   512
#define AVR_OPERAND_REL   1024

#endif