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

SOC4 in ASM program


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

New User


Joined: 05 Jan 2010
Posts: 1
Location: chennai

PostPosted: Tue Jan 05, 2010 10:29 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jan 05, 2010 10:46 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Thu Jan 07, 2010 4:27 pm
Reply with quote

@ 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
View user's profile Send private message
Stu Thomas

New User


Joined: 06 Feb 2010
Posts: 5
Location: Canada

PostPosted: Wed Feb 10, 2010 8:03 pm
Reply with quote

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
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Feb 10, 2010 8:13 pm
Reply with quote

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
View user's profile Send private message
Stu Thomas

New User


Joined: 06 Feb 2010
Posts: 5
Location: Canada

PostPosted: Wed Feb 10, 2010 8:15 pm
Reply with quote

Please explain your comment about "nonsense".
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Feb 10, 2010 8:17 pm
Reply with quote

LOL,

well PUT doesnt need a save area.
So what do you think your comments look like.
Back to top
View user's profile Send private message
Stu Thomas

New User


Joined: 06 Feb 2010
Posts: 5
Location: Canada

PostPosted: Wed Feb 10, 2010 8:34 pm
Reply with quote

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
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Feb 10, 2010 8:41 pm
Reply with quote

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
View user's profile Send private message
Stu Thomas

New User


Joined: 06 Feb 2010
Posts: 5
Location: Canada

PostPosted: Wed Feb 10, 2010 8:45 pm
Reply with quote

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
View user's profile Send private message
Stu Thomas

New User


Joined: 06 Feb 2010
Posts: 5
Location: Canada

PostPosted: Wed Feb 10, 2010 9:05 pm
Reply with quote

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
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 Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top