I have been reading all the "that is not a good way to do it" posts, so here it the challenge to all those nay-sayers.

It's time to 'put-up' or 'shut-up'.

Under the following conditions, just how would you code it?

Rules:

1) You are coding the entry and exit for a called subroutine. For this exercise, you will not be the main program called by a JCL EXEC card.
2) The way the caller is calling you can not be regulated.
3) The caller may be Assembler or Cobol.
4) Existing older code, that can not be changed, calls using a BALR.
5) Existing newer code calls using BASSM. And, it can not be changed.
6) It is known that some programs calling via BALR will call in 31bit.
7) It is know that some programs calling via BALR will call in 24bit.
8) Your code needs to perform some functions that require 31bit.
9) You must return to the caller is such a way that the callers mode prior to the call and after the call is the same.
10) 64bit support is not required.
11) You must be callable from both a non-LE environment and an LE environment.
12) LE support is not only not required, you just can't use it.
13) You must be LE-tolerant is. If you are called by LE you can't mess up the LE environment, but you don't have to exploit it. 14) And to make it even more challenging, the code *must* run in a older processor that does not support branch-retaliative nor BAKR/PR instructions. Yes, this code is from a real-live vendor product that is still being used by customers on machines that don't support those instructions.

And, before you complain, this is *exactly* the requirements that the original coder was facing, and still faces with this code.

The requirements of this challenge is that you show everybody on the list the code you would write for these requirements.

Tony Thigpen

Seymour J Metz wrote on 8/14/20 5:10 PM:
Simpler is safer.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3


________________________________________
From: IBM Mainframe Assembler List <[email protected]> on behalf of 
Tony Thigpen <[email protected]>
Sent: Tuesday, August 11, 2020 1:57 PM
To: [email protected]
Subject: how to return?

I came across the following code today. The program can either be called
by JCL or from either an HLL or assembler program. While I included some
extra code for clarity, the code I am asking for comments on is the code
that 'fixes' R14 so that a BSM can be used instead of a BR. I just
thought I would ask what others think about this method.

XXXXXXXX CSECT
XXXXXXXX AMODE ANY
XXXXXXXX RMODE 24   SOME IBM CODE IN HERE MAY REQUIRE R24
           USING XXXXXXXX,R15
           B     COPYRGHTEND
......
COPYRGHTEND DS 0D
           STM   R14,R12,12(R13)     SAVE CALLERS REGISTERS
           BCTR  R14,0               BACKUP TO CALLING INST
           BCTR  R14,0                 .
           CLI   0(R14),X'0C'        BASSM?
           BE    R14_OK
           CLI   0(R14),X'0D'        BSM?
           BE    R14_OK
           L     R14,12(,R13)        GET ORG R14
           LA    R14,0(,R14)         CLEAR HI BIT/BYTE
           BSM   R14,0               ADD PROPER AMODE
           ST    R14,12(,R13)        SET R14 FOR RETURN BY BSM
R14_OK   DS    0H
           DROP  R15
           LA    R1,SAVEAREA
           ST    R1,8(,R13)          FORWARD POINTER
           ST    R13,4(,R1)          BACKWARD POINTER
           LR    R13,R1              ESTABLISH PERM R13 AREA
           L     R1,4(,R13)          GET BACK ORG R0 & R1
           LM    R0,R1,20(R1)          FROM ORG SAVEAREA
*
           LA    R8,0(,R15)          ESTABLISH ADDRESSABILITY
           LA    R15,1                 .
           LA    R10,4095(R15,R8)      .
           USING XXXXXXXX,R8,R10       .

The return code is:
RETURNR15 DS   0H
           L     R1,4(,R13)          GET CALLER SAVE AREA ADDRESS
           ST    R15,16(,R1)         SAVE RETURN CODE
           LM    R14,R12,12(R13)     RESTORE REGISTERS
           BSM   0,R14               GO BACK

Tony Thigpen

Reply via email to