English
Language : 

45111 Datasheet, PDF (106/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
10 SX Special Features and Coding Tips
The following code snippet demonstrates this:
Start
ORG $0
; This routine is in page 0
JMP @Routine; Jump to proper page
JMP Start
Routine
ORG $200 ; This routine is in page 1
JMP @Start ; Jump back to proper page
The @ symbol preceding the address causes the assembler to insert a PAGE instruction just before the
JMP to set the page select bits appropriately. The second JMP in line three does not require an @ symbol
since the destination address is within the current page. If the @ was left out of line two, the SX would
jump to address $000 instead of $200. See Chapter 15.2.14 - Jumping Across Pages for more
information.
10.6.2 Calling Across Pages with Jump Tables
Calling subroutines can pose even more boundary problems than jumping across pages. The CALL
instruction uses only an 8-bit address as the operand (the 9th bit of the address is always cleared). This
limits the calling destination to the first 256 words of the current page.
Because it is sometimes impossible to organize all subroutines within such a tight space, a common
practice is to make use of a subroutine jump table. The jump table consists of a list of JMP commands to
various subroutines and is located within the first 256 words of the page. The CALL instructions can
simply call the proper location within the jump table and code execution jumps to the appropriate
subroutine, even if it exists in different pages or above the 256 word barrier.
To call subroutines across page boundaries:
1) Design a jump table with the page-set option (the @ sign preceding the addresses).
2) Place the subroutines in any desired location being sure to end them with RETP.
3) Call the subroutine’s alias-name in the jump table.
Page 106 • SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc.