allinsn.exp misc.exp: New files: Test run scripts
[deliverable/binutils-gdb.git] / gas / doc / c-avr.texi
CommitLineData
8473f7a4
DC
1@c Copyright 2006
2@c Free Software Foundation, Inc.
3@c This is part of the GAS manual.
4@c For copying conditions, see the file as.texinfo.
5
6@ifset GENERIC
7@page
8@node AVR-Dependent
9@chapter AVR Dependent Features
10@end ifset
11
12@ifclear GENERIC
13@node Machine Dependencies
14@chapter AVR Dependent Features
15@end ifclear
16
17@cindex AVR support
18@menu
19* AVR Options:: Options
20* AVR Syntax:: Syntax
21* AVR Opcodes:: Opcodes
22@end menu
23
24@node AVR Options
25@section Options
26@cindex AVR options (none)
27@cindex options for AVR (none)
28
29@table @code
30
31@cindex @code{-mmcu=} command line option, AVR
32@item -mmcu=@var{mcu}
33Specify ATMEL AVR instruction set or MCU type.
34
35Instruction set avr1 is for the minimal AVR core, not supported by the C
7f5ba16d 36compiler, only for assembler programs (MCU types: at90s1200,
8473f7a4
DC
37attiny11, attiny12, attiny15, attiny28).
38
39Instruction set avr2 (default) is for the classic AVR core with up to
408K program memory space (MCU types: at90s2313, at90s2323, attiny22,
41attiny26, at90s2333, at90s2343, at90s4414, at90s4433, at90s4434,
42at90s8515, at90c8534, at90s8535, at86rf401, attiny13, attiny2313,
43attiny261, attiny461, attiny861, attiny24, attiny44, attiny84, attiny25,
71fe8fb3 44attiny45, attiny85, attiny43u, attiny48, attiny88).
8473f7a4
DC
45
46Instruction set avr3 is for the classic AVR core with up to 128K program
982b62a0 47memory space (MCU types: atmega103, at43usb320, at43usb355, at76c711,
2460c166 48at90usb82, at90usb162, attiny167).
8473f7a4
DC
49
50Instruction set avr4 is for the enhanced AVR core with up to 8K program
5cc9c0ab 51memory space (MCU types: atmega48, atmega48p,atmega8, atmega88, atmega88p,
7337fc21
NC
52atmega8515, atmega8535, atmega8hva, at90pwm1, at90pwm2, at90pwm2b,
53at90pwm3, at90pwm3b).
8473f7a4
DC
54
55Instruction set avr5 is for the enhanced AVR core with up to 128K program
38de72b9
NC
56memory space (MCU types: atmega16, atmega161, atmega162, atmega163,
57atmega164p, atmega165, atmega165p, atmega168, atmega168p, atmega169,
58atmega169p, atmega32, atmega323, atmega324p, atmega325, atmega325p,
59atmega328p, atmega329, atmega329p, atmega3250, atmega3250p, atmega3290,
60atmega3290p, atmega32hvb, atmega406, atmega64, atmega640, atmega644,
61atmega644p, atmega128, atmega1280, atmega1281, atmega1284p, atmega645,
62atmega649, atmega6450, atmega6490, atmega16hva, at90can32, at90can64,
70881657
EW
63at90can128, at90pwm216, at90pwm316, atmega32c1, atmega32m1, atmega32u4,
64at90usb646, at90usb647, at90usb1286, at90usb1287, at94k).
026dcbd7
DC
65
66Instruction set avr6 is for the enhanced AVR core with 256K program
67memory space (MCU types: atmega2560, atmega2561).
8473f7a4
DC
68
69@cindex @code{-mall-opcodes} command line option, AVR
70@item -mall-opcodes
71Accept all AVR opcodes, even if not supported by @code{-mmcu}.
72
73@cindex @code{-mno-skip-bug} command line option, AVR
74@item -mno-skip-bug
75This option disable warnings for skipping two-word instructions.
76
77@cindex @code{-mno-wrap} command line option, AVR
78@item -mno-wrap
79This option reject @code{rjmp/rcall} instructions with 8K wrap-around.
80
81@end table
82
83
84@node AVR Syntax
85@section Syntax
86@menu
87* AVR-Chars:: Special Characters
88* AVR-Regs:: Register Names
89* AVR-Modifiers:: Relocatable Expression Modifiers
90@end menu
91
92@node AVR-Chars
93@subsection Special Characters
94
95@cindex line comment character, AVR
96@cindex AVR line comment character
97
98The presence of a @samp{;} on a line indicates the start of a comment
99that extends to the end of the current line. If a @samp{#} appears as
100the first character of a line, the whole line is treated as a comment.
101
102@cindex line separator, AVR
103@cindex statement separator, AVR
104@cindex AVR line separator
105
106The @samp{$} character can be used instead of a newline to separate
107statements.
108
109@node AVR-Regs
110@subsection Register Names
111
112@cindex AVR register names
113@cindex register names, AVR
114
b45619c0 115The AVR has 32 x 8-bit general purpose working registers @samp{r0},
8473f7a4
DC
116@samp{r1}, ... @samp{r31}.
117Six of the 32 registers can be used as three 16-bit indirect address
118register pointers for Data Space addressing. One of the these address
119pointers can also be used as an address pointer for look up tables in
120Flash program memory. These added function registers are the 16-bit
121@samp{X}, @samp{Y} and @samp{Z} - registers.
122
123@smallexample
124X = @r{r26:r27}
125Y = @r{r28:r29}
126Z = @r{r30:r31}
127@end smallexample
128
129@node AVR-Modifiers
130@subsection Relocatable Expression Modifiers
131
132@cindex AVR modifiers
133@cindex syntax, AVR
134
135The assembler supports several modifiers when using relocatable addresses
136in AVR instruction operands. The general syntax is the following:
137
138@smallexample
139modifier(relocatable-expression)
140@end smallexample
141
142@table @code
143@cindex symbol modifiers
144
145@item lo8
146
147This modifier allows you to use bits 0 through 7 of
148an address expression as 8 bit relocatable expression.
149
150@item hi8
151
152This modifier allows you to use bits 7 through 15 of an address expression
153as 8 bit relocatable expression. This is useful with, for example, the
154AVR @samp{ldi} instruction and @samp{lo8} modifier.
155
156For example
157
158@smallexample
159ldi r26, lo8(sym+10)
160ldi r27, hi8(sym+10)
161@end smallexample
162
163@item hh8
164
165This modifier allows you to use bits 16 through 23 of
166an address expression as 8 bit relocatable expression.
167Also, can be useful for loading 32 bit constants.
168
169@item hlo8
170
171Synonym of @samp{hh8}.
172
173@item hhi8
174
175This modifier allows you to use bits 24 through 31 of
176an expression as 8 bit expression. This is useful with, for example, the
177AVR @samp{ldi} instruction and @samp{lo8}, @samp{hi8}, @samp{hlo8},
178@samp{hhi8}, modifier.
179
180For example
181
182@smallexample
183ldi r26, lo8(285774925)
184ldi r27, hi8(285774925)
185ldi r28, hlo8(285774925)
186ldi r29, hhi8(285774925)
187; r29,r28,r27,r26 = 285774925
188@end smallexample
189
190@item pm_lo8
191
192This modifier allows you to use bits 0 through 7 of
193an address expression as 8 bit relocatable expression.
194This modifier useful for addressing data or code from
195Flash/Program memory. The using of @samp{pm_lo8} similar
196to @samp{lo8}.
197
198@item pm_hi8
199
200This modifier allows you to use bits 8 through 15 of
201an address expression as 8 bit relocatable expression.
202This modifier useful for addressing data or code from
203Flash/Program memory.
204
205@item pm_hh8
206
207This modifier allows you to use bits 15 through 23 of
208an address expression as 8 bit relocatable expression.
209This modifier useful for addressing data or code from
210Flash/Program memory.
211
212@end table
213
214@node AVR Opcodes
215@section Opcodes
216
217@cindex AVR opcode summary
218@cindex opcode summary, AVR
219@cindex mnemonics, AVR
220@cindex instruction summary, AVR
221For detailed information on the AVR machine instruction set, see
222@url{www.atmel.com/products/AVR}.
223
224@code{@value{AS}} implements all the standard AVR opcodes.
225The following table summarizes the AVR opcodes, and their arguments.
226
227@smallexample
228@i{Legend:}
229 r @r{any register}
230 d @r{`ldi' register (r16-r31)}
231 v @r{`movw' even register (r0, r2, ..., r28, r30)}
232 a @r{`fmul' register (r16-r23)}
233 w @r{`adiw' register (r24,r26,r28,r30)}
234 e @r{pointer registers (X,Y,Z)}
235 b @r{base pointer register and displacement ([YZ]+disp)}
236 z @r{Z pointer register (for [e]lpm Rd,Z[+])}
237 M @r{immediate value from 0 to 255}
238 n @r{immediate value from 0 to 255 ( n = ~M ). Relocation impossible}
239 s @r{immediate value from 0 to 7}
240 P @r{Port address value from 0 to 63. (in, out)}
241 p @r{Port address value from 0 to 31. (cbi, sbi, sbic, sbis)}
242 K @r{immediate value from 0 to 63 (used in `adiw', `sbiw')}
243 i @r{immediate value}
244 l @r{signed pc relative offset from -64 to 63}
245 L @r{signed pc relative offset from -2048 to 2047}
246 h @r{absolute code address (call, jmp)}
247 S @r{immediate value from 0 to 7 (S = s << 4)}
248 ? @r{use this opcode entry if no parameters, else use next opcode entry}
249
2501001010010001000 clc
2511001010011011000 clh
2521001010011111000 cli
2531001010010101000 cln
2541001010011001000 cls
2551001010011101000 clt
2561001010010111000 clv
2571001010010011000 clz
2581001010000001000 sec
2591001010001011000 seh
2601001010001111000 sei
2611001010000101000 sen
2621001010001001000 ses
2631001010001101000 set
2641001010000111000 sev
2651001010000011000 sez
266100101001SSS1000 bclr S
267100101000SSS1000 bset S
2681001010100001001 icall
2691001010000001001 ijmp
2701001010111001000 lpm ?
2711001000ddddd010+ lpm r,z
2721001010111011000 elpm ?
2731001000ddddd011+ elpm r,z
2740000000000000000 nop
2751001010100001000 ret
2761001010100011000 reti
2771001010110001000 sleep
2781001010110011000 break
2791001010110101000 wdr
2801001010111101000 spm
281000111rdddddrrrr adc r,r
282000011rdddddrrrr add r,r
283001000rdddddrrrr and r,r
284000101rdddddrrrr cp r,r
285000001rdddddrrrr cpc r,r
286000100rdddddrrrr cpse r,r
287001001rdddddrrrr eor r,r
288001011rdddddrrrr mov r,r
289100111rdddddrrrr mul r,r
290001010rdddddrrrr or r,r
291000010rdddddrrrr sbc r,r
292000110rdddddrrrr sub r,r
293001001rdddddrrrr clr r
294000011rdddddrrrr lsl r
295000111rdddddrrrr rol r
296001000rdddddrrrr tst r
2970111KKKKddddKKKK andi d,M
2980111KKKKddddKKKK cbr d,n
2991110KKKKddddKKKK ldi d,M
30011101111dddd1111 ser d
3010110KKKKddddKKKK ori d,M
3020110KKKKddddKKKK sbr d,M
3030011KKKKddddKKKK cpi d,M
3040100KKKKddddKKKK sbci d,M
3050101KKKKddddKKKK subi d,M
3061111110rrrrr0sss sbrc r,s
3071111111rrrrr0sss sbrs r,s
3081111100ddddd0sss bld r,s
3091111101ddddd0sss bst r,s
31010110PPdddddPPPP in r,P
31110111PPrrrrrPPPP out P,r
31210010110KKddKKKK adiw w,K
31310010111KKddKKKK sbiw w,K
31410011000pppppsss cbi p,s
31510011010pppppsss sbi p,s
31610011001pppppsss sbic p,s
31710011011pppppsss sbis p,s
318111101lllllll000 brcc l
319111100lllllll000 brcs l
320111100lllllll001 breq l
321111101lllllll100 brge l
322111101lllllll101 brhc l
323111100lllllll101 brhs l
324111101lllllll111 brid l
325111100lllllll111 brie l
326111100lllllll000 brlo l
327111100lllllll100 brlt l
328111100lllllll010 brmi l
329111101lllllll001 brne l
330111101lllllll010 brpl l
331111101lllllll000 brsh l
332111101lllllll110 brtc l
333111100lllllll110 brts l
334111101lllllll011 brvc l
335111100lllllll011 brvs l
336111101lllllllsss brbc s,l
337111100lllllllsss brbs s,l
3381101LLLLLLLLLLLL rcall L
3391100LLLLLLLLLLLL rjmp L
3401001010hhhhh111h call h
3411001010hhhhh110h jmp h
3421001010rrrrr0101 asr r
3431001010rrrrr0000 com r
3441001010rrrrr1010 dec r
3451001010rrrrr0011 inc r
3461001010rrrrr0110 lsr r
3471001010rrrrr0001 neg r
3481001000rrrrr1111 pop r
3491001001rrrrr1111 push r
3501001010rrrrr0111 ror r
3511001010rrrrr0010 swap r
35200000001ddddrrrr movw v,v
35300000010ddddrrrr muls d,d
354000000110ddd0rrr mulsu a,a
355000000110ddd1rrr fmul a,a
356000000111ddd0rrr fmuls a,a
357000000111ddd1rrr fmulsu a,a
3581001001ddddd0000 sts i,r
3591001000ddddd0000 lds r,i
36010o0oo0dddddbooo ldd r,b
361100!000dddddee-+ ld r,e
36210o0oo1rrrrrbooo std b,r
363100!001rrrrree-+ st e,r
3641001010100011001 eicall
3651001010000011001 eijmp
366@end smallexample
This page took 0.100065 seconds and 4 git commands to generate.