Program Counter & Pc Stack; Loop Counter & Stack - Analog Devices adsp-2100 Manual

Adsp-2100 family programmable single-chip microprocessors
Table of Contents

Advertisement

3
Program Control
3.2.2
The program counter (PC) is a 14-bit register which always contains the
address of the currently executing instruction. The output of the PC is fed
into a 14-bit incrementer which adds 1 to the current PC value. The output
of the incrementer can be selected by the next address multiplexer to fetch
the next sequential instruction.
Associated with the PC is a 14-bit by 16-word stack that is pushed with the
output of the incrementer when a CALL instruction is executed. The PC
stack is also pushed when a DO UNTIL is executed and when an interrupt
is processed. For interrupts, however, the incrementer is disabled so that
the current PC value (instead of PC+1) is pushed. This allows the current
instruction, which is aborted, to be refetched upon returning from the
interrupt service routine. The pushing and popping of the PC stack occurs
automatically in all of these cases. The stack can also be manually popped
with the POP instruction.
A special instruction is provided for reading (and popping) or writing
(and pushing) the top value of the PC stack. This instruction uses the
pseudo register TOPPCSTACK, described at the end of this chapter.
The output of the next address multiplexer is fed back to the PC, which
normally reloads it at the end of each processor cycle. In the case of a
register indirect jump, however, DAG2 drives the PMA bus with the next
instruction address and the PC is loaded directly from the PMA bus.
3.2.3
The counter and count stack provide the program sequencer with a
powerful looping mechanism. The counter is a 14-bit register with
automatic post-decrement capability that controls the flow of program
loops which execute a predetermined number of times. Count values are
14-bit unsigned-magnitude values.
Before entering the loop, the counter (CNTR register) is loaded with the
desired loop count from the lower 14 bits of the DMD bus. The actual loop
count N is loaded, as opposed to N–1. This is due to the operation of the
counter expired (CE) status logic, which tests CE (and automatically post-
decrements the counter) at the end of a DO UNTIL loop that uses CE as its
termination condition. CE is tested at the beginning of each processor
cycle and the counter is decremented at the end; therefore CE is asserted
when the counter reaches 1 so that the loop executes N times.
3 – 4
Program Counter & PC Stack
Loop Counter & Stack

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents