S0C1 When Run my first assembly program



High Level Assembler(HLASM) for MVS & VM & VSE

S0C1 When Run my first assembly program

Postby huxianjun » Sun Sep 11, 2016 9:51 am

Hi

I'm trying to run a very simple assembly program ASMTEST as below(my first time, just for a quick try):
R3       EQU   3
R12      EQU   12
R14      EQU   14
R15      EQU   15
*
LNAME1 AMODE 31
LNAME1 RMODE 24
LNAME1 CSECT
       USING *,15
       SAVE (14,12),,*
       X 3,3
       END


Here's the abend message:

A system abend 0C1 occurred in module ASMTEST at offset X'14'.

A program-interruption code 0001 (Operation Exception) is associated with this
abend and indicates that:

  An attempt was made to execute an instruction with an invalid operation code.

The abend was caused by an undetermined instruction.




I know it must be a very basic concept I've not understood yet for how to code/run an assembly program, but no idea what it is...

Can anyone help me to understand and solve the abend?

Thanks, Roy

coded - please do it yourself next time
huxianjun
 
Posts: 23
Joined: Thu Jul 21, 2016 10:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: S0C1 When Run my first assembly program

Postby steve-myers » Sun Sep 11, 2016 10:45 am

I see two issues.
  • I simplified your program to
    X        CSECT
             SAVE  (14,12),,*
             X     3,3
             END   X

    and ran it through the Assembler and got this
      Loc  Object Code    Addr1 Addr2  Stmt   Source Statement

    000000                00000 0000E     1 X        CSECT
                                          2          SAVE  (14,12),,*
    000000 47F0 F006            00006     4+         B     6(0,15)
    000004 01                             5+         DC    AL1(1)
    000005 E7                             6+         DC    CL1'X'
    000006 90EC D00C            0000C     7+         STM   14,12,12(13)
    00000A 5730 0003            00003     8          X     3,3
    ** ASMA033I Storage alignment for 3 unfavorable
    ** ASMA435I Record 3 in XXXXXX.X.ASM on volume: XXXXXX
    000000                                9          END   X
    It took me several minutes before I remembered what the X instruction does. Ignoring the ASMA033 warning it will execute, though I cannot guess what you hope to do after it executes.
  • Unlike most high level language programs, you must insert code into your program to return to the program that called your program. This is usually accompanied by code to restore any register your program modified and to set a return code. Since you did not bother with this your program executed the X instruction and wandered off to execute, well, nothing. "Nothing" can mean almost anything, but more often than not "nothing" is binary 0s, which are not an instruction (and IBM promises will never be an instruction).
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: S0C1 When Run my first assembly program

Postby huxianjun » Sun Sep 11, 2016 5:31 pm

Thanks Steve for your reply!

Yes my sample program is doing nothing, I'm just trying to have it compiled ok then run ended ok with RC 00, unfortunately it always failed with S0C1.

I tried to compile you the revised program you suggested, but the result is same with S0C1

Here's my job to run the program, is anything wrong with the way/job to run it?
//PY30881A JOB (U),'ASMTEST',
//         MSGCLASS=A,NOTIFY=PY3088
//*
//STEP01   EXEC PGM=ASMTEST
//*
//STEPLIB  DD DISP=SHR,DSN=PY3088.LOADLIB
//SYSOUT   DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
 


recoded

Thanks, Roy
huxianjun
 
Posts: 23
Joined: Thu Jul 21, 2016 10:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: S0C1 When Run my first assembly program

Postby steve-myers » Sun Sep 11, 2016 8:28 pm

Did you read the second bullet? Neither your program or my program will run as is. You must add termination code. At least in concept - though it doesn't really work that way - your program is a subroutine of the operating system.

Task termination attempts to release resources your program does not release, though it often does things in a different order than your program might and things don't get done properly. If you see IEC999 messages or C03 (I think it is) ABENDs it's a certain sign task termination failed to free resources properly.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: S0C1 When Run my first assembly program

Postby steve-myers » Sun Sep 11, 2016 9:06 pm

This is an example of a program that does not terminate properly.
//A       EXEC HLASMCLG
//C.SYSIN  DD  *
X        CSECT
         USING *,12
         SAVE  (14,12),,*
         LR    12,15
         L     0,=A(WASIZE)
         GETMAIN R,LV=(0)
         LR    11,1
         USING WA,11
         LA    15,SAVEAREA
         ST    13,4(,15)
         ST    15,8(,13)
         LR    13,15
         MVC   WADCB(WADCBSZ),MASTDCB
         MVC   WAOPEN(WAOPENSZ),MASTOPEN
         OPEN  (WADCB,OUTPUT),MF=(E,WAOPEN)
         PUT   WADCB,TESTLINE
         L     13,4(,13)
         L     0,=A(WASIZE)
         FREEMAIN R,LV=(0),A=(11)
         RETURN (14,12),RC=0
         PRINT NOGEN
MASTOPEN OPEN  (0,OUTPUT),MF=L
MASTDCB  DCB   DSORG=PS,MACRF=PM,DDNAME=SYSPRINT,RECFM=FA,LRECL=121,  ->
               BLKSIZE=121
MDCBSZ   EQU   *-MASTDCB
TESTLINE DC    CL121' TEST DATA'
WA       DSECT
SAVEAREA DS    18F
WAOPEN   OPEN  0,MF=L
WAOPENSZ EQU   *-WAOPEN
WADCB    DS    XL(MDCBSZ)
WADCBSZ  EQU   *-WADCB
         DS    ((8*1024)-(*-WA))X
WASIZE   EQU   *-WA
         END   X
//G.SYSPRINT DD SYSOUT=*
//G.SYSUDUMP DD SYSOUT=*

Running the program - yes, I did run it - It failed with a C03 ABEND and an IEC999 message. Now let's see if you can figure out what I did wrong.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: S0C1 When Run my first assembly program

Postby Robert Sample » Sun Sep 11, 2016 10:25 pm

There is nothing wrong with your JCL. The issue is NOT with the JCL (that is, the environment you are running in) -- the issue is that your code does not properly set up the return from the program. At a minimum you need RETURN (14,12) after your X 3,3 statement. Also, your program does not set up for save area tracing, which can be beneficial when tracking down errors in programs.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: S0C1 When Run my first assembly program

Postby steve-myers » Mon Sep 12, 2016 12:32 am

Robert Sample wrote:There is nothing wrong with your JCL. The issue is NOT with the JCL (that is, the environment you are running in) -- the issue is that your code does not properly set up the return from the program. At a minimum you need RETURN (14,12) after your X 3,3 statement. Also, your program does not set up for save area tracing, which can be beneficial when tracking down errors in programs.

IF your program does no I/O or call another program it does not need to allocate a save area. The way IBM does I/O amounts to calling another program.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: S0C1 When Run my first assembly program

Postby huxianjun » Mon Sep 12, 2016 7:26 am

Hi Steve and Robert

Many thanks for all your replies!!

You're right, after added 'RETURN (14,12)' at the end I run the program ok now!

It's amazing of coding assembly program, though I just started 1 day ago and almost know nothing about it yet...

Thanks again, Roy
huxianjun
 
Posts: 23
Joined: Thu Jul 21, 2016 10:10 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post