AVR32
9.2 Instruction Formats
This is an overview of the different instruction formats.
9.2.1 Two Register Instructions
\begin{tabular}{|c|c|c|c|} \hline Opcod & Rs/Rp & Opcode & Rd/Rs \ \hline \end{tabular} 15 \quad 13 \quad 12 \quad 9 \quad 8 \quad 4 \quad 3 \quad 0
9.2.2 Single Register Instructions
\begin{tabular}{|c|c|c|} \hline 0 \quad 1 \quad 0 \quad 1 \quad 1 \quad 1 \quad 0 & Opcode & Rd \ \hline \end{tabular} 15 \quad 13 \quad 12 \quad 9 \quad 8 \quad 4 \quad 3 \quad 0
9.2.3 Return and test
\begin{tabular}{|c|c|c|} \hline 0 \quad 1 \quad 0 \quad 1 \quad 1 \quad 1 \quad 1 \quad Opc & cond4 & Rs/Rd \ \hline \end{tabular} 15 \quad 13 \quad 12 \quad 9 \quad 8 \quad 7 \quad 4 \quad 3 \quad 0
9.2.4 K8 immediate and single register
\begin{tabular}{|c|c|c|} \hline 0 \quad 0 \quad 1 \quad Opc & k8 & Rd \ \hline \end{tabular} 15 \quad 13 \quad 12 \quad 11 \quad 4 \quad 3 \quad 0
9.2.5 SP / PC relative load / store
\begin{tabular}{|c|c|c|} \hline 0 \quad 1 \quad 0 \quad Opcode & k7 & Rd/Rs \ \hline \end{tabular} 15 \quad 13 \quad 12 \quad 11 \quad 10 \quad 4 \quad 3 \quad 0
9.2.6 K5 immediate and single register
\begin{tabular}{|c|c|c|} \hline 0 \quad 1 \quad 0 \quad 1 \quad 1 \quad 0 \quad Opc & k5 & Rd \ \hline \end{tabular} 15 \quad 13 \quad 12 \quad 10 \quad 9 \quad 8 \quad 4 \quad 3 \quad 0
9.2.7 Displacement load with k5 immediate
\begin{tabular}{|c|c|c|} \hline 0 \quad 1 \quad 1 \quad Rp & k5 & Rd \ \hline \end{tabular} 15 \quad 13 \quad 12 \quad 9 \quad 8 \quad 4 \quad 3 \quad 0
9.2.8 Displacement load / store with k3 immediate
\begin{tabular}{|c|c|c|c|} \hline 1 \quad 0 \quad 0 \quad Rp & Opcode & k3 & Rd/Rs \ \hline \end{tabular} 15 \quad 14 \quad 13 \quad 12 \quad 9 \quad 8 \quad 7 \quad 6 \quad 4 \quad 3 \quad 0
32000D-04/2011 \hfill 97

9.2.9 One register and a register pair 15 13 12 9 8 6 5 4 3 1 0 | 1 | 0 | 1 | Rp | 1 | 0 | 0 | Opc | Rd/Rs | Opc |
9.2.10 One register with k8 immediate and cond4 31 29 28 25 24 20 19 16 | 1 | 1 | 1 | Opcode | 1 | 1 | 0 | 1 | 1 | Rd | 15 12 11 8 7 0 | 0 | 0 | 0 | 0 | cond4 | k8 |
9.2.11 One register with bit addressing 15 13 12 9 8 5 4 3 0 | 1 | 0 | 1 | Bit[4:1] | Opcode | Bit[0] | Rd |
9.2.12 Short branch 15 13 12 11 4 3 2 0 | 1 | 1 | 0 | 0 | k8 | 0 | cond3 |
9.2.13 Relative jump and call 15 13 12 11 4 3 2 1 0 | 1 | 1 | 0 | 0 | K10[7:0] | 1 | Opc | K10[9:8] |
9.2.14 K8 and no register 15 12 11 4 3 1 0 | 1 | 1 | 0 | 1 | k8/Label | 0 | 0 | 0 | Opc |
9.2.15 Multiple registers (POPM) 15 3 2 0 | 1 | 1 | 0 | 1 | PC LR 12 11 10 9-8 7-4 3-0 k | 0 | 1 | 0 |
9.2.16 Multiple registers (PUSHM) 15 13 12 11 4 3 0 | 1 | 1 | 0 | 1 | PC LR 12 11 10 9-8 7-4 3-0 | 0 | 0 | 1 | 1 |
9.2.17 Status register bit specification 15 11 10 9 8 4 3 0 | 1 | 1 | 0 | 1 | 0 | Opcode | Bit No | 0 | 1 | 0 | 0 |
98 AVR32 32000D–04/2011

9.2.18 Only Opcode
15 9 8 4 3 0
1 1 0 1 0 1 1 Opcode 0 1 0 0
9.2.19 3 registers shifted
31 29 28 25 24 20 19 16
1 1 1 Rb/Rx 0 0 0 0 0 Ry/Ri
15 12 11 8 7 6 5 4 3 0
0 0 0 0 Opcode 0 0 Shift Amount Rd/Rs
9.2.20 3 registers unshifted
31 29 28 25 24 20 19 16
1 1 1 Rx 0 0 0 0 0 Ry
15 12 11 4 3 0
0 0 0 0 Opcode Rd
9.2.21 DSP Halfword Multiply
31 29 28 25 24 20 19 16
1 1 1 Rx 0 0 0 0 0 Ry
15 12 11 8 7 6 5 4 3 0
0 0 0 0 Opcode 0 0 X Y Rd
9.2.22 DSP Word and Halfword Multiply
31 29 28 25 24 20 19 16
1 1 1 Rx 0 0 0 0 0 Ry
15 12 11 8 7 5 4 3 0
0 0 0 0 Opcode 1 0 0 Y Rd
9.2.23 2 register operands with k8 immediate
31 29 28 25 24 20 19 16
1 1 1 Rs 0 0 0 0 0 Rd
15 12 11 8 7 0
0 0 0 1 Opcode k8
32000D-04/2011 ATMEL® 99
9.2.24 2 register operands with k5 immediate
31 29 28 25 24 20 19 16
| 1 | 1 | 1 | Rs | 0 | 0 | 0 | 0 | 0 | Rd |
15 12 11 8 7 5 4 0
| 0 | 0 | 0 | 1 | Opcode | 0 | 0 | 0 | k5 |
9.2.25 2 Registers with w5 and o5
31 29 28 25 24 20 19 16
| 1 | 1 | 1 | Rd | 1 | 1 | 1 | 0 | 1 | Rs |
15 10 9 5 4 0
| Opcode | o5 | w5 |
9.2.26 Coprocessor 0 load and store
31 29 28 26 25 24 20 19 16
| 1 | 1 | 1 | 1 | Opc | 1 | 1 | 0 | 1 | 0 | Rp |
15 13 12 11 8 7 6 0
| k12 [11:8] | CRd/CRs | k12[7:0] |
9.2.27 2 register operands
31 29 28 25 24 20 19 16
| 1 | 1 | 1 | Rs | 0 | 0 | 0 | 0 | 0 | Rd |
15 12 11 8 7 0
| 0 | 0 | 0 | 1 | Opcode | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
9.2.28 Register operand with K16
31 29 28 20 19 16
| 1 | 1 | 1 | Opcode | Rd/Rp |
15 0
| k16 |
9.2.29 Cache operation
31 20 19 16
| 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | Rp |
15 0
| Op5 | k11 |
100 AVR32 32000D–04/2011
AVR32
9.2.30 Register or condition code and K21

9.2.31 No register and k21
9.2.32 Two registers and K16
9.2.33 Register, doubleword register and K16
9.2.34 K16 and bit address
9.2.35 Coprocessor Operation
32000D–04/2011
9.2.36 Coprocessor load and store

9.2.37 Coprocessor load and store multiple registers

9.2.38 Coprocessor load, store and move

9.2.39 Coprocessor load and store with indexed addressing
9.2.40 Register and system register

9.2.41 Sleep and sync

AVR32
9.2.42 Register and bit address

9.2.43 Load and store multiple registers
9.2.44 Register, k12 and halfword select
9.2.45 Register, k12 and byte select
9.2.46 2 Register and k12
9.2.47 ANDL / ANDH
9.2.48 Saturate

9.2.49 3 Registers with k5
9.2.50 2 Registers with k4
9.2.51 2 Registers with cond4
9.2.52 4 Registers with k2
9.2.53 3 Registers with k8 and sa
9.2.54 k3 immediate
AVR32
9.2.55 Address and b5
9.2.56 2 register operands
9.2.57 2 register operands and k3
9.2.58 2 register operands and k4
9.3 Instruction Set Summary
9.3.1 Architecture revision
Unless otherwise noted, all instructions are part of revision 1 of the AVR32 architecture. The following instructions were added in revision 2, none were removed:
• movh Rd, imm • {add, sub, and, or, eor}{cond4}, Rd, Rx, Ry • ld.{sb, ub, sh, uh, w}{cond4} Rd, Rp[disp] • st.{b, h, w}{cond4} Rp[disp], Rs • rsub{cond4} Rd, imm
9.3.2 Arithmetic Operations
Table 9-2. Arithmetic Operations
Table 9-2. Arithmetic Operations (Continued)
| sub | C | Rd, Rs | Subtract. | Rd ← Rd - Rs | 1 |
|---|---|---|---|---|---|
| E | Rd, Rx, Ry << sa | Rd ← Rx - (Ry<<sa2) | 1 | ||
| C | Rd, imm | if (Rd==SP) Rd ← Rd - SE(imm8<<2) else Rd ← Rd - SE(imm8) | 1 | ||
| E | Rd, imm | Rd ← Rd - SE(imm21) | 1 | ||
| E | Rd, Rs, imm | Rd ← Rs - SE(imm16) | 1 | ||
| sub{cond4} | E | Rd, imm | Subtract immediate if condition satisfied. | if (cond4) Rd ← Rd - SE(imm8) | 1 |
| E | Rd, Rx, Ry | Subtract if condition satisfied. | if (cond4) Rd ← Rx - Ry | 2 | |
| tnbz | C | Rd | Test no byte equal to zero. | if (Rd[31:24] == 0 ∨ Rd[23:16] == 0 ∨ Rd[15:8] == 0 ∨ Rd[7:0] == 0 ) Z ← 1 else Z ← 0 | 1 |
9.3.3 Multiplication Operations
Table 9-3. Multiplication Operations
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| divs | E | Rd, Rx, Ry | Signed divide. (32 ← 32/32) | Rd ← Rx / Ry Rd+1 ← Rx % Ry | 1 |
| divu | E | Rd, Rx, Ry | Unsigned divide. (32 ← 32/32) | Rd ← Rx / Ry Rd+1 ← Rx % Ry | 1 |
| mac | E | Rd, Rx, Ry | Multiply accumulate. (32 ← 32x32 + 32) | Rd ← Rx * Ry + Rd | 1 |
| macs.d | E | Rd, Rx, Ry | Multiply signed accumulate. (64 ← 32x32 + 64) | Rd+1:Rd ← Rx * Ry + Rd+1:Rd | 1 |
| macu.d | E | Rd, Rx, Ry | Multiply unsigned accumulate. (64 ← 32x32 + 64) | Rd+1:Rd ← Rx * Ry + Rd+1:Rd | 1 |
| mul | C | Rd, Rs | Multiply. (32 ← 32 x 32) | Rd ← Rx * Rs | 1 |
| E | Rd, Rx, Ry | Multiply. (32 ← 32 x 32) | Rd ← Rx * Ry | 1 | |
| E | Rd, Rs, imm | Multiply immediate. | Rd ← Rs * SE(imm8) | 1 | |
| muls.d | E | Rd, Rx, Ry | Signed Multiply. (64 ← 32 x 32) | Rd+1:Rd ← Rx * Ry | 1 |
| mulu.d | E | Rd, Rx, Ry | Unsigned Multiply. (64 ← 32 x 32) | Rd+1:Rd ← Rx * Ry | 1 |
32000D–04/2011
107
9.3.4 DSP Operations
Table 9-4. DSP Operations
Table 9-4. DSP Operations (Continued)
| mulsathh.h | E | Rd, Rx:, Ry: | Fractional signed multiply with saturation. Return halfword. (16 ← 16 x 16) | Rd ← SE(Sat(Rx: *Ry: << 1) >> 16) | 1 |
|---|---|---|---|---|---|
| mulsathh.w | E | Rd, Rx:, Ry: | Fractional signed multiply with saturation. Return word. (32 ← 16 x 16) | Rd ← Sat( Rx:*Ry: << 1 ) | 1 |
| mulsatrndhh.h | E | Rd, Rx:, Ry: | Fractional signed multiply with rounding. Return halfword. (16 ← 16 x 16) | Rd ← SE(( Sat(Rx: *Ry: << 1) +0x8000 ) >> 16) | 1 |
| mulsatrndwh.w | E | Rd, Rx, Ry: | Fractional signed multiply with rounding. Return word. (32 ← 32 x 16) | Rd ← SE(( Sat(Rx*Ry: << 1) +0x8000 ) >> 16) | 1 |
| mulsatwh.w | E | Rd, Rx, Ry: | Fractional signed multiply with saturation. Return word. (32 ← 32 x 16) | Rd ← Sat(Rx*Ry: << 1) >>16 | 1 |
| macsathh.w | E | Rd, Rx:, Ry: | Fractional signed multiply accumulate with saturation. Return word. (32 ← 16 x 16 + 32) | Rd ← Sat (Sat(Rx: *Ry: << 1) +Rd) | 1 |
32000D–04/2011
109
9.3.5 Logic Operations
Table 9-5. Logic Operations
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| and | C | Rd, Rs | Logical AND. | Rd ← Rd ∧ Rs | 1 |
| E | Rd, Rx, Ry << sa | Rd ← Rx ∧ (Ry << sa5) | 1 | ||
| E | Rd, Rx, Ry >> sa | Rd ← Rx ∧ (Ry >> sa5) | 1 | ||
| and{cond4} | E | Rd, Rx, Ry | Logical AND if condition satisfied. | if (cond4) Rd ← Rx ∧ Ry | 2 |
| andn | C | Rd, Rs | Logical AND NOT. | Rd ← Rd ∧ ¬Rs | 1 |
| andh | E | Rd, imm | Logical AND High Halfword, low halfword is unchanged. | Rd[31:16] ← Rd[31:16] ∧ imm16 | 1 |
| E | Rd, imm, COH | Logical AND High Halfword, clear other halfword. | Rd[31:16] ← Rd[31:16] ∧ imm16Rd[15:0] ← 0 | 1 | |
| andl | E | Rd, imm | Logical AND Low Halfword, high halfword is unchanged. | Rd[15:0] ← Rd[15:0] ∧ imm16 | 1 |
| E | Rd, imm, COH | Logical AND Low Halfword, clear other halfword. | Rd[15:0] ← Rd[15:0] ∧ imm16Rd[31:16] ← 0 | 1 | |
| com | C | Rd | One’s Complement (NOT). | Rd ← ¬Rd | 1 |
| eor | C | Rd, Rs | Logical Exclusive OR. | Rd ← Rd ⊕ Rs | 1 |
| E | Rd, Rx, Ry << sa | Rd ← Rd ⊕ (Rs << sa5) | 1 | ||
| E | Rd, Rx, Ry >> sa | Rd ← Rd ⊕ (Rs >> sa5) | 1 | ||
| eor{cond4} | E | Rd, Rx, Ry | Logical EOR if condition satisfied. | if (cond4) Rd ← Rx ⊕ Ry | 2 |
| eorh | E | Rd, imm | Logical Exclusive OR (High Halfword). | Rd[31:16] ← Rd[31:16] ⊕ imm16 | 1 |
| eorl | E | Rd, imm | Logical Exclusive OR (Low Halfword). | Rd[15:0] ← Rd[15:0] ⊕ imm16 | 1 |
| or | C | Rd, Rs | Logical (Inclusive) OR. | Rd ← Rd ∨ Rs | 1 |
| E | Rd, Rx, Ry << sa | Rd ← Rd ∨ (Rs << sa5) | 1 | ||
| E | Rd, Rx, Ry >> sa | Rd ← Rd ∨ (Rs >> sa5) | 1 | ||
| or{cond4} | E | Rd, Rx, Ry | Logical OR if condition satisfied. | if (cond4) Rd ← Rx ∨ Ry | 2 |
| orh | E | Rd, imm | Logical OR (High Halfword). | Rd[31:16] ← Rd[31:16] ∨ imm16 | 1 |
| orl | E | Rd, imm | Logical OR (Low Halfword). | Rd[15:0] ← Rd[15:0] ∨ imm16 | 1 |
| tst | C | Rd, Rs | Test register for zero. | Rd ∧ Rs | 1 |
9.3.6 Bit Operations
Table 9-6. Bit Operations
\begin{tabular}{|l|l|l|l|l|l|} \hline Mnemonics & & Operands / Syntax & Description & Operation & Rev \ \hline bfexts & E & Rd, Rs, o5, w5 & Extract and sign-extend the w5 bits in Rs starting at bit-offset o5 to Rd. & See Instruction Set Reference & 1 \ \hline bfextu & E & Rd, Rs, o5, w5 & Extract and zero-extend the w5 bits in Rs starting at bit-offset o5 to Rd. & See Instruction Set Reference & 1 \ \hline bfins & E & Rd, Rs, o5, w5 & Insert the lower w5 bits of Rs in Rd at bit-offset o5. & See Instruction Set Reference & 1 \ \hline bld & E & Rd, bp & Bit load. & C \leftarrow Rd[bp5] Z \leftarrow Rd[bp5] & 1 \ \hline brev & C & Rd & Bit reverse. & Rd[0:31] \leftarrow Rd[31:0] & 1 \ \hline bst & E & Rd, bp & Bit store. & Rd[bp5] \leftarrow C & 1 \ \hline casts.b & C & Rd & Typecast byte to signed word. & Rd \leftarrow SE(Rd[7:0]) & 1 \ \hline casts.h & C & Rd & Typecast halfword to signed word. & Rd \leftarrow SE(Rd[15:0]) & 1 \ \hline castu.b & C & Rd & Typecast byte to unsigned word. & Rd \leftarrow ZE(Rd[7:0]) & 1 \ \hline castu.h & C & Rd & Typecast halfword to unsigned word. & Rd \leftarrow ZE(Rd[15:0]) & 1 \ \hline cbr & C & Rd, bp & Clear bit in register. & Rd[bp5] \leftarrow 0 & 1 \ \hline clz & E & Rd, Rs & Count leading zeros. & See Instruction Set Reference & 1 \ \hline sbr & C & Rd, bp & Set bit in register. & Rd[bp5] \leftarrow 1 & 1 \ \hline swap.b & C & Rd & Swap bytes in register. & Rd[31:24] \leftarrow Rd[7:0], Rd[23:16] \leftarrow Rd[15:8], Rd[15:8] \leftarrow Rd[23:16], Rd[7:0] \leftarrow Rd[31:24] & 1 \ \hline swap.bh & C & Rd & Swap bytes in each halfword. & Rd[31:24] \leftarrow Rd[23:16], Rd[23:16] \leftarrow Rd[31:24], Rd[15:8] \leftarrow Rd[7:0], Rd[7:0] \leftarrow Rd[15:8] & 1 \ \hline swap.h & C & Rd & Swap halfwords in register. & Rd[31:16] \leftarrow Rd[15:0], Rd[15:0] \leftarrow Rd[31:16] & 1 \ \hline \end{tabular}
32000D-04/2011 ATMEL 111
9.3.7 Shift Operations
Table 9-7. Operations
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| asr | E | Rd, Rx, Ry | Arithmetic shift right (signed). | See Instruction Set Reference | 1 |
| E | Rd, Rs, sa | 1 | |||
| C | Rd, sa | 1 | |||
| lsl | E | Rd, Rx, Ry | Logical shift left. | See Instruction Set Reference | 1 |
| E | Rd, Rs, sa | 1 | |||
| C | Rd, sa | 1 | |||
| lsr | E | Rd, Rx, Ry | Logical shift right. | See Instruction Set Reference | 1 |
| E | Rd, Rs, sa | 1 | |||
| C | Rd, sa | 1 | |||
| rol | C | Rd | Rotate left through carry. | See Instruction Set Reference | 1 |
| ror | C | Rd | Rotate right through carry. | See Instruction Set Reference | 1 |
9.3.8 Instruction Flow
Table 9-8. Instruction Flow
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| br{cond3} | C | disp | Branch if condition satisfied. | if (cond3)PC ← PC + (SE(disp8)<<1) | 1 |
| br{cond4} | E | disp | if (cond4)PC ← PC + (SE(disp21)<<1) | 1 | |
| rjmp | C | disp | Relative jump. | PC ← PC + (SE(disp10)<<1) | 1 |
| acall | C | disp | Application call | LR ← PC + 2PC ← *(ACBA + (ZE(disp8)<<2)) | 1 |
| icall | C | Rd | Register indirect call. | LR ← PC + 2PC ← Rd | 1 |
| mcall | E | Rp[disp] | Memory call. | LR ← PC + 4PC ← *((Rp && 0xFFFF_FFFC) + (SE(disp16)<<2)) | 1 |
| rcall | C | disp | Relative call. | LR ← PC + 2PC ← PC + (SE(disp10)<<1) | 1 |
| E | disp | LR ← PC + 4PC ← PC + (SE(disp21)<<1) | 1 | ||
| scall | C | Supervisor call | See Instruction Set Reference. | 1 | |
| sscall | C | Secure State call | See Instruction Set Reference. | 1 | |
| ret{cond4} | C | Rs | Conditional return from subroutine with move and test of return value. | if (Rs != {SP, PC})R12 ← RsPC ← LR | 1 |
| Conditional return from subroutine with return of false value. | if (Rs = LR)R12 ← -1PC ← LR | 1 | |||
| Conditional return from subroutine with return of false value. | if (Rs = SP)R12 ← 0PC ← LR | 1 | |||
| Conditional return from subroutine with return of true value. | if (Rs = PC)R12 ← 1PC ← LR | 1 | |||
| retd | C | Return from debug mode | SR ← RSR_DBGPC ← LR_DBG | 1 | |
| rete | C | Return from event handler | See Instruction Set Reference. | 1 | |
| rets | C | Return from supervisor call | See Instruction Set Reference. | 1 | |
| retss | C | Return from secure state | See Instruction Set Reference. | 1 |
32000D–04/2011
113
9.3.9 Data Transfer
9.3.9.1 Move/Load Immediate operations
Table 9-9. Move/Load Immediate Operations
| Mnemonics | C/E | Operands / Syntax | Description | Operation | Rev |
|---|---|---|---|---|---|
| mov | C | Rd, imm | Load immediate into register. | Rd ← SE(imm8) | 1 |
| E | Rd, imm | Rd ← SE(imm21) | 1 | ||
| C | Rd, Rs | Copy register. | Rd ← Rs | 1 | |
| mov{cond4} | E | Rd, Rs | Copy register if condition is true | if (cond4) Rd ← Rs | 1 |
| E | Rd, imm | Load immediate into register if condition is true | if (cond4) Rd ← SE(imm8) | 1 | |
| movh | E | Rd, imm | Load immediate into high halfword of register. | Rd ← imm16<<16 | 2 |
9.3.9.2 Load/Store operations
Table 9-10. Load/Store Operations
| Mnemonics | C/E | Operands / Syntax | Description | Operation | Rev |
|---|---|---|---|---|---|
| ld.ub | C | Rd, Rp++ | Load unsigned byte with post-increment. | Rd ← ZE(*(Rp++)) | 1 |
| C | Rd, --Rp | Load unsigned byte with pre-decrement. | Rd ← ZE(*(--Rp)) | 1 | |
| C | Rd, Rp[disp] | Load unsigned byte with displacement. | Rd ← ZE(*(Rp+ZE(disp3))) | 1 | |
| E | Rd, Rp[disp] | Rd ← ZE(*(Rp+SE(disp16))) | 1 | ||
| E | Rd, Rb[Ri<<sa] | Indexed Load unsigned byte. | Rd ← ZE(*(Rb+(Ri << sa2))) | 1 | |
| ld.ub{cond4} | E | Rd, Rp[disp] | Load unsigned byte with displacement if condition satisfied. | if {cond4} Rd ← ZE(*(Rp+ZE(disp9))) | 2 |
| ld.sb | E | Rd, Rp[disp] | Load signed byte with displacement. | Rd ← SE(*(Rp+SE(disp16))) | 1 |
| E | Rd, Rb[Ri<<sa] | Indexed Load signed byte. | Rd ← SE(*(Rb+(Ri << sa2))) | 1 | |
| ld.sb{cond4} | E | Rd, Rp[disp] | Load signed byte with displacement if condition satisfied. | if {cond4} Rd ← SE(*(Rp+ZE(disp9))) | 2 |
| ld.uh | C | Rd, Rp++ | Load unsigned halfword with post-increment. | Rd ← ZE(*(Rp++)) | 1 |
| C | Rd, --Rp | Load unsigned halfword with pre-decrement. | Rd ← ZE(*(--Rp)) | 1 | |
| C | Rd, Rp[disp] | Load unsigned halfword with displacement. | Rd ← ZE(*(Rp+(ZE(disp3)<<1))) | 1 | |
| E | Rd, Rp[disp] | Rd ← ZE(*(Rp+(SE(disp16)))) | 1 | ||
| E | Rd, Rb[Ri<<sa] | Indexed Load unsigned halfword. | Rd ← ZE(*(Rb+(Ri << sa2))) | 1 | |
| ld.uh{cond4} | E | Rd, Rp[disp] | Load unsigned halfword with displacement if condition satisfied. | if {cond4} Rd ← ZE(*(Rp+ZE(disp9<<1))) | 2 |
AVR32
Table 9-10. Load/Store Operations (Continued)
| Instruction | Type | Operands | Description | Operation | Cycles |
|---|---|---|---|---|---|
| ld.sh | C | Rd, Rp++ | Load signed halfword with post-increment. | Rd ← SE(* (Rp++)) | 1 |
| C | Rd, --Rp | Load signed halfword with pre-decrement. | Rd ← SE(* (--Rp)) | 1 | |
| C | Rd, Rp[disp] | Load signed halfword with displacement. | Rd ← SE(* (Rp+(ZE(disp3)<<1))) | 1 | |
| E | Rd, Rp[disp] | Rd ← SE(* (Rp+(SE(disp16)))) | 1 | ||
| E | Rd, Rb[Ri<<sa] | Indexed Load signed halfword. | Rd ← SE(* (Rb+(Ri << sa2))) | 1 | |
| ld.sh{cond4} | E | Rd, Rp[disp] | Load signed halfword with displacement if condition satisfied. | if {cond4} Rd ← SE(* (Rp+ZE(disp9<<1))) | 2 |
| ld.w | C | Rd, Rp++ | Load word with post-increment. | Rd ← * (Rp++) | 1 |
| C | Rd, --Rp | Load word with pre-decrement. | Rd ← * (--Rp) | 1 | |
| C | Rd, Rp[disp] | Load word with displacement. | Rd ← * (Rp+(ZE(disp5)<<2)) | 1 | |
| E | Rd, Rp[disp] | Rd ← * (Rp+(SE(disp16))) | 1 | ||
| E | Rd, Rb[Ri<<sa] | Indexed Load word. | Rd ← * (Rb+(Ri << sa2)) | 1 | |
| E | Rd, Rb[Ri: << 2] | Load word with extracted index into Rd. | Rd ← * (Rb+(Ri: << 2)) | 1 | |
| ld.w{cond4} | E | Rd, Rp[disp] | Load word with displacement if condition satisfied. | if {cond4} Rd ← * (Rp+ZE(disp9<<2)) | 2 |
| ld.d | C | Rd, Rp++ | Load doubleword with post-increment. | Rd+1:Rd ← (* (Rp++)) | 1 |
| C | Rd, --Rp | Load doubleword with pre-decrement. | Rd+1:Rd ← (* (--Rp)) | 1 | |
| C | Rd, Rp | Load doubleword. | Rd+1:Rd ← * (Rp) | 1 | |
| E | Rd, Rp[disp] | Load double with displacement. | Rd+1:Rd ← * (Rp+SE(disp16)) | 1 | |
| E | Rd, Rb[Ri<<sa] | Indexed Load double. | Rd+1:Rd ← * (Rb+(Ri << sa2)) | 1 | |
| ldins.b | E | Rd:, Rp[disp] | Load byte with displacement and insert at specified byte location in Rd. | Rd: ← * (Rp+(SE(disp12))) | 1 |
| ldins.h | E | Rd:, Rp[disp] | Load halfword with displacement and insert at specified halfword location in Rd. | Rd: ← * (Rp+(SE(disp12)<<1)) | 1 |
| ldswp.sh | E | Rd, Rp[disp] | Load halfword with displacement, swap bytes and sign-extend | Temp ← * (Rp+(SE(disp12) << 1) Rd ← SE(Temp[7:0], Temp[15:8]) | 1 |
| ldswp.uh | E | Load halfword with displacement, swap bytes and zero-extend | Temp ← * (Rp+(SE(disp12) << 1) Rd ← ZE(Temp[7:0], Temp[15:8]) | 1 | |
| ldswp.w | E | Load word with displacement and swap bytes. | Temp ← * (Rp+(SE(disp12) << 2) Rd[31:24] ← Temp[7:0], Rd[23:16] ← Temp[15:8], Rd[15:8] ← Temp[23:16], Rd[7:0] ← Temp[31:24] | 1 | |
| lddpc | C | Rd, PC[disp] | Load with displacement from PC. | Rd ← * ((PC && 0xFFFF_FFFC) +(ZE(disp7)<<2)) | 1 |
| lddsp | C | Rd, SP[disp] | Load with displacement from SP. | Rd ← * ((SP && 0xFFFF_FFFC) +(ZE(disp7)<<2)) | 1 |
32000D–04/2011
Table 9-10. Load/Store Operations (Continued)
| Instruction | Mode | Operands | Description | Operation | Cycles |
|---|---|---|---|---|---|
| st.b | C | Rp++, Rs | Store with post-increment. | *(Rp++) ← Rs[7:0] |
1 |
| C | --Rp, Rs | Store with pre-decrement. | *(--Rp) ← Rs[7:0] |
1 | |
| C | Rp[disp], Rs | Store byte with displacement. | *(Rp+ZE(disp3)) ← Rs[7:0] |
1 | |
| E | Rp[disp], Rs | *(Rp+SE(disp16)) ← Rs[7:0] |
1 | ||
| E | Rb[Ri<<sa], Rs | Indexed Store byte. | *(Rb+(Ri << sa2)) ← Rs[7:0] |
1 | |
| st.b{cond4} | E | Rp[disp], Rs | Store byte with displacement if condition satisfied. | if {cond4}*(Rp+SE(disp9)) ← Rs[7:0] |
2 |
| st.d | C | Rp++, Rs | Store with post-increment. | *(Rp++) ← (Rs+1:Rs) |
1 |
| C | --Rp, Rs | Store with pre-decrement. | *(--Rp) ← (Rs+1:Rs) |
1 | |
| C | Rp, Rs | Store doubleword | *(Rp) ← (Rs+1:Rs) |
1 | |
| E | Rp[disp], Rs | Store double with displacement | *(Rp+SE(disp16)) ← (Rs+1:Rs) |
1 | |
| E | Rb[Ri<<sa], Rs | Indexed Store double. | *(Rb+(Ri << sa2)) ← (Rs+1:Rs) |
1 | |
| st.h | C | Rp++, Rs | Store with post-increment. | *(Rp++) ← Rs[15:0] |
1 |
| C | --Rp, Rs | Store with pre-decrement. | *(--Rp) ← Rs[15:0] |
1 | |
| C | Rp[disp], Rs | Store halfword with displacement. | *(Rp+(ZE(disp3)<<1)) ← Rs[15:0] |
1 | |
| E | Rp[disp], Rs | *(Rp+(SE(disp16))) ← Rs[15:0] |
1 | ||
| E | Rb[Ri<<sa], Rs | Indexed Store halfword. | *(Rb+(Ri << sa2)) ← Rs[15:0] |
1 | |
| st.h{cond4} | E | Rp[disp], Rs | Store halfword with displacement if condition satisfied. | if {cond4}*(Rp+SE(disp9<<1)) ← Rs[15:0] |
2 |
| st.w | C | Rp++, Rs | Store with post-increment. | *(Rp++) ← Rs |
1 |
| C | --Rp, Rs | Store with pre-decrement. | *(--Rp) ← Rs |
1 | |
| C | Rp[disp], Rs | Store word with displacement. | *(Rp+(ZE(disp4)<<2)) ← Rs |
1 | |
| E | Rp[disp], Rs | *(Rp+(SE(disp16))) ← Rs |
1 | ||
| E | Rb[Ri<<sa], Rs | Indexed Store word. | *(Rb+(Ri << sa2)) ← Rs |
1 | |
| st.w{cond4} | E | Rp[disp], Rs | Store word with displacement if condition satisfied. | if {cond4}*(Rp+ZE(disp9<<2)) ← Rs |
2 |
| stcond | C | Rp[disp], Rs | Conditional store with displacement. | SREG[Z] ← SREG[L]if (SREG[L])*(Rp+(SE(disp16))) ← Rs |
1 |
| stdsp | C | SP[disp], Rs | Store with displacement from SP. | *( (SP && 0xFFFF_FFFC)+(ZE(disp7)<<2)) ← Rs |
1 |
| sthh.w | E | Rp[disp], Rx:, Ry: | Combine halfwords to word and store with displacement. | *(Rp+(ZE(disp8)<<2)) ← {Rx:<part>, Ry:<part>} |
1 |
| E | Rb[Ri<<sa], Rx:, Ry: | Combine halfwords to word and store indexed. | *(Rb+(Ri << sa2)) ← {Rx:<part>, Ry:<part>} |
1 |
Table 9-10. Load/Store Operations (Continued)
| stswp.h | E | Rp[disp], Rs | Swap bytes and store halfword with displacement. | Temp ← Rs[7:0], Rs[15:8] *(Rp+(SE(disp12) << 1) ← Temp | 1 |
|---|---|---|---|---|---|
| stswp.w | E | Swap bytes and store word with displacement. | Temp[31:24] ← Rs[7:0], Temp[23:16] ← Rs[15:8], Temp[15:8] ← Rs[23:16], Temp[7:0] ← Rs[31:24] *(Rp+(SE(disp12) << 2) ← Temp | 1 | |
| xchg | E | Rd, Rx, Ry | Exchange register and memory | See Instruction Set Reference | 1 |
9.3.9.3 Multiple data
Table 9-11. Mutiple data
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| ldm | E | Rp{++}, Reglist16 {, R12={-1,0,1}} | Load multiple registers. R12 is tested if PC is loaded. | See Instruction Set Reference | 1 |
| ldmts | E | Rp{++}, Reglist16 | Load multiple registers in application context for task switch. | See Instruction Set Reference | 1 |
| popm | C | Reglist8 {, R12={-1,0,1}} | Pop multiple registers from stack. R12 is tested if PC is popped. | See Instruction Set Reference | 1 |
| pushm | C | Reglist8 | Push multiple registers to stack. | See Instruction Set Reference | 1 |
| stm | E | {--}Rp, Reglist16 | Store multiple registers. | See Instruction Set Reference | 1 |
| stmts | E | {--}Rp, Reglist16 | Store multiple registers in application context for task switch. | See Instruction Set Reference | 1 |
9.3.10 System/Control
Table 9-12. System/Control
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| breakpoint | C | Breakpoint. | See Instruction Set Reference | 1 | |
| cache | E | Rp[disp], Op | Perform cache operation | See Instruction Set Reference | 1 |
| csrf | C | bp | Clear status register flag. | SR[bp5] ← 0 | 1 |
| csrfcz | C | bp | Copy status register flag to C and Z. | C ← SR[bp5] Z ← SR[bp5] | 1 |
| frs | C | frs | Invalidates the return address stack | See Instruction Set Reference | 1 |
| mfdr | E | Rd, DebugRegAddress | Move debug register to Rd. | Rd ← DebugRegister[DebugRegAddr] | 1 |
| mfsr | E | Rd, SysRegNo | Move system register to Rd. | Rd ← SystemRegister[SysRegNo] | 1 |
| mtdr | E | DebugRegAddress, Rs | Move Rs to debug register. | DebugRegister[DebugRegAddr] ← Rs | 1 |
| mtsr | E | SysRegNo, Rs | Move Rs to system register. | SystemRegister[SysRegNo] ← Rs | 1 |
| musfr | C | Rs | Move Rs to status register | SR[3:0] ← Rs[3:0] | 1 |
| mustr | C | Rd | Move status register to Rd | Rd ← ZE(SR[3:0]) | 1 |
32000D–04/2011
117
Table 9-12. System/Control (Continued)
| nop | C | No operation | See Instruction Set Reference | 1 | |
|---|---|---|---|---|---|
| pref | E | Rp[disp] | Prefetch cache line | See Instruction Set Reference | 1 |
| sleep | E | Op8 | Enter SLEEP mode. | See Instruction Set Reference | 1 |
| sr{cond4} | C | Rd | Conditionally set register to true or false. | if (cond4)Rd ← 1;elseRd ← 0; | 1 |
| ssrf | C | bp | Set status register flag. | SR[bp5] ← 1 | 1 |
| sync | E | Op8 | Flush write buffer | See Instruction Set Reference | 1 |
| tlbr | C | Read TLB entry | See Instruction Set Reference | 1 | |
| tlbs | C | Search TLB for entry | See Instruction Set Reference | 1 | |
| tlbw | C | Write TLB entry | See Instruction Set Reference | 1 |
118 AVR32 32000D–04/2011
9.3.11 Coprocessor interface
Table 9-13. Coprocessor Interface
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| cop | E | CP#, CRd, CRx, CRy, Op | Coprocessor operation. | CRd ← CRx Op CRy | 1 |
| ldc.d | E | CP#, CRd, Rp[disp] | Load coprocessor register | CRd+1:CRd ← *(Rp+ZE(disp8<<2)) | 1 |
| E | CP#, CRd, --Rp | Load coprocessor register with pre-decrement | CRd+1:CRd ← *(--Rp) | 1 | |
| E | CP#, CRd, Rb[Ri<<sa] | Load coprocessor register with indexed addressing | CRd+1:CRd ← *(Rb+(Ri << sa2)) | 1 | |
| ldc0.d | E | CRd, Rp[disp] | Load coprocessor 0 register | CRd+1:CRd ← *(Rp+ZE(disp12<<2)) | 1 |
| ldc.w | E | CP#, CRd, Rp[disp] | Load coprocessor register | CRd ← *(Rp+ZE(disp8<<2)) | 1 |
| E | CP#, CRd, --Rp | Load coprocessor register with pre-decrement | CRd ← *(--Rp) | 1 | |
| E | CP#, CRd, Rb[Ri<<sa] | Load coprocessor register with indexed addressing | CRd ← *(Rb+(Ri << sa2)) | 1 | |
| ldc0.w | E | CRd, Rp[disp] | Load coprocessor 0 register | CRd ← *(Rp+ZE(disp12<<2)) | 1 |
| ldcM.d | E | CP#, Rp{++}, ReglistCPD8 | Load multiple coprocessor double registers | See instruction set reference | 1 |
| ldcM.w | E | CP#, Rp{++}, ReglistCPH8 | Load multiple coprocessor high registers | See instruction set reference | 1 |
| ldcM.w | E | CP#, Rp{++}, ReglistCPL8 | Load multiple coprocessor low registers | See instruction set reference | 1 |
| mvcr.d | E | CP#, Rd, CRs | Move from coprocessor to register | Rd+1:Rd ← CRs+1:CRs | 1 |
| mvcr.w | E | CP#, Rd, CRs | Move from coprocessor to register | Rd ← CRs | 1 |
| mvrc.d | E | CP#, CRd, Rs | Move from register to coprocessor | CRd+1:CRd ← Rs+1:Rs | 1 |
| mvrc.w | E | CP#, CRd, Rs | Move from register to coprocessor | CRd ← Rs | 1 |
| stc.d | E | CP#, Rp[disp], CRs | Store coprocessor register | *(Rp+ZE(disp8<<2)) ← CRs+1:CRs | 1 |
| E | CP#, Rp++, CRs | Store coprocessor register with post-increment | *(Rp--) ← CRs+1:CRs | 1 | |
| E | CP#, Rb[Ri<<sa], CRs | Store coprocessor register with indexed addressing | *(Rb+(Ri << sa2)) ← CRs+1:CRs | 1 | |
| stc0.d | E | Rp[disp], CRs | Store coprocessor 0 register | *(Rp+ZE(disp12<<2)) ← CRs+1:CRs | 1 |
| stc.w | E | CP#, Rp[disp], CRs | Store coprocessor register | *(Rp+ZE(disp8<<2)) ← CRs | 1 |
| E | CP#, Rp++, CRs | Store coprocessor register with post-increment | *(Rp++) ← CRs | 1 | |
| E | CP#, Rb[Ri<<sa], CRs | Store coprocessor register with indexed addressing | *(Rb+(Ri << sa2)) ← CRs | 1 | |
| stc0.d | E | Rp[disp], CRs | Store coprocessor 0 register | *(Rp+ZE(disp12<<2)) ← CRs | 1 |
32000D–04/2011
119
Table 9-13. Coprocessor Interface (Continued)
| stcm.d | E | CP#, {--}Rp, ReglistCPD8 | Store multiple coprocessor double registers | See instruction set reference | 1 |
|---|---|---|---|---|---|
| stcm.w | E | CP#, {--}Rp, ReglistCPH8 | Store multiple coprocessor high registers | See instruction set reference | 1 |
| stcm.w | E | CP#, {--}Rp, ReglistCPL8 | Store multiple coprocessor low registers | See instruction set reference | 1 |
9.3.12 Instructions to aid Java execution
Table 9-14. Instructions to aid Java (Card) execution
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| incjosp | C | imm | Increment Java stack pointer | JOSP + {-4, -3, -2, -1, 1, 2, 3, 4} | 1 |
| popjc | C | Pop Java context from Frame | See instruction set reference | 1 | |
| pushjc | C | Push Java context to Frame | See instruction set reference | 1 | |
| retj | C | Return from Java Trap | See instruction set reference | 1 |
9.3.13 SIMD Operations
Table 9-15. SIMD Operations
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| pabs.{sb/sh} | E | Rd, Rs | Packed Absolute Value | See instruction set reference | 1 |
| packsh.{ub/sb} | E | Rd, Rx, Ry | Pack Halfwords to Bytes | See instruction set reference | 1 |
| packw.sh | E | Rd, Rx, Ry | Pack Words to Halfwords | See instruction set reference | 1 |
| padd.{b/h} | E | Rd, Rx, Ry | Packed Addition | See instruction set reference | 1 |
| paddh.{ub/sh} | E | Rd, Rx, Ry | Packed Addition with halving | See instruction set reference | 1 |
| padds.{ub/sb/uh/sh} | E | Rd, Rx, Ry | Packed Addition with Saturation | See instruction set reference | 1 |
| paddsub.h | E | Rd, Rx:, Ry: | Packed Halfword Addition and Subtraction | See instruction set reference | 1 |
| paddsubh.sh | E | Rd, Rx:, Ry: | Packed Halfword Addition and Subtraction with halving | See instruction set reference | 1 |
| paddsubs.{uh/sh} | E | Rd, Rx:, Ry: | Packed Halfword Addition and Subtraction with Saturation | See instruction set reference | 1 |
| paddx.h | E | Rd, Rx, Ry | Packed Halfword Addition with Crossed Operand | See instruction set reference | 1 |
| paddxh.sh | E | Rd, Rx, Ry | Packed Halfword Addition with Crossed Operand and Halving | See instruction set reference | 1 |
| paddxs.{uh/sh} | E | Rd, Rx, Ry | Packed Halfword Addition with Crossed Operand and Saturation | See instruction set reference | 1 |
| pasr.{b/h} | E | Rd, Rs, {sa} | Packed Arithmetic Shift Left | See instruction set reference | 1 |
| pavg.{ub/sh} | E | Rd, Rx, Ry | Packed Average | See instruction set reference | 1 |
| plsl.{b/h} | E | Rd, Rs, {sa} | Packed Logic Shift Left | See instruction set reference | 1 |
Table 9-15. SIMD Operations (Continued)
| pIsr.{b/h} | E | Rd, Rs, {sa} | Packed Logic Shift Right | See instruction set reference | 1 |
|---|---|---|---|---|---|
| pmax.{ub/sh} | E | Rd, Rx, Ry | Packed Maximum Value | See instruction set reference | 1 |
| pmin.{ub/sh} | E | Rd, Rx, Ry | Packed Minimum Value | See instruction set reference | 1 |
| psad | E | Rd, Rx, Ry | Sum of Absolute Differences | See instruction set reference | 1 |
| psub.{b/h} | E | Rd, Rx, Ry | Packed Subtraction | See instruction set reference | 1 |
| psubadd.h | E | Rd, Rx:, Ry: | Packed Halfword Subtraction and Addition | See instruction set reference | 1 |
| psubaddh.sh | E | Rd, Rx:, Ry: | Packed Halfword Subtraction and Addition with halving | See instruction set reference | 1 |
| psubadds.{uh/sh} | E | Rd, Rx:, Ry: | Packed Halfword Subtraction and Addition with Saturation | See instruction set reference | 1 |
| psubh.{ub/sh} | E | Rd, Rx, Ry | Packed Subtraction with halving | See instruction set reference | 1 |
| psubs.{ub/sb/uh/sh} | E | Rd, Rx, Ry | Packed Subtraction with Saturation | See instruction set reference | 1 |
| psubx.h | E | Rd, Rx, Ry | Packed Halfword Subtraction with Crossed Operand | See instruction set reference | 1 |
| psubxh.sh | E | Rd, Rx, Ry | Packed Halfword Subtraction with Crossed Operand and Halving | See instruction set reference | 1 |
| psubxs.{uh/sh} | E | Rd, Rx, Ry | Packed Halfword Subtraction with Crossed Operand and Saturation | See instruction set reference | 1 |
| punpck{ub/sb}.h | E | Rd, Rs: | Unpack Bytes to Halfwords | See instruction set reference | 1 |
9.3.14 Memory read-modify-write instructions
Table 9-16. Memory read-modify-write Instructions
| Mnemonics | Operands / Syntax | Description | Operation | Rev | |
|---|---|---|---|---|---|
| memc | E | imm, bp | Clear bit in memory | Memory[(imm15<<2)[bp5]] = 0 | 1 |
| mems | E | imm, bp | Set bit in memory | Memory[(imm15<<2)[bp5]] = 1 | 1 |
| memt | E | imm, bp | Toggle bit in memory | Memory[(imm15<<2)[bp5]] = ¬Memory[(imm15<<2)[bp5]] | 1 |
32000D–04/2011 ATMEL® 121