In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote: Samual, yes, you are right (and I mentioned this in my last post), RETW does _not_ restore the page bits. Paul's suggestion replacing the RETW by mov w, #const + retp is one option but it no longer allows you to use SASM's nice feature to follow RETWs with many parameters to create kind of a table. It is important to know that all RET instructions correctly restore the SX program counter (the internal 11 or 12 bit register) and the 8-bit PC register, so all RET instructions send program execution back to the right place. The pitfall is that RETP is the only instruction that also restores the page bits on return, where the others don't. Thus, later jumps or calls may go to "nowhere land", or to some un-expected location when the page was changed before to correctly address the subroutine. Therefore, as I had mentioned before in my last post, another alternative is to have the calling code take care if setting the page bits correctly, like in org 0 Main page Sub1 call Sub1 page Main . . org $200 Sub1 ; Foo Foo retw 1 IREAD is another interesting alternaitive to handle tables with constants but it is a bit more tricky, and requires a bit more code to handle it. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=104866#m104927 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)