Atmel AVR Instruction Set - Processor Registers

Processor Registers

There are 32 general-purpose 8-bit registers, R0–R31. All arithmetic operations operate on registers; only load and store instructions access RAM.

The general-purpose registers are mapped to the first 32 bytes of RAM. The next 64-bytes of RAM are used for a number of special-purpose registers. This I/O space has special addressing capabilities, so addresses within it are often written as "0x00 (0x20)" through "0x3F (0x5F)" to show the both the 6-bit I/O space address and the general RAM address.

Additional I/O registers may be located beginning at address 96, and general-purpose RAM begins after that.

A limited number of instructions operate on register pairs. The higher-numbered register of the pair is the most significant.

The last 6 registers are used as register pairs for memory addressing. When paired, they are known as X (R27:R26), Y (R29:R28) and Z (R31:R30). Postincrement and predecrement addressing modes are supported on all 3. Y and Z also support a 6-bit displacement.

Some instructions, generally those which allow an 8-bit immediate value, are limited to registers R16–R31. A few (late additions to the instruction set) are limited to 8 registers, R16–R23.

Additional special-purpose registers are:

  • 16- or 22-bit program counter
  • 8-bit status register (I/O register 0x3F (0x5F))
  • 16-bit stack pointer (I/O registers 0x3E:0x3D (0x5E:0x5D))
  • 8-bit EIND register (I/O register 0x3C (0x5C)), high bits of Z register for indirect branches
  • 8-bit RAMPZ register (I/O register 0x3B (0x5B)), high bits of Z register for LPM instructions

Except for the program counter, the processor special-purpose registers are also mapped to RAM, in the I/O space.

The status register bits are:

  1. C Carry flag. This is a borrow flag on subtracts.
  2. Z Zero flag. Set to 1 when an arithmetic result is zero.
  3. N Negative flag. Set to a copy of the most significant bit of an arithmetic result.
  4. V Overflow flag. Set in case of two's complement overflow.
  5. S Sign flag. Unique to AVR, this is always N⊕V, and shows the true sign of a comparison.
  6. H Half carry. This is an internal carry from additions, and is used to support BCD arithmetic.
  7. T Bit copy. Special bit load and bit store instructions use this bit.
  8. I Interrupt flag. Set when interrupts are enabled.

Read more about this topic:  Atmel AVR Instruction Set

Famous quotes containing the word registers:

    We may prepare food for our children, chauffeur them around, take them to the movies, buy them toys and ice cream, but nothing registers as deeply as a simple squeeze, cuddle, or pat on the back. There is no greater reassurance of their lovability and worth than to be affectionately touched and held.
    Stephanie Martson (20th century)