1*e992f068Schristos@c Copyright (C) 2006-2022 Free Software Foundation, Inc. 216dce513Schristos@c This is part of the GAS manual. 316dce513Schristos@c For copying conditions, see the file as.texinfo. 416dce513Schristos 516dce513Schristos@ifset GENERIC 616dce513Schristos@page 716dce513Schristos@node AVR-Dependent 816dce513Schristos@chapter AVR Dependent Features 916dce513Schristos@end ifset 1016dce513Schristos 1116dce513Schristos@ifclear GENERIC 1216dce513Schristos@node Machine Dependencies 1316dce513Schristos@chapter AVR Dependent Features 1416dce513Schristos@end ifclear 1516dce513Schristos 1616dce513Schristos@cindex AVR support 1716dce513Schristos@menu 1816dce513Schristos* AVR Options:: Options 1916dce513Schristos* AVR Syntax:: Syntax 2016dce513Schristos* AVR Opcodes:: Opcodes 21ede78133Schristos* AVR Pseudo Instructions:: Pseudo Instructions 2216dce513Schristos@end menu 2316dce513Schristos 2416dce513Schristos@node AVR Options 2516dce513Schristos@section Options 2616dce513Schristos@cindex AVR options (none) 2716dce513Schristos@cindex options for AVR (none) 2816dce513Schristos 2916dce513Schristos@table @code 3016dce513Schristos 31012573ebSchristos@cindex @code{-mmcu=} command-line option, AVR 3216dce513Schristos@item -mmcu=@var{mcu} 3316dce513SchristosSpecify ATMEL AVR instruction set or MCU type. 3416dce513Schristos 3516dce513SchristosInstruction set avr1 is for the minimal AVR core, not supported by the C 3616dce513Schristoscompiler, only for assembler programs (MCU types: at90s1200, 3716dce513Schristosattiny11, attiny12, attiny15, attiny28). 3816dce513Schristos 3916dce513SchristosInstruction set avr2 (default) is for the classic AVR core with up to 4016dce513Schristos8K program memory space (MCU types: at90s2313, at90s2323, at90s2333, at90s2343, 4116dce513Schristosattiny22, attiny26, at90s4414, at90s4433, at90s4434, at90s8515, at90c8534, 4216dce513Schristosat90s8535). 4316dce513Schristos 4416dce513SchristosInstruction set avr25 is for the classic AVR core with up to 8K program memory 4516dce513Schristosspace plus the MOVW instruction (MCU types: attiny13, attiny13a, attiny2313, 4616dce513Schristosattiny2313a, attiny24, attiny24a, attiny4313, attiny44, attiny44a, attiny84, 4716dce513Schristosattiny84a, attiny25, attiny45, attiny85, attiny261, attiny261a, attiny461, 4816dce513Schristosattiny461a, attiny861, attiny861a, attiny87, attiny43u, attiny48, attiny88, 4916dce513Schristosattiny828, at86rf401, ata6289, ata5272). 5016dce513Schristos 5116dce513SchristosInstruction set avr3 is for the classic AVR core with up to 128K program 5216dce513Schristosmemory space (MCU types: at43usb355, at76c711). 5316dce513Schristos 5416dce513SchristosInstruction set avr31 is for the classic AVR core with exactly 128K program 5516dce513Schristosmemory space (MCU types: atmega103, at43usb320). 5616dce513Schristos 5716dce513SchristosInstruction set avr35 is for classic AVR core plus MOVW, CALL, and JMP 5816dce513Schristosinstructions (MCU types: attiny167, attiny1634, at90usb82, at90usb162, 5916dce513Schristosatmega8u2, atmega16u2, atmega32u2, ata5505). 6016dce513Schristos 6116dce513SchristosInstruction set avr4 is for the enhanced AVR core with up to 8K program 6216dce513Schristosmemory space (MCU types: atmega48, atmega48a, atmega48pa, atmega48p, atmega8, 6316dce513Schristosatmega8a, atmega88, atmega88a, atmega88p, atmega88pa, atmega8515, atmega8535, 6416dce513Schristosatmega8hva, at90pwm1, at90pwm2, at90pwm2b, at90pwm3, at90pwm3b, at90pwm81, 6516dce513Schristosata6285, ata6286). 6616dce513Schristos 6716dce513SchristosInstruction set avr5 is for the enhanced AVR core with up to 128K program 6816dce513Schristosmemory space (MCU types: at90pwm161, atmega16, atmega16a, atmega161, atmega162, 6916dce513Schristosatmega163, atmega164a, atmega164p, atmega164pa, atmega165, atmega165a, 7016dce513Schristosatmega165p, atmega165pa, atmega168, atmega168a, atmega168p, atmega168pa, 7116dce513Schristosatmega169, atmega169a, atmega169p, atmega169pa, atmega32, atmega323, atmega324a, 7216dce513Schristosatmega324p, atmega324pa, atmega325, atmega325a, atmega32, atmega32a, atmega323, 7316dce513Schristosatmega324a, atmega324p, atmega324pa, atmega325, atmega325a, atmega325p, 7416dce513Schristosatmega325p, atmega325pa, atmega3250, atmega3250a, atmega3250p, atmega3250pa, 7516dce513Schristosatmega328, atmega328p, atmega329, atmega329a, atmega329p, atmega329pa, 7616dce513Schristosatmega3290a, atmega3290p, atmega3290pa, atmega406, atmega64, atmega64a, 7716dce513Schristosatmega64rfr2, atmega644rfr2, atmega640, atmega644, atmega644a, atmega644p, 7816dce513Schristosatmega644pa, atmega645, atmega645a, atmega645p, atmega6450, atmega6450a, 7916dce513Schristosatmega6450p, atmega649, atmega649a, atmega649p, atmega6490, atmega6490a, 8016dce513Schristosatmega6490p, atmega16hva, atmega16hva2, atmega16hvb, atmega16hvbrevb, 8116dce513Schristosatmega32hvb, atmega32hvbrevb, atmega64hve, at90can32, at90can64, at90pwm161, 8216dce513Schristosat90pwm216, at90pwm316, atmega32c1, atmega64c1, atmega16m1, atmega32m1, 8316dce513Schristosatmega64m1, atmega16u4, atmega32u4, atmega32u6, at90usb646, at90usb647, at94k, 8416dce513Schristosat90scr100, ata5790, ata5795). 8516dce513Schristos 8616dce513SchristosInstruction set avr51 is for the enhanced AVR core with exactly 128K 8716dce513Schristosprogram memory space (MCU types: atmega128, atmega128a, atmega1280, 8816dce513Schristosatmega1281, atmega1284, atmega1284p, atmega128rfa1, atmega128rfr2, 8916dce513Schristosatmega1284rfr2, at90can128, at90usb1286, at90usb1287, m3000). 9016dce513Schristos 9116dce513SchristosInstruction set avr6 is for the enhanced AVR core with a 3-byte PC 9216dce513Schristos(MCU types: atmega2560, atmega2561, atmega256rfr2, atmega2564rfr2). 9316dce513Schristos 9416dce513SchristosInstruction set avrxmega2 is for the XMEGA AVR core with 8K to 64K 9516dce513Schristosprogram memory space and less than 64K data space (MCU types: 9616dce513Schristosatxmega16a4, atxmega16a4u, atxmega16c4, atxmega16d4, atxmega16x1, 9716dce513Schristosatxmega32a4, atxmega32a4u, atxmega32c4, atxmega32d4, atxmega16e5, 9816dce513Schristosatxmega8e5, atxmega32e5, atxmega32x1). 9916dce513Schristos 100ede78133SchristosInstruction set avrxmega3 is for the XMEGA AVR core with up to 64K 101ede78133Schristosof combined program memory and RAM, and with program memory 102ede78133Schristosvisible in the RAM address space (MCU types: 103ede78133Schristosattiny212, attiny214, attiny412, attiny414, attiny416, attiny417, 104ede78133Schristosattiny814, attiny816, attiny817, attiny1614, attiny1616, attiny1617, 105ede78133Schristosattiny3214, attiny3216, attiny3217). 10616dce513Schristos 10716dce513SchristosInstruction set avrxmega4 is for the XMEGA AVR core with up to 64K 10816dce513Schristosprogram memory space and less than 64K data space (MCU types: 10916dce513Schristosatxmega64a3, atxmega64a3u, atxmega64a4u, atxmega64b1, atxmega64b3, 11016dce513Schristosatxmega64c3, atxmega64d3, atxmega64d4). 11116dce513Schristos 11216dce513SchristosInstruction set avrxmega5 is for the XMEGA AVR core with up to 64K 11316dce513Schristosprogram memory space and greater than 64K data space (MCU types: 11416dce513Schristosatxmega64a1, atxmega64a1u). 11516dce513Schristos 11616dce513SchristosInstruction set avrxmega6 is for the XMEGA AVR core with larger than 11716dce513Schristos64K program memory space and less than 64K data space (MCU types: 11816dce513Schristosatxmega128a3, atxmega128a3u, atxmega128c3, atxmega128d3, atxmega128d4, 11916dce513Schristosatxmega192a3, atxmega192a3u, atxmega128b1, atxmega128b3, atxmega192c3, 12016dce513Schristosatxmega192d3, atxmega256a3, atxmega256a3u, atxmega256a3b, 12116dce513Schristosatxmega256a3bu, atxmega256c3, atxmega256d3, atxmega384c3, 12216dce513Schristosatxmega256d3). 12316dce513Schristos 12416dce513SchristosInstruction set avrxmega7 is for the XMEGA AVR core with larger than 12516dce513Schristos64K program memory space and greater than 64K data space (MCU types: 12616dce513Schristosatxmega128a1, atxmega128a1u, atxmega128a4u). 12716dce513Schristos 12816dce513SchristosInstruction set avrtiny is for the ATtiny4/5/9/10/20/40 12916dce513Schristosmicrocontrollers. 13016dce513Schristos 131012573ebSchristos@cindex @code{-mall-opcodes} command-line option, AVR 13216dce513Schristos@item -mall-opcodes 13316dce513SchristosAccept all AVR opcodes, even if not supported by @code{-mmcu}. 13416dce513Schristos 135012573ebSchristos@cindex @code{-mno-skip-bug} command-line option, AVR 13616dce513Schristos@item -mno-skip-bug 13716dce513SchristosThis option disable warnings for skipping two-word instructions. 13816dce513Schristos 139012573ebSchristos@cindex @code{-mno-wrap} command-line option, AVR 14016dce513Schristos@item -mno-wrap 14116dce513SchristosThis option reject @code{rjmp/rcall} instructions with 8K wrap-around. 14216dce513Schristos 143012573ebSchristos@cindex @code{-mrmw} command-line option, AVR 14416dce513Schristos@item -mrmw 14516dce513SchristosAccept Read-Modify-Write (@code{XCH,LAC,LAS,LAT}) instructions. 14616dce513Schristos 147012573ebSchristos@cindex @code{-mlink-relax} command-line option, AVR 14816dce513Schristos@item -mlink-relax 14916dce513SchristosEnable support for link-time relaxation. This is now on by default 15016dce513Schristosand this flag no longer has any effect. 15116dce513Schristos 152012573ebSchristos@cindex @code{-mno-link-relax} command-line option, AVR 15316dce513Schristos@item -mno-link-relax 15416dce513SchristosDisable support for link-time relaxation. The assembler will resolve 15516dce513Schristosrelocations when it can, and may be able to better compress some debug 15616dce513Schristosinformation. 15716dce513Schristos 158012573ebSchristos@cindex @code{-mgcc-isr} command-line option, AVR 159ede78133Schristos@item -mgcc-isr 160ede78133SchristosEnable the @code{__gcc_isr} pseudo instruction. 161ede78133Schristos 162*e992f068Schristos@cindex @code{-mno-dollar-line-separator} command line option, AVR 163*e992f068Schristos@item -mno-dollar-line-separator 164*e992f068SchristosDo not treat the @code{$} character as a line separator character. 165*e992f068SchristosThis is for languages where @code{$} is valid character inside symbol 166*e992f068Schristosnames. 167*e992f068Schristos 16816dce513Schristos@end table 16916dce513Schristos 17016dce513Schristos 17116dce513Schristos@node AVR Syntax 17216dce513Schristos@section Syntax 17316dce513Schristos@menu 17416dce513Schristos* AVR-Chars:: Special Characters 17516dce513Schristos* AVR-Regs:: Register Names 17616dce513Schristos* AVR-Modifiers:: Relocatable Expression Modifiers 17716dce513Schristos@end menu 17816dce513Schristos 17916dce513Schristos@node AVR-Chars 18016dce513Schristos@subsection Special Characters 18116dce513Schristos 18216dce513Schristos@cindex line comment character, AVR 18316dce513Schristos@cindex AVR line comment character 18416dce513Schristos 18516dce513SchristosThe presence of a @samp{;} anywhere on a line indicates the start of a 18616dce513Schristoscomment that extends to the end of that line. 18716dce513Schristos 18816dce513SchristosIf a @samp{#} appears as the first character of a line, the whole line 18916dce513Schristosis treated as a comment, but in this case the line can also be a 19016dce513Schristoslogical line number directive (@pxref{Comments}) or a preprocessor 19116dce513Schristoscontrol command (@pxref{Preprocessing}). 19216dce513Schristos 19316dce513Schristos@cindex line separator, AVR 19416dce513Schristos@cindex statement separator, AVR 19516dce513Schristos@cindex AVR line separator 19616dce513Schristos 19716dce513SchristosThe @samp{$} character can be used instead of a newline to separate 198*e992f068Schristosstatements. Note: the @option{-mno-dollar-line-separator} option 199*e992f068Schristosdisables this behaviour. 20016dce513Schristos 20116dce513Schristos@node AVR-Regs 20216dce513Schristos@subsection Register Names 20316dce513Schristos 20416dce513Schristos@cindex AVR register names 20516dce513Schristos@cindex register names, AVR 20616dce513Schristos 20716dce513SchristosThe AVR has 32 x 8-bit general purpose working registers @samp{r0}, 20816dce513Schristos@samp{r1}, ... @samp{r31}. 20916dce513SchristosSix of the 32 registers can be used as three 16-bit indirect address 21016dce513Schristosregister pointers for Data Space addressing. One of the these address 21116dce513Schristospointers can also be used as an address pointer for look up tables in 21216dce513SchristosFlash program memory. These added function registers are the 16-bit 21316dce513Schristos@samp{X}, @samp{Y} and @samp{Z} - registers. 21416dce513Schristos 21516dce513Schristos@smallexample 21616dce513SchristosX = @r{r26:r27} 21716dce513SchristosY = @r{r28:r29} 21816dce513SchristosZ = @r{r30:r31} 21916dce513Schristos@end smallexample 22016dce513Schristos 22116dce513Schristos@node AVR-Modifiers 22216dce513Schristos@subsection Relocatable Expression Modifiers 22316dce513Schristos 22416dce513Schristos@cindex AVR modifiers 22516dce513Schristos@cindex syntax, AVR 22616dce513Schristos 22716dce513SchristosThe assembler supports several modifiers when using relocatable addresses 22816dce513Schristosin AVR instruction operands. The general syntax is the following: 22916dce513Schristos 23016dce513Schristos@smallexample 23116dce513Schristosmodifier(relocatable-expression) 23216dce513Schristos@end smallexample 23316dce513Schristos 23416dce513Schristos@table @code 23516dce513Schristos@cindex symbol modifiers 23616dce513Schristos 23716dce513Schristos@item lo8 23816dce513Schristos 23916dce513SchristosThis modifier allows you to use bits 0 through 7 of 240*e992f068Schristosan address expression as an 8 bit relocatable expression. 24116dce513Schristos 24216dce513Schristos@item hi8 24316dce513Schristos 24416dce513SchristosThis modifier allows you to use bits 7 through 15 of an address expression 245*e992f068Schristosas an 8 bit relocatable expression. This is useful with, for example, the 24616dce513SchristosAVR @samp{ldi} instruction and @samp{lo8} modifier. 24716dce513Schristos 24816dce513SchristosFor example 24916dce513Schristos 25016dce513Schristos@smallexample 25116dce513Schristosldi r26, lo8(sym+10) 25216dce513Schristosldi r27, hi8(sym+10) 25316dce513Schristos@end smallexample 25416dce513Schristos 25516dce513Schristos@item hh8 25616dce513Schristos 25716dce513SchristosThis modifier allows you to use bits 16 through 23 of 258*e992f068Schristosan address expression as an 8 bit relocatable expression. 25916dce513SchristosAlso, can be useful for loading 32 bit constants. 26016dce513Schristos 26116dce513Schristos@item hlo8 26216dce513Schristos 26316dce513SchristosSynonym of @samp{hh8}. 26416dce513Schristos 26516dce513Schristos@item hhi8 26616dce513Schristos 26716dce513SchristosThis modifier allows you to use bits 24 through 31 of 268*e992f068Schristosan expression as an 8 bit expression. This is useful with, for example, the 26916dce513SchristosAVR @samp{ldi} instruction and @samp{lo8}, @samp{hi8}, @samp{hlo8}, 27016dce513Schristos@samp{hhi8}, modifier. 27116dce513Schristos 27216dce513SchristosFor example 27316dce513Schristos 27416dce513Schristos@smallexample 27516dce513Schristosldi r26, lo8(285774925) 27616dce513Schristosldi r27, hi8(285774925) 27716dce513Schristosldi r28, hlo8(285774925) 27816dce513Schristosldi r29, hhi8(285774925) 27916dce513Schristos; r29,r28,r27,r26 = 285774925 28016dce513Schristos@end smallexample 28116dce513Schristos 28216dce513Schristos@item pm_lo8 28316dce513Schristos 28416dce513SchristosThis modifier allows you to use bits 0 through 7 of 285*e992f068Schristosan address expression as an 8 bit relocatable expression. 286*e992f068SchristosThis modifier is useful for addressing data or code from 287*e992f068SchristosFlash/Program memory by two-byte words. The use of @samp{pm_lo8} 288*e992f068Schristosis similar to @samp{lo8}. 28916dce513Schristos 29016dce513Schristos@item pm_hi8 29116dce513Schristos 29216dce513SchristosThis modifier allows you to use bits 8 through 15 of 293*e992f068Schristosan address expression as an 8 bit relocatable expression. 294*e992f068SchristosThis modifier is useful for addressing data or code from 295*e992f068SchristosFlash/Program memory by two-byte words. 296*e992f068Schristos 297*e992f068SchristosFor example, when setting the AVR @samp{Z} register with the @samp{ldi} 298*e992f068Schristosinstruction for subsequent use by the @samp{ijmp} instruction: 299*e992f068Schristos 300*e992f068Schristos@smallexample 301*e992f068Schristosldi r30, pm_lo8(sym) 302*e992f068Schristosldi r31, pm_hi8(sym) 303*e992f068Schristosijmp 304*e992f068Schristos@end smallexample 30516dce513Schristos 30616dce513Schristos@item pm_hh8 30716dce513Schristos 30816dce513SchristosThis modifier allows you to use bits 15 through 23 of 309*e992f068Schristosan address expression as an 8 bit relocatable expression. 310*e992f068SchristosThis modifier is useful for addressing data or code from 311*e992f068SchristosFlash/Program memory by two-byte words. 31216dce513Schristos 31316dce513Schristos@end table 31416dce513Schristos 31516dce513Schristos@node AVR Opcodes 31616dce513Schristos@section Opcodes 31716dce513Schristos 31816dce513Schristos@cindex AVR opcode summary 31916dce513Schristos@cindex opcode summary, AVR 32016dce513Schristos@cindex mnemonics, AVR 32116dce513Schristos@cindex instruction summary, AVR 32216dce513SchristosFor detailed information on the AVR machine instruction set, see 32316dce513Schristos@url{www.atmel.com/products/AVR}. 32416dce513Schristos 32516dce513Schristos@code{@value{AS}} implements all the standard AVR opcodes. 32616dce513SchristosThe following table summarizes the AVR opcodes, and their arguments. 32716dce513Schristos 32816dce513Schristos@smallexample 32916dce513Schristos@i{Legend:} 33016dce513Schristos r @r{any register} 33116dce513Schristos d @r{`ldi' register (r16-r31)} 33216dce513Schristos v @r{`movw' even register (r0, r2, ..., r28, r30)} 33316dce513Schristos a @r{`fmul' register (r16-r23)} 33416dce513Schristos w @r{`adiw' register (r24,r26,r28,r30)} 33516dce513Schristos e @r{pointer registers (X,Y,Z)} 33616dce513Schristos b @r{base pointer register and displacement ([YZ]+disp)} 33716dce513Schristos z @r{Z pointer register (for [e]lpm Rd,Z[+])} 33816dce513Schristos M @r{immediate value from 0 to 255} 33916dce513Schristos n @r{immediate value from 0 to 255 ( n = ~M ). Relocation impossible} 34016dce513Schristos s @r{immediate value from 0 to 7} 34116dce513Schristos P @r{Port address value from 0 to 63. (in, out)} 34216dce513Schristos p @r{Port address value from 0 to 31. (cbi, sbi, sbic, sbis)} 34316dce513Schristos K @r{immediate value from 0 to 63 (used in `adiw', `sbiw')} 34416dce513Schristos i @r{immediate value} 34516dce513Schristos l @r{signed pc relative offset from -64 to 63} 34616dce513Schristos L @r{signed pc relative offset from -2048 to 2047} 34716dce513Schristos h @r{absolute code address (call, jmp)} 34816dce513Schristos S @r{immediate value from 0 to 7 (S = s << 4)} 34916dce513Schristos ? @r{use this opcode entry if no parameters, else use next opcode entry} 35016dce513Schristos 35116dce513Schristos1001010010001000 clc 35216dce513Schristos1001010011011000 clh 35316dce513Schristos1001010011111000 cli 35416dce513Schristos1001010010101000 cln 35516dce513Schristos1001010011001000 cls 35616dce513Schristos1001010011101000 clt 35716dce513Schristos1001010010111000 clv 35816dce513Schristos1001010010011000 clz 35916dce513Schristos1001010000001000 sec 36016dce513Schristos1001010001011000 seh 36116dce513Schristos1001010001111000 sei 36216dce513Schristos1001010000101000 sen 36316dce513Schristos1001010001001000 ses 36416dce513Schristos1001010001101000 set 36516dce513Schristos1001010000111000 sev 36616dce513Schristos1001010000011000 sez 36716dce513Schristos100101001SSS1000 bclr S 36816dce513Schristos100101000SSS1000 bset S 36916dce513Schristos1001010100001001 icall 37016dce513Schristos1001010000001001 ijmp 37116dce513Schristos1001010111001000 lpm ? 37216dce513Schristos1001000ddddd010+ lpm r,z 37316dce513Schristos1001010111011000 elpm ? 37416dce513Schristos1001000ddddd011+ elpm r,z 37516dce513Schristos0000000000000000 nop 37616dce513Schristos1001010100001000 ret 37716dce513Schristos1001010100011000 reti 37816dce513Schristos1001010110001000 sleep 37916dce513Schristos1001010110011000 break 38016dce513Schristos1001010110101000 wdr 38116dce513Schristos1001010111101000 spm 38216dce513Schristos000111rdddddrrrr adc r,r 38316dce513Schristos000011rdddddrrrr add r,r 38416dce513Schristos001000rdddddrrrr and r,r 38516dce513Schristos000101rdddddrrrr cp r,r 38616dce513Schristos000001rdddddrrrr cpc r,r 38716dce513Schristos000100rdddddrrrr cpse r,r 38816dce513Schristos001001rdddddrrrr eor r,r 38916dce513Schristos001011rdddddrrrr mov r,r 39016dce513Schristos100111rdddddrrrr mul r,r 39116dce513Schristos001010rdddddrrrr or r,r 39216dce513Schristos000010rdddddrrrr sbc r,r 39316dce513Schristos000110rdddddrrrr sub r,r 39416dce513Schristos001001rdddddrrrr clr r 39516dce513Schristos000011rdddddrrrr lsl r 39616dce513Schristos000111rdddddrrrr rol r 39716dce513Schristos001000rdddddrrrr tst r 39816dce513Schristos0111KKKKddddKKKK andi d,M 39916dce513Schristos0111KKKKddddKKKK cbr d,n 40016dce513Schristos1110KKKKddddKKKK ldi d,M 40116dce513Schristos11101111dddd1111 ser d 40216dce513Schristos0110KKKKddddKKKK ori d,M 40316dce513Schristos0110KKKKddddKKKK sbr d,M 40416dce513Schristos0011KKKKddddKKKK cpi d,M 40516dce513Schristos0100KKKKddddKKKK sbci d,M 40616dce513Schristos0101KKKKddddKKKK subi d,M 40716dce513Schristos1111110rrrrr0sss sbrc r,s 40816dce513Schristos1111111rrrrr0sss sbrs r,s 40916dce513Schristos1111100ddddd0sss bld r,s 41016dce513Schristos1111101ddddd0sss bst r,s 41116dce513Schristos10110PPdddddPPPP in r,P 41216dce513Schristos10111PPrrrrrPPPP out P,r 41316dce513Schristos10010110KKddKKKK adiw w,K 41416dce513Schristos10010111KKddKKKK sbiw w,K 41516dce513Schristos10011000pppppsss cbi p,s 41616dce513Schristos10011010pppppsss sbi p,s 41716dce513Schristos10011001pppppsss sbic p,s 41816dce513Schristos10011011pppppsss sbis p,s 41916dce513Schristos111101lllllll000 brcc l 42016dce513Schristos111100lllllll000 brcs l 42116dce513Schristos111100lllllll001 breq l 42216dce513Schristos111101lllllll100 brge l 42316dce513Schristos111101lllllll101 brhc l 42416dce513Schristos111100lllllll101 brhs l 42516dce513Schristos111101lllllll111 brid l 42616dce513Schristos111100lllllll111 brie l 42716dce513Schristos111100lllllll000 brlo l 42816dce513Schristos111100lllllll100 brlt l 42916dce513Schristos111100lllllll010 brmi l 43016dce513Schristos111101lllllll001 brne l 43116dce513Schristos111101lllllll010 brpl l 43216dce513Schristos111101lllllll000 brsh l 43316dce513Schristos111101lllllll110 brtc l 43416dce513Schristos111100lllllll110 brts l 43516dce513Schristos111101lllllll011 brvc l 43616dce513Schristos111100lllllll011 brvs l 43716dce513Schristos111101lllllllsss brbc s,l 43816dce513Schristos111100lllllllsss brbs s,l 43916dce513Schristos1101LLLLLLLLLLLL rcall L 44016dce513Schristos1100LLLLLLLLLLLL rjmp L 44116dce513Schristos1001010hhhhh111h call h 44216dce513Schristos1001010hhhhh110h jmp h 44316dce513Schristos1001010rrrrr0101 asr r 44416dce513Schristos1001010rrrrr0000 com r 44516dce513Schristos1001010rrrrr1010 dec r 44616dce513Schristos1001010rrrrr0011 inc r 44716dce513Schristos1001010rrrrr0110 lsr r 44816dce513Schristos1001010rrrrr0001 neg r 44916dce513Schristos1001000rrrrr1111 pop r 45016dce513Schristos1001001rrrrr1111 push r 45116dce513Schristos1001010rrrrr0111 ror r 45216dce513Schristos1001010rrrrr0010 swap r 45316dce513Schristos00000001ddddrrrr movw v,v 45416dce513Schristos00000010ddddrrrr muls d,d 45516dce513Schristos000000110ddd0rrr mulsu a,a 45616dce513Schristos000000110ddd1rrr fmul a,a 45716dce513Schristos000000111ddd0rrr fmuls a,a 45816dce513Schristos000000111ddd1rrr fmulsu a,a 45916dce513Schristos1001001ddddd0000 sts i,r 46016dce513Schristos1001000ddddd0000 lds r,i 46116dce513Schristos10o0oo0dddddbooo ldd r,b 46216dce513Schristos100!000dddddee-+ ld r,e 46316dce513Schristos10o0oo1rrrrrbooo std b,r 46416dce513Schristos100!001rrrrree-+ st e,r 46516dce513Schristos1001010100011001 eicall 46616dce513Schristos1001010000011001 eijmp 46716dce513Schristos@end smallexample 468ede78133Schristos 469ede78133Schristos@node AVR Pseudo Instructions 470ede78133Schristos@section Pseudo Instructions 471ede78133Schristos 472ede78133SchristosThe only available pseudo-instruction @code{__gcc_isr} can be activated by 473ede78133Schristosoption @option{-mgcc-isr}. 474ede78133Schristos 475ede78133Schristos@table @code 476ede78133Schristos 477ede78133Schristos@item __gcc_isr 1 478ede78133SchristosEmit code chunk to be used in avr-gcc ISR prologue. 479ede78133SchristosIt will expand to at most six 1-word instructions, all optional: 480ede78133Schristospush of @code{tmp_reg}, push of @code{SREG}, 481ede78133Schristospush and clear of @code{zero_reg}, push of @var{Reg}. 482ede78133Schristos 483ede78133Schristos@item __gcc_isr 2 484ede78133SchristosEmit code chunk to be used in an avr-gcc ISR epilogue. 485ede78133SchristosIt will expand to at most five 1-word instructions, all optional: 486ede78133Schristospop of @var{Reg}, pop of @code{zero_reg}, 487ede78133Schristospop of @code{SREG}, pop of @code{tmp_reg}. 488ede78133Schristos 489ede78133Schristos@item __gcc_isr 0, @var{Reg} 490ede78133SchristosFinish avr-gcc ISR function. Scan code since the last prologue 491ede78133Schristosfor usage of: @code{SREG}, @code{tmp_reg}, @code{zero_reg}. 492ede78133SchristosPrologue chunk and epilogue chunks will be replaced by appropriate code 493ede78133Schristosto save / restore @code{SREG}, @code{tmp_reg}, @code{zero_reg} and @var{Reg}. 494ede78133Schristos 495ede78133Schristos@end table 496ede78133Schristos 497ede78133SchristosExample input: 498ede78133Schristos 499ede78133Schristos@example 500ede78133Schristos__vector1: 501ede78133Schristos __gcc_isr 1 502ede78133Schristos lds r24, var 503ede78133Schristos inc r24 504ede78133Schristos sts var, r24 505ede78133Schristos __gcc_isr 2 506ede78133Schristos reti 507ede78133Schristos __gcc_isr 0, r24 508ede78133Schristos@end example 509ede78133Schristos 510ede78133SchristosExample output: 511ede78133Schristos 512ede78133Schristos@example 513ede78133Schristos00000000 <__vector1>: 514ede78133Schristos 0: 8f 93 push r24 515ede78133Schristos 2: 8f b7 in r24, 0x3f 516ede78133Schristos 4: 8f 93 push r24 517ede78133Schristos 6: 80 91 60 00 lds r24, 0x0060 ; 0x800060 <var> 518ede78133Schristos a: 83 95 inc r24 519ede78133Schristos c: 80 93 60 00 sts 0x0060, r24 ; 0x800060 <var> 520ede78133Schristos 10: 8f 91 pop r24 521ede78133Schristos 12: 8f bf out 0x3f, r24 522ede78133Schristos 14: 8f 91 pop r24 523ede78133Schristos 16: 18 95 reti 524ede78133Schristos@end example 525