
10
ATmega8515(L)
2512A–AVR–04/02
The X-register, Y-register, and
Z-register
The registers R26..R31 have some addedfunctions to their generalpurposeusage.
These registers are16-bit address pointers for indirectaddressing of the Data Space.
Thethree indirectaddress registers X, Y, andZare defined asdescribed in Figure5.
Figure 5. The X-, Y-, andZ-registers
Inthe different addressing modes theseaddress registers have functions asfixeddis-
placement, automatic increment, and automaticdecrement (see the Instruction Set
reference fordetails).
Stack Pointer The Stack is mainly usedforstoring temporary data,forstoring local variables andfor
storing returnaddresses after interrupts andsubroutine calls.The Stack Pointer Regis-
ter always points to thetop of the stack. Note that the Stack is implemented as growing
from higher memory locations to lower memory locations.This implies that a stack
PUSH commanddecreases the Stack Pointer.
The Stack Pointerpoints to the data SRAMstack area wherethe Subroutine andInter-
rupt Stacks are located.ThisStack spaceinthe data SRAM must be definedbythe
program beforeanysubroutine calls areexecuted or interrupts areenabled.The Stack
Pointer must be set to point above $60. The Stack Pointer isdecrementedbyone when
data ispushed onto the Stack with thePUSH instruction, and it isdecrementedbytwo
when the returnaddress ispushed onto the Stack withsubroutine call or interrupt. The
Stack Pointer is incrementedbyone when data ispoppedfrom the Stack with thePOP
instruction, and it is incrementedbytwo when address ispoppedfrom the Stack with
return from subroutine RETorreturn from interruptRETI.
The AVR Stack Pointer is implemented as two8-bit registers in the I/Ospace. The num-
ber ofbits actually used is implementation dependent. Note that the data spaceinsome
implementations of theAVRarchitectureisso small that only SPL is needed. Inthis
case, the SPH Registerwill not be present.
15 XH XL 0
X-register 7 0 7 0
R27($1B) R26($1A)
15 YH YL 0
Y-register 7 0 7 0
R29($1D) R28 ($1C)
15 ZH ZL 0
Z-register 7 0 7 0
R31 ($1F) R30 ($1E)
Bit 15 14 13 12 11 10 9 8
SP15 SP14 SP13 SP12 SP11 SP10 SP9 SP8 SPH
SP7 SP6 SP5 SP4 SP3 SP2 SP1 SP0 SPL
76543 210
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value00000000
00000000
Comentarios a estos manuales