Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Assembler Code to check normal return / error

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
amitc23

New User


Joined: 05 Nov 2014
Posts: 78
Location: India

PostPosted: Mon Aug 17, 2015 3:52 pm    Post subject: Assembler Code to check normal return / error
Reply with quote

Hi

I have following assembler code. could you please help me understand this.


Code:
READD1 EQU   *                                       
         LA    R0,CARD1          ARG LIST           
         L     RF,DATEENTRY           ENTRY POINT         
         BALR  RE,RF               READ THE CARD       
         BR    R2                  RETURN NORMAL       
         B     DATEOVER            RETURN EOF         
         SPACE 1                                       
DATECON
 .............
..........
..............


In this code ,

How does the program know whether it was a normal return / error / end- of-file (in bold lines above)? I thought both BR and B are uncond to check the efficiencyitional Branches.

Regards
Amit

Code'd
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Aug 17, 2015 4:29 pm    Post subject: Reply to: Assembler Code
Reply with quote

The sub-program should set R15 to a value (zero being normal) when returning to the NSI (Next Sequential Instruction in the Calling program), which can be found in R14.

Examine the sub-program source and look for a return-code setting in R15.

HTH....
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 78
Location: India

PostPosted: Mon Aug 17, 2015 4:45 pm    Post subject:
Reply with quote

Thanks Bill

I got the most of it. However one doubt still remains.
Code:

BALR  RE,RF               READ THE CARD
BR    R2                  RETURN NORMAL
B     DATEOVRX            RETURN EOF


In this code , I understand that the return code from the subroutine call would be placed in RF (bits 2-3). But How does system know to execute BR or B (I mean how do they link to the return code received). Or let me put it this way , Why is BR not executed if the return code is not zero.

I searched for help and it says both BR and B is unconditional Branches.

Regards

Code'd
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Aug 17, 2015 4:58 pm    Post subject: Reply to: Assembler Code
Reply with quote

It looks like "READD1" is a sub-routine that issues a BALR to DATEENTRY, which is invoked via a BAL, because R2 will return you back to the NSI in the program where the BAL had been issued. Without seeing any more of the source, the B DATEOVER seems to be non-executable.

Maybe another member can give an assessment?

If you walk it through a debugger, does the B DATEOVER ever occur?

HTH....
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 78
Location: India

PostPosted: Mon Aug 17, 2015 5:29 pm    Post subject:
Reply with quote

I don't have a debugger at my installation. However following is DATEOVER and DATECON code.

Code:
DATEOVER EQU   *                                     
         B     DATECON            CONTINUE EXECUTION


DATECON EQU   *                                           
         LA    RD,SAVEREGS         SET MY SAVE AREA       
         L     R1,DATEWRK         RESTORE POINTER ADDR   
         B     MAINLINE            GO TO MODULE EXECUTION


Regards

Code'd, again
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Mon Aug 17, 2015 6:54 pm    Post subject: Reply to: Assembler Code
Reply with quote

Why don't you show the code for DATEENTRY? Using the Code tags, please.
Back to top
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 460
Location: The Universe

PostPosted: Mon Aug 17, 2015 8:48 pm    Post subject:
Reply with quote

amitc23 wrote:
... Thanks Bill

I got the most of it. However one doubt still remains.
Code:

BALR  RE,RF               READ THE CARD
BR    R2                  RETURN NORMAL
B     DATEOVRX            RETURN EOF


In this code , I understand that the return code from the subroutine call would be placed in RF (bits 2-3). But How does system know to execute BR or B (I mean how do they link to the return code received). Or let me put it this way , Why is BR not executed if the return code is not zero.

I searched for help and it says both BR and B is unconditional Branches.

Regards

Code'd
BR x is an Assembler provided shortcut for BCR 15,x. Similarly, B x is an Assembler provided shortcut for BC 15,x.

I do something similar -
Code:
         LA    1,UT2   
         BAS   14,READUT
         B     RIGHTEOF


Code:
READUT   BASR  15,0             
         SAVE  (14,2),,READUT   
         LA    15,72(,13)       
         ST    13,4(,15)         
         ST    15,8(,13)         
         LR    13,15             
         LR    2,1               
         GET   (1)               
         LHI   0,1               
         A     0,UT1COUNT-UT1(,2)
         ST    0,UT1COUNT-UT1(,2)
         L     13,4(,13)         
         ST    1,24(,13)         
         RETURN (14,2)           
         ORG   *-2               
         B     4(,14)           
EOF      DC    0H'0'             
         L     13,4(,13)         
         RETURN (14,2)
The intent in the first code fragment is to branch to a specialized EOF routine if the read gets an EOF. The second code fragment is the actual READ routine. It returns to the NSI+4 if there is no EOF, and to the NSI if there is an EOF. It appears the original author of the TS/OP's code has the same general idea.

The ORG *-2 after the first RETURN macro resets the Assembler's location counter so the B 4(,14) replaces the BR 14 within the RETURN macro.

Just a code style point. Many Assembler programmers avoid

XYZ EQU *
instruction

All machine instructions must be aligned on a half word boundary; there is no guarantee the location counter will be on a half word boundary when an address is assigned to XYZ. In my second code fragment, there is a similar issue for the EOF symbol.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 3 Mon Dec 05, 2016 11:57 am
No new posts S922 Error yuvan ABENDS & Debugging 3 Fri Dec 02, 2016 6:58 pm
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
No new posts Invoke Webservice Fails with DFHPI100... divated CICS 2 Thu Nov 24, 2016 5:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us