-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavr-opcode.def
208 lines (180 loc) · 7.96 KB
/
avr-opcode.def
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
This file is part of AVRtest -- A simple simulator for the
AVR family of 8-bit microcontrollers designed to test the compiler.
Copyright (C) 2001, 2002, 2003 Theodore A. Roth, Klaus Rudolph
Copyright (C) 2007 Paulo Marques
Copyright (C) 2008-2024 Free Software Foundation, Inc.
AVRtest is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
AVRtest 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 avrtest; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
Before including this file, define a macro
AVR_OPCODE(ID, N_WORDS, N_TICKS, NAME)
where
ID
is a valid C identifier. It is used to compose `func_<ID>'
and `ID_<ID>'.
N_WORDS
is the number of words in flash needed to encode the instruction.
N_TICKS
is the number of instruction cycles needed by the instruction.
NAME
is a human-readable representation of the instruction (nmemonic)
displayed when logging is active. log_put_bit() will fix '*'
on the fly.
*
Instructions might need extra cycles.
#
Instructions might be replaced by the following instruction.
*/
// First entry (ID = 0) is executed when jumping to a location
// outside of the decoded flash memory.
AVR_OPCODE (BAD_PC, 0, 0, "bad PC")
// An invalid opcode inside the decoded flash memory.
AVR_OPCODE (ILLEGAL, 0, 0, "ILLEGAL")
// An instruction with undefined result, e.g. LD R26,X+
AVR_OPCODE (UNDEF, 0, 0, "")
/* SYSCALL N (N = 0..31) is the special code sequence that unconditionally
skips the invalid opcode 0xffff:
CPSE N, N
.word 0xffff
This sequence is unlikely to be seen in real programs and is used to
trigger special target program <-> avrtest interactions:
SYSCALL 31 raise abort
SYSCALL 30 raise exit
SYSCALL 29 write char to PC's stdout
SYSCALL 28 read from PC's stdin
SYSCALL 27 set argc, argv as of -args ...
SYSCALL 26 file I/O
SYSCALL 25 raise abort on 2nd hit
SYSCALL 24 write char to PC's stderr
SYSCALL 23 emulate IEEE double operations
SYSCALL 22 emulate IEEE single operations
SYSCALL 21 misc stuff
SYSCALL 8 dumping 64-bit values to PC's stdout
SYSCALL 7 dumping values to PC's stdout
SYSCALL 4 get / reset cycle count, instruction count, (pseudo) rand
These syscalls are only supported by avrtest_log:
SYSCALL 6..5 performance meters
SYSCALL 3..0 logging control
Remaining syscalls are unused. */
AVR_OPCODE (SYSCALL, 2, 0, "*** SYSCALL")
AVR_OPCODE (ADC, 1, 1, "ADC" )
AVR_OPCODE (ADD, 1, 1, "ADD" )
AVR_OPCODE (ADIW, 1, 2, "ADIW" )
AVR_OPCODE (SBIW, 1, 2, "SBIW" )
AVR_OPCODE (AND, 1, 1, "AND" )
AVR_OPCODE (ANDI, 1, 1, "ANDI" )
AVR_OPCODE (ASR, 1, 1, "ASR" )
AVR_OPCODE (BCLR, 1, 1, "CL*" )
AVR_OPCODE (BLD, 1, 1, "BLD.*" )
AVR_OPCODE (BREAK, 1, 1, "BREAK" )
AVR_OPCODE (BRBC, 1, 1, "BR*C" ) // *
AVR_OPCODE (BRBS, 1, 1, "BR*S" ) // *
AVR_OPCODE (BSET, 1, 1, "SE*" )
AVR_OPCODE (BST, 1, 1, "BST.*" )
AVR_OPCODE (CALL, 2, 4, "CALL" ) // *
AVR_OPCODE (CBI, 1, 2-CX, "CBI.*" )
AVR_OPCODE (COM, 1, 1, "COM" )
AVR_OPCODE (CP, 1, 1, "CP" )
AVR_OPCODE (CPC, 1, 1, "CPC" )
AVR_OPCODE (CPI, 1, 1, "CPI" )
AVR_OPCODE (CPSE, 1, 1, "CPSE" ) // * #
AVR_OPCODE (CPSE2, 1, 1, "CPSE" ) // *
AVR_OPCODE (DEC, 1, 1, "DEC" )
AVR_OPCODE (DES, 1, 1, "DES" )
AVR_OPCODE (EICALL, 1, 4-CX, "EICALL" )
AVR_OPCODE (EIJMP, 1, 2, "EIJMP" )
AVR_OPCODE (ELPM, 1, 3, "ELPM" )
AVR_OPCODE (ELPM_Z, 1, 3, "ELPM Z" )
AVR_OPCODE (ELPM_Z_incr, 1, 3, "ELPM Z+")
AVR_OPCODE (EOR, 1, 1, "EOR" )
AVR_OPCODE (ESPM, 1, 1, "ESPM" )
AVR_OPCODE (FMUL, 1, 2, "FMUL" )
AVR_OPCODE (FMULS, 1, 2, "FMULS" )
AVR_OPCODE (FMULSU, 1, 2, "FMULSU" )
AVR_OPCODE (ICALL, 1, 3-CX, "ICALL" ) // *
AVR_OPCODE (IJMP, 1, 2, "IJMP" )
AVR_OPCODE (IN, 1, 1, "IN" )
AVR_OPCODE (INC, 1, 1, "INC" )
AVR_OPCODE (JMP, 2, 3, "JMP" )
AVR_OPCODE (LDI, 1, 1, "LDI" )
AVR_OPCODE (LDD_Y, 1, 2, "LDD Y+q")
AVR_OPCODE (LDD_Z, 1, 2, "LDD Z+q")
AVR_OPCODE (LDS, 2, 2+CX, "LDS" )
AVR_OPCODE (LDS1, 1, 1, "LDS" ) // Tiny
AVR_OPCODE (LD_X, 1, 2, "LD X" )
AVR_OPCODE (LD_X_decr, 1, 2, "LD -X" )
AVR_OPCODE (LD_X_incr, 1, 2, "LD X+" )
AVR_OPCODE (LD_Y_decr, 1, 2, "LD -Y" )
AVR_OPCODE (LD_Y_incr, 1, 2, "LD Y+" )
AVR_OPCODE (LD_Z_decr, 1, 2, "LD -Z" )
AVR_OPCODE (LD_Z_incr, 1, 2, "LD Z+" )
AVR_OPCODE (LPM, 1, 3, "LPM" )
AVR_OPCODE (LPM_Z, 1, 3, "LPM Z" )
AVR_OPCODE (LPM_Z_incr, 1, 3, "LPM Z+" )
AVR_OPCODE (LSR, 1, 1, "LSR" )
AVR_OPCODE (MOV, 1, 1, "MOV" )
AVR_OPCODE (MOVW, 1, 1, "MOVW" )
AVR_OPCODE (MUL, 1, 2, "MUL" )
AVR_OPCODE (MULS, 1, 2, "MULS" )
AVR_OPCODE (MULSU, 1, 2, "MULSU" )
AVR_OPCODE (NEG, 1, 1, "NEG" )
AVR_OPCODE (NOP, 1, 1, "NOP" )
AVR_OPCODE (OR, 1, 1, "OR" )
AVR_OPCODE (ORI, 1, 1, "ORI" )
AVR_OPCODE (OUT, 1, 1, "OUT" )
AVR_OPCODE (POP, 1, 2, "POP" )
AVR_OPCODE (PUSH, 1, 2-CX, "PUSH" )
AVR_OPCODE (RCALL, 1, 3-CX, "RCALL" ) // *
AVR_OPCODE (RET, 1, 4, "RET" ) // *
AVR_OPCODE (RETI, 1, 4, "RETI" ) // *
AVR_OPCODE (RJMP, 1, 2, "RJMP" )
AVR_OPCODE (ROR, 1, 1, "ROR" )
AVR_OPCODE (SBC, 1, 1, "SBC" )
AVR_OPCODE (SBCI, 1, 1, "SBCI" )
AVR_OPCODE (SBI, 1, 2-CX, "SBI.*" )
AVR_OPCODE (SBIC, 1, 1+CX, "SBIC.*" ) // * #
AVR_OPCODE (SBIC2, 1, 1+CX, "SBIC.*" ) // *
AVR_OPCODE (SBIS, 1, 1+CX, "SBIS.*" ) // * #
AVR_OPCODE (SBIS2, 1, 1+CX, "SBIS.*" ) // *
AVR_OPCODE (SBRC, 1, 1, "SBRC.*" ) // * #
AVR_OPCODE (SBRC2, 1, 1, "SBRC.*" ) // *
AVR_OPCODE (SBRS, 1, 1, "SBRS.*" ) // * #
AVR_OPCODE (SBRS2, 1, 1, "SBRS.*" ) // *
AVR_OPCODE (SLEEP, 1, 1, "SLEEP" )
AVR_OPCODE (SPM, 1, 1, "SPM" )
AVR_OPCODE (STD_Y, 1, 2, "STD Y+q")
AVR_OPCODE (STD_Z, 1, 2, "STD Z+q")
AVR_OPCODE (STS, 2, 2, "STS" )
AVR_OPCODE (STS1, 1, 1, "STS" ) // Tiny
AVR_OPCODE (ST_X, 1, 2, "ST X" )
AVR_OPCODE (ST_X_decr, 1, 2, "ST -X" )
AVR_OPCODE (ST_X_incr, 1, 2, "ST X+" )
AVR_OPCODE (ST_Y_decr, 1, 2, "ST -Y" )
AVR_OPCODE (ST_Y_incr, 1, 2, "ST Y+" )
AVR_OPCODE (ST_Z_decr, 1, 2, "ST -Z" )
AVR_OPCODE (ST_Z_incr, 1, 2, "ST Z+" )
AVR_OPCODE (SUB, 1, 1, "SUB" )
AVR_OPCODE (SUBI, 1, 1, "SUBI" )
AVR_OPCODE (SWAP, 1, 1, "SWAP" )
AVR_OPCODE (WDR, 1, 1, "WDR" )
// Some common shortcuts
AVR_OPCODE (CLR, 1, 1, "CLR" )
AVR_OPCODE (LSL, 1, 1, "LSL" )
AVR_OPCODE (ROL, 1, 1, "ROL" )
AVR_OPCODE (TST, 1, 1, "TST" )
// XMEGA instructions
AVR_OPCODE (XCH, 1, 1, "XCH" )
AVR_OPCODE (LAS, 1, 1, "LAS" )
AVR_OPCODE (LAC, 1, 1, "LAC" )
AVR_OPCODE (LAT, 1, 1, "LAT" )