SX Users Manual Rev. 3.1
© 2000 Scenix Semiconductor, Inc. All rights reserved.
Chapter 3 Instruction Set
Return from Subroutine Across Page Boundary
STATUS(PA2:PA0) = top-of-stack (11:9)
program counter = top-of-stack
0000 0000 1101
Like the RET instruction, the RETP instruction causes a return from a subroutine.
It pops the 12-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.
Unlike the RET instruction, the RETP instruction also writes bit 11:9 of the return
address (the address of the instruction immediately following the call instruction)
into the PA2:PA0 bits of the STATUS register. This automatically configures the
PA2:PA0 bits to select the current page, allowing a subsequent same-page jump or
call to be executed without using another page instruction.
2 in compatible mode (SX18/20/28AC and SX18/20/28AC75 only), or 3 in tur-
;start of program in page 0
;set PA2:PA0 bits to 001 (different page)
;call subroutine in different page
;call subroutine in same page
;subroutine in same page as call
;new memory segment at 200h
;subroutine address label at 200h
;return from subroutine (different page)
The first call crosses a 512-word page boundary (PA2:PA0 = 001). Upon return
from that subroutine, the PA2:PA0 bits are automatically returned to their original
values (PA2:PA0 = 00), allowing a subsequent same-page call to be done without
using the page instruction again.