English
Language : 

45111 Datasheet, PDF (107/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
10 SX Special Features and Coding Tips
The following code snippet demonstrates this:
ORG
$0
; This routine is in page 0
Sub1
Sub2
; Define the subroutine jump-table
;
JMP
@_Sub1
; Set page and jump
JMP
@_Sub2
Start
; Start of main routines
;
CALL
@Sub1
JMP
@Continue
; Call the Jump Table
ORG
$200
; This routine is in page 1
Continue
CALL
JMP
@Sub2
@Start
; Call the Jump Table
_Sub1
ORG
$400
; Subroutine 1 code goes here
;
RETP
; This routine is in page 2
; Return and reset page
_Sub2
; Subroutine 2 code goes here
;
RETP
; Return and reset page
The first CALL in the Start routine calls the Sub1 address in the jump table. The JMP command at Sub1
then jumps to the _Sub1 subroutine (in page 2) which eventually returns to the line following the CALL.
The RETP command used to return from the subroutine resets the page select bits to the page of the
calling routine (exactly as intended).
The @ symbol preceding the addresses causes the SX editor to insert a PAGE instruction just before the
JMP and CALL commands to set the page select bits appropriately. The first CALL, in the Start routine,
would function the same without an @ symbol, as shown above, since the destination address is within
the current page. See Chapter 15.2.16 – Calling Across Pages for more information.
SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc. • Page 107