EasyManua.ls Logo

ST ST7 - Program Counter (PC); Stack Pointer (SP)

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...
68/317
4 - Architecture of the ST7 core
two addresses as is needed in a memory-to-memory data move, with or without alteration in
between. However, these registers may also be used to store temporary data.
4.2.2.4 Program Counter (PC)
The program counter is the register that controls the sequencing of the instructions. The pro-
gram is written as a series of instructions, and these instructions are stored in consecutive
cells of the program memory. The Program Counter contains the address of the next instruc-
tion to be executed. This instruction is read from memory, then executed, and the
PC is incre-
mented so that it then points to the next instruction in the sequence.
It is possible to alter the contents of the
PC while the program is executing. In this case, the
next instruction will not necessarily be the next in the sequence, but an instruction somewhere
else in memory. Changing the course of the program is called jumping or branching.
Jump and Branch are the names of instructions that actually change the contents of the
PC by
setting it to a value specified with the instruction. Jumps may also be conditional, that is, the
jump instruction effectively alters the contents of the
PC if certain conditions are met. These
conditions can be the values of one or more bits of the Condition Code Register. For example,
the
JREQ instruction changes the PC to the specified address if the Z bitoftheCC register is set,
otherwise the program continues in sequence.
Another kind of jump is the Subroutine Call, that first saves the address of the next instruction
in sequence (the one that follows the jump instruction) before jumping. A special instruction,
RETurn, retrieves this address and puts it into the PC. The next instruction executed is once
again the one that follows the
CALL instruction.
4.2.2.5 Stack Pointer (SP)
The stack is the part of the read-write memory where return addresses are stored by the
CALL
instructions and retrieved by the RET instruction.

Table of Contents

Related product manuals