I'm a newbie in assembler and i have a problem to resolve a 0C1 in my 1st assembler program. Here is the code :
TEST02 CSECT
SAVE (12,14)
BALR R12,0
USING *,R12
LA R2,SAVEAREA
ST R2,8(,R13)
ST R13,SAVEAREA+4
L R13,SAVEAREA+4
RETURN (14,12),RC=0
SAVEAREA DC 18F'0'
YREGS
END
Normally, this program just takes the control and returns the control to the environment.
When i assembly, i've got an 0 return code, but when i execute it, i have a 0C1 :
IEA995I SYMPTOM DUMP OUTPUT 790
SYSTEM COMPLETION CODE=0C1 REASON CODE=00000001
TIME=14.47.09 SEQ=39036 CPU=0000 ASID=032B
PSW AT TIME OF ERROR 078D0000 00000002 ILC 2 INTC 01
NO ACTIVE MODULE FOUND
NAME=UNKNOWN
DATA AT PSW 00000000 - 000A0000 000130E1 00000000
GR 0: 00000000 1: 00000000
2: 00000000 3: 00000000
4: 00000000 5: 00000000
6: 00000000 7: 00000000
8: 00000000 9: 00000000
A: 00000000 B: 00000000
C: 00E96742 D: 00006F60
E: 00000000 F: 00000000
END OF SYMPTOM DUMP
At ProgrammStart you issued an SAVE 12,14 and at ProgrammEnd the
correct RETURN 14,12.
So first, you only stored r12,r13 and r14 in the upper saveare. Then you reloaded r14,r15,r0,r1,...up tp r15 and did a BR r14. That causes the StorageViolation.
First you have to store all regs from the upper programm, in your case, the base environment. Then initiate your own savearea. So you have to take care of the correct forward/backward chain.
Without using IBM macros save & return you could code it like this:
MDL00910 CSECT
STM R14,R12,12(R13) ...STORE IN UPPER SAVEAREA
SPACE
BALR R09,0 ...SET R9 AS BASE-REGISTER
USING *,R9
SPACE
USING MDL00910_PARAMETER,R2 ...SET R2 AS DSECT PARM
L R2,0(R1) (ONLY IF THER IS ANY)
SPACE
LA R15,MDL00910_SAVEAREA ...LOAD OWN PGM-SAVEAREA
ST R15,8(R13) ...STORE ADR IN UPPER SAVE
ST R13,4(R15) ...STORE UPPER IN OWN SAVE
LR R13,R15 ...CHANGE ADRESSES
SPACE
B *+4+4+18*4
SPACE
MDL00910_SAVEAREA DC 18F'0' ...PROGRAMM-SAVE-AREA
SPACE
B MDL00910_START
MDL00910_START DS 0H
...JUST DO SOMETHING
MDL00910_ENDE DS 0H
L R13,MDL00910_SAVEAREA+4 ...LOAD BACK ADRESS
LM R14,R12,12(R13) ...RELOAD ALL REGISTERS
SR R15,R15 ...CLEAN R15 FOR RC=0
BR R14 ...GO BACK TO WHERE YOU COME