MIDRANGE dot COM Mailing List Archive

Home » MIDRANGE-L » May 1999

Re: *PSSR subroutine and the call stack


Doug Handy got it right when he wrote that RPG saves one return address
per subroutine, and when the ENDSR is reached, it branches to the saved
address.  Each EXSR causes the return address associated with the target
subroutine to be set to the address of the instruction immediately
following the EXSR.

Of course, this does not explain the behavior observed by Pete Hall. 
The call to Sub A from Sub C should have overlaid A's return address
with an address in C.  But, as Doug pointed out, the language forbids
recursion and does not predict what will happen.

> Excerpts from midrange: 9-May-99 RE: *PSSR subroutine and th..
> Pete Hall@execpc.com (1190*)

> mainline calls Sub A
> Sub A calls Sub B
> Sub B calls Sub C
> Sub C calls Sub A
> Sub A returns to mainline (not Sub C) - this was not the desired
> behavior

| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com

Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2015 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact