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
 

 

Question about return code in assembler

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

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Mon Jun 09, 2008 10:10 am    Post subject: Question about return code in assembler
Reply with quote

Hi All,
In assembler program ,in wich register the return code is stored?Is it in R15?Do we need to initialize this register in the beging of the program?.Please find my sample code below its giving maxcc 4062,is any particular reason for it?
000001 PROGRAM START 0
000002 BALR 12,0
000003 USING *,12
000004 L 2,X
000005 A 2,Y
000006 ST 2,Z
000007 BR 14
000008 *
000009 X DC F'7'
000010 Y DC F'3'
000011 Z DS F
000012 END


Regards,
Bipin Peter
Back to top
View user's profile Send private message

GAFUR

New User


Joined: 19 May 2005
Posts: 31

PostPosted: Mon Jun 09, 2008 11:16 am    Post subject:
Reply with quote

By seeing your program i can say there are no standard entry and exit instructions.

Return code , this will be stored in register 15 at time of exit.

I have modified your progam and tested works fine.


000001 PROGRAM START 0
000002 STM 14,12,12(13)
000003 BALR 12,0
000004 USING *,12
000005 ST 13,SAVE+4
000006 LA 13,SAVE
000007
000008 L 2,X
000009 A 2,Y
000010 ST 2,Z
000011 *
000012 EXIT L 13,SAVE+4
000013 L 14,12(0,13)
000014 LA 15,4 ===> RETURN CODE 4
000015 LM 0,12,20(13)
000016 BR 14
000017 *
000018 SAVE DS 18F
000019 X DC F'7'
000020 Y DC F'3'
000021 Z DS F
000022 END
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Mon Jun 09, 2008 8:05 pm    Post subject:
Reply with quote

@bipinpeter !

As your Assembler program allways runs as a subprogramm of the system or another programm, you have to take care of the registers at the beginning and at the end of your programm. First you have to store the registers of the system/calling programm, then at end, you have to restore them. It's allways the same.

Regards, UmeySan


Example:

MDL00910 CSECT
ENTRY MDL00910
MDL00910_BEGIN DS 0H
STM R14,R12,12(R13) ...STORE REGS IN CALLERS SAVE
LR R9,R15 ...LOAD R9 ADRESS CALLERS R15
USING MDL00910_BEGIN,R9 ...AND USE IT AS BASE-REG
SPACE
LA R15,MDL00910_SAVEAREA ...LOAD OWN PGM-SAVEAREA
ST R15,8(R13) ...STORE IN CALLERS SAVE-AREA
ST R13,4(R15) ...STORE IN OWN SAV-EAREA
LR R13,R15 ...POINT R13 TO OWN SAVE-AREA
SPACE
B MDL00910_START

MDL00910_START DS 0H


MDL00910_STOPP DS 0H
B MDL00910_START


MDL00910_ENDE DS 0H PROGRAMM-ENDE
L R13,MDL00910_SAVEAREA+4 ...LOAD SAVE-AREA
LM R14,R12,12(R13) ...RELOAD ALL THE REGS
SR R15,R15 ...CLEAR REGISTER-15
BR R14 ...GET OUT OF HERE
EJECT
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Mon Jun 09, 2008 10:27 pm    Post subject:
Reply with quote

Hi GAFUR,
I tried ur code its working fine.But when i commented the line LA 15,4 ===> RETURN CODE 4 .I got return code 3968.Why is this?
What actually happening if load R15 with R4?

Regards,
Bipin Peter
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jun 10, 2008 1:36 am    Post subject:
Reply with quote

Hello,

Quote:
What actually happening if load R15 with R4?
That is not using R4 - it is using the literal four - hence the RC=4 when executed.

You are getting the unpredictable value because that is whatever was left in the register when you did not initialize it to zero, four, or some other value (less than 4096). If you specify a return code greater than 4095, you get an "adjuctment" automagically.

If you want an RC=0, use a zero instead of 4.
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 How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts A not very Christmassy PL/I tale, wit... prino PL/I & Assembler 3 Mon Dec 26, 2016 1:01 am
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am


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