Assembler first program failed with S0C1

HLASM for MVS. PL/I for MVS & Enterprise PL/I for z/OS.
Post Reply
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Assembler first program failed with S0C1

Post by kingo »

Hi,

I am trying to learn and practice Assembler. I tried to execute one of the program in Bill Quall's book and it failed with s0c1

Code: Select all

----+----1----+----2----+----
*****************************
         PRINT  NOGEN
TEST     START  0
         BASR   15,0
         USING  *,15
         WTO    T1
T1       DC     C'TEST'
         END    TEST
I got the abend below :

Code: Select all

COMPLETION CODE      SYSTEM = 0C1      REASON CODE = 00000001

  PSW AT ENTRY TO ABEND   078D0000  00007014  ILC  06  INTC  0001
PSW LOAD MODULE             ADDRESS = 00007000  OFFSET = 00000014
What could be the issue,could someone guide me please?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

After the WTO, you then attempt to execute 'TEST' as assembler instructions. This is not going to work -- obviously (even if the hex values were valid assembler instructions, you're almost certainly not going to have the required data for the assembler instructions available). You need to have a BR 14 (or whatever was in the program you copied) to exit the program BEFORE the constant.

Side comment: PRINT NOGEN is not a good thing to put in an assembler program unless it has lots of macros. You want to see the generated offsets because if you have an abend, the offset of the abend is displayed to at least get you started on where to look for the problem.
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Hi Robert,

Thank you for your response

I corrected the code as suggested

Code: Select all

TEST     CSECT
         STM   14,12,12(13)     STANDARD ENTRY
         BASR  12,0
         USING *,12
         ST    13,SAVE+4
         LA    13,SAVE
         L     13,SAVE+4
         WTO   'HELLO'
         WTO   'JUST1'
         WTO   T1
         LM    14,12,12(13)
         LA    15,0
         BR    14
SAVE     DS    18F
T1       DC    C'TEST'
         END   TEST
This executed ok but I don't see T1 being written and the rest HELLO and JUST1 is displayed, could you please tell me why T1 not being displayed?

Thanks
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

Try these code changes:

Code: Select all

         WTO   TEXT=(T1)
 .
 .
 .
 T1      0DS   CL6
         DC    H'04'
         DC    C'TEST'
The first two messages have their length known when the assembly is done since they are constants. WTO T1, however, is not a valid WTO message and requires you to use the variable-length record format and hence you have to provide the length of the message as a half-word before the actual text. You use WTO TEXT=(T1) to indicate what the message and its length are. You'll want to read up on WTO if you want to use it for much, as there are a number of things to understand about how it works.
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Hi Robert,

Thanks again, I modified the code as suggested

Code: Select all

TEST     CSECT
         STM   14,12,12(13)     STANDARD ENTRY
         BASR  12,0
         USING *,12
         ST    13,SAVE+4
         LA    13,SAVE
         L     13,SAVE+4
         WTO   'HELLO'
         WTO   'JUST1'
         WTO   TEXT=(T1)
         LM    14,12,12(13)
         LA    15,0
         BR    14
SAVE     DS    18F
T1       0DS   CL6
         DC    H'04'
         DC    C'TEST'
         END   TEST
It fails in compiler with

Code: Select all

** ASMA141E Bad character in operation code - 0DS


Do I need to add X at 72 for group variables?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

No, change the code to

Code: Select all

T1       DS    0CL6
My fault -- I didn't have time to check the syntax before I sent the email, and I was distracted by something else going on.
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Hi Robert,

Thanks it is fixed now and I apologies for not reporting an another error earlier and I did not report it at first place as I assumed it could be due to T1 was not defined earlier.

But after making adjustments I get this error during compile

Code: Select all

  Loc    Object Code      Addr1    Addr2    Stmt  Source Statement
000000A8 18E1                                 58+         LR    14,1
000000AA 1BFF                                 59+         SR    15,15
000000AC 4AF1 0000               00000000     60+         AH    15,0(1,0)
000000B0 1AEF                                 61+         AR    14,15
000000B2 0000 0000               00000000     62+         ST    T1,4(0,1)
** ASMA029E Incorrect register specification - T1
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

I don't use WTO often enough to remember it well. Try this:

Code: Select all

         LA    5,T1
         WTO   TEXT=(5)
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Hi Robert,

This worked liked a charm
Thanks a bunch

Code: Select all

TEST     CSECT
         STM   14,12,12(13)     STANDARD ENTRY
         BASR  12,0
         USING *,12
         ST    13,SAVE+4
         LA    13,SAVE
         L     13,SAVE+4
         WTO   'HELLO'
         WTO   'JUST1'
         LA    5,T1
         WTO   TEXT=(5)
         LM    14,12,12(13)
         LA    15,0
         BR    14
SAVE     DS    18F
T1       DS    0CL6
         DC    H'04'
         DC    C'TEST'
         END   TEST
This worked liked a charm

And as my next try I tried to write to spool

by adding logic like below

Code: Select all

TEST     CSECT
         STM   14,12,12(13)     STANDARD ENTRY
         BASR  12,0
         USING *,12
         ST    13,SAVE+4
         LA    13,SAVE
         L     13,SAVE+4
         WTO   'HELLO'
         WTO   'JUST1'
         OPEN  (SYSOUT,OUTPUT)
         MVC   OUTR,T1
         PUT   SYSOUT,OUTR
         CLOSE SYSOUT
         LM    14,12,12(13)
         LA    15,0
         BR    14
SAVE     DS    18F
T1       DS    0CL6
         DC    H'04'
         DC    C'TEST'
OUTR     DS    CL6
SYSOUT   DCB   DDNAME=SYSOUT,DSORG=PS,MACRF=PM,RECFM=FB,LRECL=80
         END   TEST
Though I see an entry in SYSOUT in spool the job is not ending , Have I triggered a loop here ?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

You are not using standard assembler save area linking, so yes it's possible you've got a loop going. Try changing to:

Code: Select all

TEST     CSECT
         BASR  12,0
         USING *,12
         ST    13,SAVE+4     SAVE BACK CHAIN
         LA    11,SAVE       SET UP FORWARD CHAIN
         ST    11,8(13)      SAVE FORWARD CHAIN
         LR    13,11         SET UP FOR NEXT SAVE AREA CHAIN
         WTO   'HELLO'
         WTO   'JUST1'
         OPEN  (SYSOUT,OUTPUT)
         MVC   OUTR,T1
         PUT   SYSOUT,OUTR
         CLOSE SYSOUT
         L     13,SAVE+4     GET BACK CHAIN
         LM    14,12,12(13)  RESTORE REGISTERS
         LA    15,0
         BR    14
SAVE     DS    18F
T1       DS    0CL6
         DC    H'04'
         DC    C'TEST'
OUTR     DS    CL6
SYSOUT   DCB   DDNAME=SYSOUT,DSORG=PS,MACRF=PM,RECFM=FB,LRECL=80
         END   TEST
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Hi Robert,

I tried your solution it wrote the record to SYSOUT but it is abending with S0C1, I guess it could be something to do with exit is not happening properly not sure though.

PS: Also apologies for replying a bit late I was trying to fix the issue with help of google and I am not successful so far.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

Well no wonder -- I deleted the line to save the registers somehow!

Code: Select all

         BASR  12,0
         USING *,12
         SAVE (14,12)
         ST    13,SAVE+4     SAVE BACK CHAIN
         LA    11,SAVE       SET UP FORWARD CHAIN
         ST    11,8(13)      SAVE FORWARD CHAIN
         LR    13,11         SET UP FOR NEXT SAVE AREA CHAIN
This code has a slight contradiction -- you are using register 12 as a base register and not saving it before doing so, hence the value of register 12 better not be needed by the calling program. A way to keep register 12 from being wiped out:

Code: Select all

TEST     CSECT
         USING TEST,15
         SAVE  (14,12)
         BASR  12,0
         USING *,12
(since register 15 has the address of TEST when the program starts) and continue with the save area chaining code.
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Thanks Robert , It worked :)
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

As you get more into assembler, you might want to use YREGS, SAVE, RETURN macros (they are kept in SYS1.MACLIB so you may need to put //SYSLIB DD DISP=SHR,DSN=SYS1.MACLIB in your assembly JCL -- if you are using a prepared procedure (PROC) this may be already present), or create your own copies of the macros. YREGS does equates on R0 through R9, R10 through R15 to 0 through 15. This allows you to see register usage in your assembler cross-reference. SAVE saves your registers and RETURN restores the registers (and optionally sets a return code) before doing a BR 14 to exit. Learn what the options at the top of the assembly output mean and when to use each -- they can be EXTREMELY helpful in providing information that helps you debug problems.
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Hi Robert,

Yeah, Thanks I am hoping to move on step by step like practising below
- MOVE
- STRING FUNCTIONS
- LOOPS
- CONDITION AND BRANCHING
- FILE OPERATIONS
- ARITHMETIC FUNCTION
- REPORTING
- ADDRESS DB2 CICS ( Again not sure of the feasibility)
- SYSTEM FUNCTION like ( TSO , ISPF , REXX - Not sure if this could be achieved soon But I am determined to Master :)

I might be posting a lot of queries until I master.

Thanks again for your support.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

Also, there is a SNAP macro that can dump memory and / or registers so you don't have to keep using WTO (trust me, operators really don't like superfluous WTO). I'll put together something on its use when I get a chance.
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Hi Robert,

Thats why I was trying to figure out writing to SYSOUT so operators don't need to call me :)
I heard about SNAP I am yet to try that.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Assembler first program failed with S0C1

Post by Robert Sample »

It's fairly easy to use:

Code: Select all

         OPEN  (SNAPOUT,OUTPUT)
         .
         .
         .
         SNAP  DCB=SNAPOUT,ID=000,PDATA=REGS,STORAGE=(start,end)
         .
         .
         .
         CLOSE (SNAPOUT)
         .
         .
         .
SNAPOUT  DCB   DSORG=PS,RECFM=VBA,MACRF=(W),BLKSIZE=1632,LRECL=125,    X
               DDNAME=SNAPPRNT,DCBE=SNAPOUTX
SNAPOUTX DCBE  RMODE31=BUFF
(start,end) represent the starting and ending locations of memory to dump -- you can use addresses (variable names) in your program or registers in parentheses. The DCBE allows the code to run with 24-bit or 31-bit addressing. ID= can have any value from 0 to 255 and allows you to identify which SNAP output is which, as a part of the page header gives you the ID value. The DCB parameters are what they are for a reason, so just code it as you see it here.
User avatar
kingo
Registered Member
Posts: 27
Joined: Mon Jun 04, 2018 10:55 pm

Re: Assembler first program failed with S0C1

Post by kingo »

Sure Robert I will try that :) Thank you
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Assembler & PL/I.”