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 (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
| To subscribe to this list send email to
| To unsubscribe from this list send email to
| Questions should be directed to the list owner/operator:

This thread ...


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