Instruction Set Architecture—IP2022 User’s Manual 198 www.ubicom.com RETW #lit8 Return from Subroutine with Literal into W Operation: W = lit8
program counter = top-of-stack
Bits affected: None Opcode: 0111 1000 kkkk kkkk Description: This instruction loads an 8-bit literal into W and
causes a return from a subroutine. The literal can
be    used    to    implement    lookup    tables.    The
instruction pops the 16-bit value previously stored
on   the   stack   and   restores   that   value   to   the
program  counter.  This  causes  the  program  to
jump to the instruction immediately following the
call instruction that called the subroutine. The hardware   stack   used   for   subroutine   call   and
return is independent from the stack used with the
push and pop instructions. It  is  not  necessary  to  set  the  PA2:0  bits  in  the
STATUS register to return to the correct place in
the   program.   This   is   because   the   full   16-bit
program address is restored from the stack. The
ret  instruction   does   not  use  (and   does   not affect) the PA2:0 bits.