IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Question about return code in assembler


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bipinpeter

Active User


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

PostPosted: Mon Jun 09, 2008 10:10 am
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
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: 771
Location: Germany

PostPosted: Mon Jun 09, 2008 8:05 pm
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: 213
Location: Cochin/Kerala/India

PostPosted: Mon Jun 09, 2008 10:27 pm
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

Moderator Emeritus


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

PostPosted: Tue Jun 10, 2008 1:36 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts Question for file manager IBM Tools 7
Search our Forums:

Back to Top