EasyManua.ls Logo

ST ST7 - Page 69

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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
CALLs 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

Table of Contents

Related product manuals