© 2000 Scenix Semiconductor, Inc. All rights reserved. - 43 - www.scenix.com SX48BD/SX52BD/SX52BD75/SX52BD100 15.9 Branch and Loop Call Instructions The device contains an 8-level hardware stack where the return  address  is  stored  with  a  subroutine  call.  Multiple stack levels allow subroutine nesting. The instruction set supports absolute address branching. 15.9.1  Jump Operation When a JMP instruction is executed, the lower nine bits of the program counter are loaded with the address of the specified   label.   The   upper   three   bits   of   the   program counter  are  loaded  with  the  page  select  bits,  PA2:PA0, contained in the STATUS register. Therefore, care must be exercised to ensure the page select bits are pointing to the correct page before the jump occurs. 15.9.2  Page Jump Operation When  a  JMP  instruction  is  executed  and  the  intended destination  is  on  a  different  page,  the  page  select  bits must be initialized with appropriate values to point to the desired page before the jump occurs. This can be done easily with SETB and CLRB instructions or by writing a value to the STATUS register. The device also has the PAGE instruction, which automatically selects the page in a single-cycle execution. Note:“N” must be 0, 1, 2, or 3. 15.9.3  Call Operation The following happens when a CALL instruction is exe- cuted: •    The current value of the program counter is increment- ed and pushed onto the top of the stack. •    The lower eight bits of the label address are copied into the lower eight bits of the program counter. •    The ninth bit of the Program Counter is cleared to zero. •    The page select bits (in STATUS register) are copied into the upper three bits of the 12-bit program counter. This  means  that  the  call  destination  must  start  in  the lower  half  of  any  page.  For  example,  00h-0FFh,  200h- 2FFh, 400h-4FFh, etc. 15.9.4  Page Call Operation When  a  subroutine  that  resides  on  a  different  page  is called, the page select bits must contain the proper val- ues to point to the desired page before the call instruction is  executed.  This  can  be  done  easily  using  SETB  and CLRB instructions or writing a value to the STATUS reg- ister.  The  device  also  has  the  PAGE  instruction,  which automatically  selects  the  page  in  a  single-cycle  execu- tion. 15.10    Return Instructions The  device  has  several  instructions  for  returning  from subroutines  and  interrupt  service  routines.  The  return from   subroutine   instructions   are   RET   (return   without affecting W), RETP (same as RET but affects PA2:PA0), RETI (return from interrupt), RETIW (return and add W to RTCC), and RETW #literal (return and place literal in W). The literal serves as an immediate data value from mem- ory. This instruction can be used for table lookup opera- tions. To do table lookup, the table must contain a string of RETW #literal instructions. The first instruction just in front of the table calculates the offset into the table. The table can be used as a result of a CALL. STATUS<7:5> JMP LABEL (9 BITS) PC<11:9> PC<8:0> PAGE N STATUS<7:5> JMP LABEL (9 BITS) PC<11:9> PC<8:0> STATUS<7:5> 0 CALL LABEL (8 BITS) PC<11:9> PC<8>       PC<7:0> PAGE N STATUS<7:5> 0 CALL LABEL (8 BITS) PC<11:9> PC<8> PC<7:0>