S0C1 abend when adding numbers in an array



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

S0C1 abend when adding numbers in an array

Postby monica1 » Tue Jan 17, 2017 9:20 am

Hi,

I am trying to work on an array program to understand the concepts of array processing in Assembler.

Given below is the array program to add the numbers in an array.

* ADD NUMBERS IN AN ARRAY        
ADDARR   CSECT                    
         BALR 12,0                
         USING *,12              
         USING TNUMSECT,6        
         BAL 11,ADDRTN            
         WTO 'DISPLAY1'          
         OPEN (OUTDCB,(OUTPUT))  
         UNPK OUTNUM,TOT          
         OI OUTNUM+1,X'F0'        
         PUT OUTDCB,OUTAREA      
         WTO 'DISPLAY9'          
         CLOSE (OUTDCB)          
         B EXIT                  
ADDRTN   ST 11,ADDSAVE            
         WTO 'DISPLAY2'          
         LA 6,TNUMTABL        
         LA 3,ENUM#ENT        
MOREENT  DS 0H                
         WTO 'DISPLAY3'      
         AP TOT,TNUMCODE      
         LA 6,ENUMLEN(,6)    
         BCT 3,MOREENT        
ADDEXIT  DS 0H                
         WTO 'DISPLAY4'      
         L 11,ADDSAVE        
         BR 11                
EXIT     L 13,SAVE+4          
         WTO 'DISPLAY10'      
         LM 14,12,12(13)      
         WTO 'DISPLAY11'      
         XR 15,15            
         WTO 'DISPLAY12'      
         BR 14                                                          
         WTO 'DISPLAY13'                                                
* DECLARATIONS                                                          
ADDSAVE  DC F'0'                                                        
SAVE     DS 18F                                                        
TOT      DC PL2'0'                                                      
OUTDCB   DCB DSORG=PS,MACRF=(PM),DDNAME=TESTOUT,                       X
               RECFM=FB,LRECL=80,BLKSIZE=0                              
OUTAREA  DS 0CL80                                                      
OUTNUM   DS CL2                                                        
FILLER1  DS CL78' '                                                    
* TABLE DECLARATION                                                    
TNUMTABL DS 0H                                                          
         DC PL2'15'                                                    
ENUMLEN  EQU (*-TNUMTABL)                                              
         DC PL2'12'                                                    
         DC PL2'09'                                                    
         DC PL2'16'                  
         DC PL2'05'                  
ENUMTLEN EQU (*-TNUMTABL)            
ENUM#ENT EQU (ENUMTLEN/ENUMLEN)      
* DSECT ENTRY FOR TABLE              
TNUMSECT DSECT                      
TNUMENTY DS 0PL2                    
TNUMCODE DS PL2                      
ENUMENTY EQU (*-TNUMSECT)            
         END


When I am running this program, I am able to see the result in the output file but the job abends with S0C1 abend.

Below is the output file.

****** ***************************** Top of Data ******************************
000001 57                                                                      
****** **************************** Bottom of Data ****************************


I am able to see the display till DISPLAY10 in spool but not able to see the displays later on which means there is a problem with the statement LM 14,12,12(13) .

Could you help me out in understanding if we need to add anything specific when working with arrays?

Thank you.
monica1
 
Posts: 7
Joined: Mon Jan 16, 2017 8:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: S0C1 abend when adding numbers in an array

 

Re: S0C1 abend when adding numbers in an array

Postby steve-myers » Tue Jan 17, 2017 9:34 am

I hope you realized WTO will alter registers 14 through 1.

In general, you should assume all macros will alter registers 14, 15, 0 and 1
steve-myers
Global moderator
 
Posts: 1932
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 206 times

Re: S0C1 abend when adding numbers in an array

Postby monica1 » Tue Jan 17, 2017 9:52 am

I used WTO to understand how the control is flowing and where exactly the error is coming up. Is there any other way other than WTO inorder to debug the program without altering the register contents?
monica1
 
Posts: 7
Joined: Mon Jan 16, 2017 8:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: S0C1 abend when adding numbers in an array

Postby Robert Sample » Tue Jan 17, 2017 10:08 am

Is there any other way other than WTO inorder to debug the program without altering the register contents?
The SNAP macro allows you to print memory locations and / or registers to an output file.
Robert Sample
Global moderator
 
Posts: 3507
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 248 times

Re: S0C1 abend when adding numbers in an array

Postby prino » Tue Jan 17, 2017 10:08 am

monica1 wrote:I used WTO to understand how the control is flowing and where exactly the error is coming up. Is there any other way other than WTO inorder to debug the program without altering the register contents?

Use IBM's Debug Tool.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 562
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 24 times

Re: S0C1 abend when adding numbers in an array

Postby steve-myers » Tue Jan 17, 2017 10:30 am

Most shops discourage the use of WTO as you're using it to track program flow. There are simply too many totally useless messages flooding operator consoles for operators to pick out important messages.

Look at what happens with this sequence

WTO 'RESTORING REGISTERS'
L 13,4(,13)
LM 14,12,12(13)
WTO 'RETURNING
SR 15,15
BR 14

Now, look at the expansion of WTO 'RETURNING'

BAL 1,*+18
DC AL2(13,0),C'RETURNING'
DC 0H'0'
SVC 35

The purpose of the BAL instruction is to store the address of the message into register 1. The message starts with the DC AL2... instruction. It also branches to the next instruction to execute, the SVC 35 instruction. BAL is an RX type instruction, which means it uses a base register. Well, guess what? the LM 14,12 just wiped out your base register, so it's rather hard to predict where the BAL will actually branch to.

By the way, I invented the expansion, but it's probably pretty close to the real expansion.

OS/360 had a batch facility called Testtran for batch debugging. It was hard to use, and really not that useful. IBM killed Testtran when they added TSO, and turned the Testtran break in facility over to TSO for TSO TEST. TSO TEST, which lets you test most unauthorized programs from your TSO terminal has many flaws, but after you learn it you will rarely test a program in batch
steve-myers
Global moderator
 
Posts: 1932
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 206 times

Re: S0C1 abend when adding numbers in an array

Postby monica1 » Tue Jan 17, 2017 11:31 am

I had missed to include the below statements at the beginning of the program.

STM 14,12,12(13)

ST 13,SAVE+4
LA 13,SAVE

Screenshot of how I included these in the program is shown below.

* ADD NUMBERS IN AN ARRAY                
ADDARR   CSECT                          
         STM 14,12,12(13)                
         BALR 12,0                      
         USING *,12                      
         USING TNUMSECT,6                
         ST 13,SAVE+4                    
         LA 13,SAVE                      
MAINPGM  OPEN (OUTDCB,(OUTPUT))


Once these instructions were added, the program ran fine.

Thanks everyone for your help.
monica1
 
Posts: 7
Joined: Mon Jan 16, 2017 8:27 am
Has thanked: 0 time
Been thanked: 0 time


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post