I have written a sample ASM program to read from a file and write the record into output file. It got compiled successfully but it is giving SOC1 abend at the time of execution.
Here is the code:
Code:
PRINT NOGEN
START 0
HELLO CSECT
USING *,12
STM 14,12,12(13)
LR 12,15
LA 15,SAVE
ST 15,8(13)
ST 13,4(15)
LR 13,15
*
OPEN (FILEA,INPUT)
OPEN (FILEB,OUTPUT)
LOOP GET FILEA,IREC
MVC OTID,ITID
MVC OTNAME,ITNAME
MVC OTDEG,ITDEG
PUT FILEB,OREC
B LOOP
ATEND CLOSE FILEA
CLOSE FILEB
RETURN
*
LTORG
*
FILEA DCB DSORG=PS,MACRF=GM,EODAD=ATEND,DDNAME=FILEA
FILEB DCB DSORG=PS,MACRF=PM,DDNAME=FILEB
*
IREC DS 0CL80
ITID DS CL5
ITNAME DS CL25
ITDEG DS CL15
DS CL35
*
OREC DS 0CL60
OTID DS CL5
DC CL3' '
OTNAME DS CL25
DC CL3' '
OTDEG DS CL15
DC CL9' '
*
SAVE DS 18A
END HELLO
Kindly let me know that Is this code correct?
Please let me know what are all other statements need to code.
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
Psychic day was Tuesday this week.
How many times do we have to reply to people and ask them for the
OUTPUT
of the failed run and showing exactly what has happened.
Or do you expect someone to copy, assemble and link the code and try it for themselves.
Please have a think about providing usefull information before posting will you !!!
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
At the very least, your program must be Assembled/Linked as AMODE/RMODE 24, because you're using DCB's.
After the CLOSE of both files, you're not restoring the caller's R13 from the 18-word savearea (L 13,4(,13)). Also, the RETURN Macro is incomplete, as it needs to specify RETURN (14,12),RC=(15). It's always a good idea (and it can't hurt) to set R15 to a value (such as F'0') and return it to the Caller. If the Caller is COBOL, then this would be the RETURN-CODE Special-Register. I think PL/I's counterpart is PLIRETC, but I'm not 100% certain.
I would advise you to use R3 instead of R12 as the base-register, because if the caller is Language Environment compliant, R12 always contains the address of the CEECAA and if you ever change the sub-program to be LE compliant, you'll need this address.
The ABEND information in SYSOUT should give you the address in the sub-program that caused the S0C1 (an invalid OP CODE), which is easy enough to find in the listing.
What could be happening is after the RETURN (which needs to be fixed), execution falls through and hits a DS/DC expansion in the DCB because an LTORG should not be generated (don't see any literals).
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
Quote:
I have written a sample ASM program to read from a file and write the record into output file. It got compiled successfully but it is giving SOC1 abend at the time of execution.
Unlike HLL's, who will inform you about potential errors, the Assembler is unforgiving and it assumes that you know what you're doing.
BTW, you Assemble an Assembler program, whereas, you Compile a COBOL program.