View previous topic :: View next topic
|
Author |
Message |
Gumby
New User
Joined: 05 Jan 2010 Posts: 1 Location: chennai
|
|
|
|
I'm new to ASM. I've been trying to learn asm by myself and in one of my practice programs I keep getting s0c4 upon execution. I'm not able to pinpoint what's wrong. Could you please let me know where I'm going wrong?.
Code: |
ASMPGM6 START 0
SAVE (14,12)
BALR 12,0
USING *,12
PARA1 EQU *
OUTREC DS 0CL80
OPEN (OUTFILE,(OUTPUT))
MVC OUTREC,=C'HI'
PUT OUTFILE,OUTREC
CLOSE (OUTFILE)
RETURN (14,12),RC=0
OUTFILE DCB DSORG=PS, X
RECFM=FBA, X
MACRF=PM, X
BLKSIZE=800, X
LRECL=80, X
DDNAME=OUTP
END
|
run job for the above program is as below
Code: |
//STEP1 EXEC PGM=ASMPGM7
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//OUTP DD DSN=E4912.OPT,
// DISP=(MOD,CATLG,),
// SPACE=(CYL,(1,1),RLSE),
// LRECL=80,RECFM=FBA,BLKSIZE=800
|
Rgds,
KV |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Code: |
OUTREC DS 0CL80
OPEN (OUTFILE,(OUTPUT))
MVC OUTREC,=C'HI' |
the quoted code will overlay the program with garbage!
read the pop for the MVC specifications!
it' s always a bad practice to have to working areas interspersed with the executables
also nothe that a DS 0<something> does not reserve any storage,
it sipèly define an address and a length |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
@ Gumby !
And please, read more about structured programming.
Do not code anything one after the other. Build structures. Use sections.
Code assembler as you would code cobol. |
|
Back to top |
|
|
Stu Thomas
New User
Joined: 06 Feb 2010 Posts: 5 Location: Canada
|
|
|
|
OPEN and CLOSE do not need a save area, but PUT does. You need to provide a save area - that will solve your problem. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Stu Thomas wrote: |
OPEN and CLOSE do not need a save area, but PUT does. You need to provide a save area - that will solve your problem. |
Huh? And THAT said by a system programmer?
I did write enough assembler programs to know that you are
talking nonsense. |
|
Back to top |
|
|
Stu Thomas
New User
Joined: 06 Feb 2010 Posts: 5 Location: Canada
|
|
|
|
Please explain your comment about "nonsense". |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
LOL,
well PUT doesnt need a save area.
So what do you think your comments look like. |
|
Back to top |
|
|
Stu Thomas
New User
Joined: 06 Feb 2010 Posts: 5 Location: Canada
|
|
|
|
PUT results in a BALR 14,15 to an Access Method. The first thing that the Access Method does is to store YOUR registers into the save area pointed to by Reg 13. Reg 13 currently points to the save area which was passed to your program by your caller. Therefore, the Access Method is writing into your caller's save area. Thus, the Access Method has overlaid your caller's save area. When you return to your caller at the end of your code, you have not restored your caller's registers - you've got the registers which were saved by the Access Method. The 0C4 results. This is a common problem, often seen when people do not understand when save areas are required. It is also common to see people providing save areas when they are not necessary, but this will not cause abends, just unnecessary instructions, and wasted time.
Do you need any further explanation? |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Of course not but what you commented looked like supplying a save area for any PUT.
But supplying a save area at the start of your programming is a required practice. I even think that the OPEN/CLOSE will use it.
So im sorry for mis interpreting your comment.
Hope there is no harm done. |
|
Back to top |
|
|
Stu Thomas
New User
Joined: 06 Feb 2010 Posts: 5 Location: Canada
|
|
|
|
Sorry, but that is not correct. OPEN and CLOSE use the save area in the RB; they do not require that you provide a save area in your program. And, as I explained, "supplying a save area" is NOT a required practice. |
|
Back to top |
|
|
Stu Thomas
New User
Joined: 06 Feb 2010 Posts: 5 Location: Canada
|
|
|
|
One more thing as I re-read your answer. Even though I did not state this, ALL PUTs need a save area.
Also, I accidently missed your apology. There's never any harm done since we are all trying to help each other. I'm not offended. And yes, I actually am a System Programmer, and I've been one since 1967, in the days of PCP. MFT and MVT. I learned assembler from the original Principles of Operation, and I know what a challenge understanding it can be. I'm glad to provide any assistance if it will help folks who are new to assembler to solve their difficulties. |
|
Back to top |
|
|
|