
69/317
4 - Architecture of the ST7 core
04-stack
When a value is stored using the stack pointer, the stack is decremented, so that the next
value stored will be placed at the address just below the previous one. This process of storing
and decrementing the pointer is called Pushing, and can be done either by a
PUSH
instruction
or by a
CALL
instruction that pushes the return address.
When the data is read back from the stack, the
SP
is incremented so that the next data re-
trieved will be the one situated at the address above the previous value retrieved. This is
called popping the data, and can be done using the
POP
instruction or the
RET
instruction that
pops one address off the stack and jumps to that address.
If several addresses are stored successively because several
CALL
s were executed succes-
sively, the first
RET
instruction will pop the last address pushed, the second
RET
will pop the
one-but-last address, and so on. This feature provides for the nesting of subroutines, where
the last called is the first exited.
Interrupts, being a kind of subroutine call, also use the stack to store the context of the inter-
rupted process. Since interrupts occur at unexpected times, all the core registers must be
saved on entering the interrupt service routine. This is performed automatically by the interrupt
mechanism that pushes in order
PC
,
X
,
A
and
CC
. The return from interrupt must thus use a dif-
ferent instruction from the return from subroutine, where only the
PC
was saved. The instruc-
tion
IRET
is supplied for this purpose, and restores the initial values of these registers. It
should be noted that the
Y
index register is not saved automatically. The industry-standard
0140h
Top of the stack
017Fh
Bottom of the stack
(Reset value)
64 bytes of RAM
Stack organization of the ST72251
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...