This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:piot:chapter_4_3 [2026/01/10 20:37] – pczekalski | en:multiasm:piot:chapter_4_3 [2026/03/01 17:43] (current) – ktokarz | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Registers ====== | ====== Registers ====== | ||
| - | Registers are a key element of AVR microcontrollers. There are various types of registers, including general-purpose, | + | Registers are a key element of AVR microcontrollers. There are various types of registers, including general-purpose, |
| - | AVR CPU General | + | ==== General-purpose registers ==== |
| + | |||
| + | In the AVR architecture, there are 32 general-purpose registers belonging to two groups: | ||
| **R0-R15: | **R0-R15: | ||
| Line 9: | Line 11: | ||
| **R16-R31: | **R16-R31: | ||
| - | General-purpose registers that can be used with immediate | + | General-purpose registers that can be used with immediate |
| + | |||
| + | Table {{ref> | ||
| + | |||
| + | <table avr_register_comparison> | ||
| + | < | ||
| + | |||
| + | |||
| + | ^ Feature | ||
| + | | Instruction compatibility | ||
| + | | Opcode encoding | ||
| + | | Typical compiler usage | Less preferred; used for temporary or special roles | ||
| + | | Special-purpose roles | ||
| + | | Pointer support | ||
| + | | Efficiency | ||
| + | | Multiplication involvement | ||
| + | | Suitability in ASM | Limited; avoid with immediates; R0/R1 have special rules | Recommended for general ALU operations | ||
| + | | GCC policy | ||
| + | </ | ||
| <figure avr_registers> | <figure avr_registers> | ||
| - | {{:en: | + | {{ en: |
| < | < | ||
| </ | </ | ||
| Line 21: | Line 41: | ||
| R26-R31: These registers serve as 16-bit address pointers for indirect addressing of the data space. They are defined as X, Y, and Z registers. | R26-R31: These registers serve as 16-bit address pointers for indirect addressing of the data space. They are defined as X, Y, and Z registers. | ||
| + | <figure extended_registers> | ||
| + | {{ en: | ||
| + | < | ||
| + | </ | ||
| + | ==== Other registers ==== | ||
| + | |||
| + | **RAMPX, RAMPY, RAMPZ:** Registers concatenated with the X-, Y-, and Z-registers, | ||
| + | |||
| + | **RAMPD:** Register concatenated with the Z-register, enabling direct addressing of the whole data space on MCUs with more than 64 KB data space. | ||
| + | |||
| + | **EIND:** Register concatenated with the Z-register, enabling indirect jump and call to the entire program space on MCUs with more than 64K words (128 KB) of program space. | ||
| - | **Other registers: | + | <table Register properties> |
| + | < | ||
| + | ^ Register | ||
| + | | RAMPX | ||
| + | | RAMPY | ||
| + | | RAMPZ | ||
| + | | RAMPD | ||
| + | | EIND | Extends program addressing | ||
| + | </ | ||
| - | RAMPX, RAMPY, RAMPZ: Registers concatenated with the X-, Y-, and Z-registers, | + | All of the registers |
| - | RAMPD: Register concatenated with the Z-register, enabling direct addressing of the whole data space on MCUs with more than 64 KB data space. | ||
| - | EIND: Register concatenated with the Z-register, enabling indirect jump and call to the entire program space on MCUs with more than 64K words (128 KB) of program space. | ||