IP2022 Data Sheet www.ubicom.com 41 Instructions that directly affect the contents of the program
counter (such as jumps and calls) require that the pipeline
be  cleared  and  subsequently  refilled.  Therefore,  these
instructions take two additional clock cycles.
4.4 Subroutine Call/Return Stack A   16-level   hardware   call/return   stack   is   provided   for
saving  the  program  counter  on  a  subroutine  call  and
restoring the program counter on subroutine return. The
stack is not mapped into the data memory address space
except for the top level, which is accessible as the CALLH
and CALLL registers. Software can read and write these
registers  to  implement  a  deeper  stack,  in  those  cases
which  require  nesting  subroutines  more  than  16  levels
deep. This stack is completely independent of the stack
used   with   the   push   and   pop   instructions   and   the
SPH/SPL register pair.
When a subroutine is called, the return address is pushed
onto  the  subroutine  stack,  as  shown  in  Figure  4-13.
Specifically, each saved address in the stack is moved to
the next lower level to make room for the new address to
be saved. Stack 1 receives the contents of the program
counter. Stack 16 is overwritten with what was in Stack 15.
The contents of stack 16 are lost.
Figure 4-13  Stack Operation on Subroutine Call When a return instruction is executed the subroutine stack
is  popped,  as  shown  in  Figure  4-14.  Specifically,  the
contents of Stack 1 are copied into the program counter
and the contents of each stack level are moved to the next
higher level. When a value is popped off the stack, the
bottom entry is initialized to 0xFFFF. For example, Stack
1 receives the contents of Stack 2, etc., until Stack 15 is
overwritten  with  the  contents  of  Stack  16.  Stack  16  is
initialized to 0xFFFF.
515-010.eps Stack 1 Stack 2 Program Counter (15:0) Stack 16 Contents are Discarded Stack 3 Stack 4 Stack 5 Stack 6 Stack 7 Stack 8 Stack 9 Stack 10 Stack 11 Stack 12 Stack 13 Stack 14 Stack 15 Stack 16