In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote: Hi Sam; You definitely are digging deep into the bowels of the SX......good for you! The call stack has 8 levels and is 11 (12 for SX48/52) bits wide, catching the full 11 (or 12) bit complement of the PC, and hence a RETURN, whether it is RET, RETP or RETW, will return to the proper spot int the program. There are no special shadow registers for the 3 RETURN instructions, all is contained in the call stack. Only RETP adjusts the page bits of the STATUS register to the current page, but of course they may not have been changed in the called routine, and hence may remain (correct) from what they were before. The JMP instruction is a little different; it only has an 9 bit argument in the instruction label, and pulls the other 2 bits (3 for SX48/52) from the STATUS register. So within the same page, a JMP can go to anywhere of 512 locations, but to go outside that range, the STATUS page bits must first be pre-set, usually through a PAGE instruction. When doing a "calculated" jump where one's program writes a value to the PC, only 8 bits of the PC are accessible, and the 9th bit is always cleared, hence such a jump can only move within the lower 256 locations of the page. Also, the 10th and 11th (and 12th for the SX48/52) bits are drawn from the STATUS register. Again the desired page must be pre-set. This same procedure holds for a CALL instruction. Hope this helps clear things up for you. Cheers, Peter (pjv) ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=104929#m104935 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)