Too clever by far. Offhand I don't think I would give it a passing grade in a code review.
I can't immediately think of situations where it might fail, but I have the sneaking suspicion that what I don't know (and that's a lot) could bite that code. Peter -----Original Message----- From: IBM Mainframe Assembler List <[email protected]> On Behalf Of Ed Jaffe Sent: Tuesday, August 11, 2020 2:15 PM To: [email protected] Subject: Re: how to return? Clever... On 8/11/2020 10:57 AM, Tony Thigpen wrote: > 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 > -------------------------------------------------------------------------------- This e-mail message, including any attachments, appended messages and the information contained therein, is for the sole use of the intended recipient(s). If you are not an intended recipient or have otherwise received this email message in error, any use, dissemination, distribution, review, storage or copying of this e-mail message and the information contained therein is strictly prohibited. If you are not an intended recipient, please contact the sender by reply e-mail and destroy all copies of this email message and do not otherwise utilize or retain this email message or any or all of the information contained therein. Although this email message and any attachments or appended messages are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by the sender for any loss or damage arising in any way from its opening or use. This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.
