The goal should be to return to the caller in its amode, as that's
undoubtedly what it expects.

If a program is invoked via BASSM (or BSM), the amode in effect at entry is
NOT the caller's amode, other than by chance.  So if you save the amode at
your entry, and use that for return, you will likely cause an abend or
worse.

This is the end of my tutorial on basic linkage.  This is all
well-documented in the Principles of Operation, and Assembler Services
Guide Chapter 5.

sas


On Wed, Aug 12, 2020 at 3:25 PM Gary Weinhold <[email protected]> wrote:

> That was my point; If the goal is to allow the called program to switch
> to amode 31 and return to the caller in the amode it was in, it appears
> Binjamin's 2 instructions are sufficient.  The original code is checking
> to see if they need to do this (and there is a small exposure because
> the opcodes could be spoofed or EXECed, as others pointed out, or the
> locations preceding the R14 could be unaddressable), and it may be more
> efficient to just run the LA and BSM without checking.  Tony mentioned
> that the code is now used outside its original controlled environment,
> so the assumptions abut how it's  entered may no longer apply.
>
> My comment on speed was checking the opcodes and branching take some
> cycles and the LA, BSM instructions may take fewer.
>
> On 2020-08-12 2:04 p.m., Martin Truebner wrote:
> > Gary,
> >
> >>> Are we to conclude from that this discussion that this is a reliable
> way
> >>> to ensure that an AMODE 31 subroutine returns control to its caller
> >>> in the correct amode?
> > the code Tony had was to ensure that it can switch to whatever mode
> > a routine to be called from that code needs
> > without effecting the original caller of the code
> >
> >>>  From Binjamin's response, it appears that checking the opcode of the
> >>> previous instruction was unnecessary and perhaps, depending on the
> >>> speed of BSM, actually slowed down the routine.
> > no no - if BSM is needed (because original caller of the code is 24
> > and final target is 31) then Binjamin's code is fine (at entry!) ...
> >
> > but it also is executed if everyone is 24 and there is no need for it.
>
>
>
> Gary Weinhold
> Senior Application Architect
> DATAKINETICS | Data Performance & Optimization
> Phone:+1.613.523.5500 x216
> Email: [email protected]
> Visit us online at www.DKL.com
> E-mail Notification: The information contained in this email and any
> attachments is confidential and may be subject to copyright or other
> intellectual property protection. If you are not the intended recipient,
> you are not authorized to use or disclose this information, and we request
> that you notify us by reply mail or telephone and delete the original
> message from your mail system.
>

Reply via email to