In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote: [quote="Peter Verkaik"] You could do this from location 1 mov m,#($+4)>>8 mov w,#adr1 call @mySub adr1: ;ret adr for this call from location 2 mov m,#($+4)>>8 mov w,#adr2 call @mySub adr2: ;ret adr for this call mySub: ;save m and w for reference or store to private stack or whatever ;do some code retp ;return to adr1 or adr2, specified by m and w regards peter Hi Peter; While your suggestion is technically correct, I believe the your last line (retp ;return to adr1 or adr2, specified by m and w) may lead the reader to believe that the return is directed by the contents of M and W, rather than the entry at the top of the call stack. The contents of M and W are totally irrelevant to return, you had simply chosen them as a convenient location to save the return address so that the subroutine code could use it if required. Also, would loading M and W also not be written somewhat more simply as: Location1 code ;arbitrary code code ;arbitrary code mov m,#Return1>>8 ;get the upper 4 return address bits into m (must go through w for SX48/52) mov w,#Return1 ;get the lower 8 return address bits into w call Subroutine ;go to the routine Return1 code ;arbitrary code code ;arbitrary code Subroutine code ;arbitrary code code ;arbitrary code retp Cheers, Peter (pjv) [/quote][/quote] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=94157#m94238 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)