SX memory page issue
matrixoperator
Posts: 8
I'm trying to implement a 256 element lookup table in assembly on an SX28.
The subroutine starts on the send page of memory $200. The main program that calls the routine is on the first page of memory. Everything works fine until the subroutine is called with a value in the 'w' register that has the routine jump to the table element stored at $300 or greater. I thought that the range of the second page is from $200-$3ff so I should not expect any problems with page references. Is there something inherently wrong with this approach. Attached is the code below.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
reality is still analog
The subroutine starts on the send page of memory $200. The main program that calls the routine is on the first page of memory. Everything works fine until the subroutine is called with a value in the 'w' register that has the routine jump to the table element stored at $300 or greater. I thought that the range of the second page is from $200-$3ff so I should not expect any problems with page references. Is there something inherently wrong with this approach. Attached is the code below.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
reality is still analog
Comments
This is noted in the "SX Instruction Set" tables in the manual.
If you locate the "JMP PC+W" at a page boundary ($200, $400, etc), you can have at most 255 RETW #xx entries.
You might want to use the IREAD instruction instead.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
Thanks for the help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
reality is still analog
Place a subroutine code like
ReadTable
page Table
jmp w
into any code page, and place 256 RETIW n instructions into another page, (called "Table" here), and - voila - you may call ReadTable with w holding any value from 0 to 255, i.e. with 256 different values.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G