AVR Instructions

The AVR architecture has about 130 instructions.

Most are only provided for efficiency: to allow faster and/or smaller programs. Many are simple variants of other instructionss.

We'll cover only ~20 instructions in COMP1721. These are sufficent to write any program.

Each AVR instruction is represented by a unique bit pattern - its opcode.

Almost all AVR instructions are encoded as 16-bit opcodes, a few require 32-bits.

For example the instruction add R23, R11 would be encoded as the 16-bit opcode 0x0d7b. This bit pattern:

0000110101111011
iiiiiirdddddrrrr

There are three components.

The 5 red bits 00011 distinguish this as an add instruction.

The 5 blue bits 10111 indicates register 23 is the first operand register.

The 5 green bits 10111 indicates register 11 is the second operand register.

All add Rd, Rr instructions follow this pattern.

Index