In SX Microcontrollers, SX/B Compiler and SX-Key Tool, dkemppai wrote: Ok, I think I just figured out the answer. Here is what I was up to. I was trying to write a psudo call routine to be used in the upper half of a page of memory. I have a routine that needs to be called, and then calls additional routines multiple times (all residing in the upper half of the page). Because of the size of my program, the program overflows into the upper half of the page and will not work. The solution is to segregrate code into the upper half of the page. The standard call routines won't work. I can't use a jump table, because I need to call routines in the upper half of the page from other routines existing in the upper half of the page. With a few extra instructions, one can effectivley use the 'Secret instructions' and RETI to 'call' and 'return' from sub routines in the upper half of a page. I'm certian that this could be expanded to include calls to and from anywhere, with a few extra bytes of memory/instructions per routine. Another possibility is to not use the JMPLOC variable, by replacing it with a PushW, PopW... I'm sure macros could simplify this goobly gook... ...but I just don't do marcos (Unless forced to!!!) Finally, a way to usefully use the secret instructions!!! (grin) Calls in the upper half of a page, to the upper half of the page are done in the format: (JMPLOC is a byte or ram) MOV JMPLOC,#$+3 JMP RoutinetoCall Returns are: PushW ;Load W into W Shadow Stack MOV W,STATUS ;MOVE STAT to W PushSTAT ;Load W into STAT Shadow Stack MOV W,FSR ;Move the FSR to W PushFSR ;Load W into FSR Shadow Stack MOV M,#$>>8 ;Load Current Page/Half Page into W MOV W,JMPLOC ;Load W with "Next" Addr on this 1/2 Page2 PushPC ;Push W and M to PC Stack RETI ;Pop the All Registers back... Anyway, here's the file. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=80504#m80540 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)