Joined: 18 Jun 2007 Posts: 213 Location: Cochin/Kerala/India
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
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
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
Joined: 18 Jun 2007 Posts: 213 Location: Cochin/Kerala/India
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?
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
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.