|
View previous topic :: View next topic
|
| Author |
Message |
ryanh
New User
Joined: 13 Feb 2023 Posts: 7 Location: singapore
|
|
|
|
Hi all,
Sorry for this dumb question, I've been stuck for several days without any progress.
I am completely new to mainframe, and it took me about a week to setup Hercules etc. The zos version I used in Hercules is zos V1R5.
I then logged in TSO, my assembler code is as follows,
| Code: |
HELLO CSECT
USING HELLO,15
SAVE (14,12)
OPEN (SYSUT1)
GET SYSUT1,INBUF
CLOSE (SYSUT1)
RETURN (14,12),RC=0
SYSUT1 DCB DSORG=PS,MACRF=(GM),DDNAME=IN,RECFM=FB, C
LRECL=80,BLKSIZE=3120
INBUF DS CL80
END
|
This simple program just opens a file and reads in a record and then closes it.
I compile this program as follows (sorry that I am not comfortable with JCL and job submission, it's so troublesome, editing in TSO is also a lot of trouble and it's so hard to correct the errors).
In TSO, enter the following commands:
| Code: |
ALLOCATE F(SYSIN) DA(TEST01.ASM) SHR REUSE
ALLOCATE F(SYSLIB) DA(SYS1.MACLIB SYS1.MODGEN) SHR REUSE
ALLOCATE F(SYSPRINT) DA(*) REUSE
ALLOCATE DA(TEST01.OBJ) NEW TRACKS SPACE(3,3) BLKSIZE(80)LRECL(80) RECFM(F B) CATALOG REUSE
ALLOCATE F(SYSLIN) DA(TEST01.OBJ)
CALL *(ASMA90)
LINK TEST01.OBJ
ALLOCATE DA(TEST01.DATA) NEW DSORG(PS) LRECL(80) RECFM(F B) BLKSIZE(3120)
ALLOCATE F(SYSUT1) DA(TEST01.DATA)
CALL TEST01
|
The last line CALL TEST01 failed with S0C4 Reason code=11 error.
The program also seems to modify the attributes of SYSUT1 (TEST01.DATA) file (dataset).
If I LISTDS TEST01.DATA, it shows LRECL=80 AND BLKSIZE=3120, but if I run "CALL TEST01" several times (always fails), the attribute of TEST01.DATA changed, if I run LISTDS TEST01.DATA, it shows LRECL=3120 BLKSIZE=3120.
It seems that the program accesses into wrong bits of the files and even sometimes unintentionally modifies the file.
Can any one give me any hints what shall I do to figure out where's wrong?
Thanks a lot. |
|
| Back to top |
|
 |
Willy Jensen
Active Member

Joined: 01 Sep 2015 Posts: 772 Location: Denmark
|
|
|
|
| my guess is that the program has been linked as rmode 31. Try adding RMODE(24) to the LINK command. |
|
| Back to top |
|
 |
ryanh
New User
Joined: 13 Feb 2023 Posts: 7 Location: singapore
|
|
|
|
| Willy Jensen wrote: |
| my guess is that the program has been linked as rmode 31. Try adding RMODE(24) to the LINK command. |
Sorry, I tried LINK TEST.OBJ AMODE(24) just now, and it didn't work.
Actually I think the DCB works fine. Because I tried the following program and it works and print out 'TEST(SYSUT1)'.
| Code: |
HELLO CSECT
USING HELLO,15
SAVE (14,12)
MVC WTO+13(6),SYSUT1+40
WTO WTO 'TEST( )'
RETURN (14,12),RC=0
SYSUT1 DCB DSORG=PS,MACRF=(GM),DDNAME=SYSUT1,RECFM=FB,LRECL=80, C
BLKSIZE=3120
INBUF DS CL80
END
|
The problem is when I try to open SYSUT1, there will be various errors (The errors I encounted includes S0C4-11, S0C6-06 and S0C1-01).
The open statement alone will cause error (comment out all other GET/PUT and CLOSE). |
|
| Back to top |
|
 |
ryanh
New User
Joined: 13 Feb 2023 Posts: 7 Location: singapore
|
|
|
|
I tried to change DDNAME from SYSUT1 to a shorter name IN (because I suspect DDNAME is max 5 bytes).
Now Open statement works fine, and the TEST01.DATA attribute will not be modifed by 'CALL TEST01' any more.
However, the GET IN,INBUF statement still causes abend S0C4-11, if comment out GET, the CLOSE statement still causes abend S0C1-01.
And if comment out GET and CLOSE, only OPEN and then return, the program returns successfully without errors. |
|
| Back to top |
|
 |
Willy Jensen
Active Member

Joined: 01 Sep 2015 Posts: 772 Location: Denmark
|
|
|
|
| DDname is max 8 bytes. Your program does not have a save area. Start by adding that. And it still must be linked as rmode(24). Your 2nd program does not do any I/O so is not relevant. |
|
| Back to top |
|
 |
ryanh
New User
Joined: 13 Feb 2023 Posts: 7 Location: singapore
|
|
|
|
| Willy Jensen wrote: |
| DDname is max 8 bytes. Your program does not have a save area. Start by adding that. And it still must be linked as rmode(24). Your 2nd program does not do any I/O so is not relevant. |
Thanks a lot for the help. Now it's the update:
The following program Open (IN) only, and no GET, no CLOSE,
abend error S0C1-01
| Code: |
00010 HELLO CSECT
00020 USING HELLO,15
00030 SAVE (14,12)
00040 ST 13,SAVE+4
00050 LR 12,13
00060 LA 13,SAVE
00070 ST 13,8(12)
00080 BC 15,START
00090 SAVE DC 18F'0'
00100 END DS 0H
00110 L 13,SAVE+4
00120 RETURN (14,12),RC=0
00130 START DS 0H
00140 OPEN (IN)
00150 BC 15,END
00160 IN DCB DSORG=PS,DDNAME=IN,RECFM=FB,LRECL=80,BLKSIZE=3120, C
00170 MACRF=(GM)
00180 INBUF DS CL100
00190 END
IKJ52500I END OF DATA
|
The following program, Open works, No Get, but Close returns abend S0C1-01.
| Code: |
00010 HELLO CSECT
00020 USING HELLO,15
00030 SAVE (14,12)
00040 OPEN (IN)
00050 CLOSE (IN)
00060 RETURN (14,12),RC=0
00070 IN DCB DSORG=PS,DDNAME=IN,RECFM=FB,LRECL=80,BLKSIZE=3120, C
00080 MACRF=(GM)
00090 INBUF DS CL100
00100 END
IKJ52500I END OF DATA
|
The following program, Open works, Get returns abend S0C4-11
| Code: |
00010 HELLO CSECT
00020 USING HELLO,15
00030 SAVE (14,12)
00040 OPEN (IN)
00045 GET IN,INBUF
00050 CLOSE (IN)
00060 RETURN (14,12),RC=0
00070 IN DCB DSORG=PS,DDNAME=IN,RECFM=FB,LRECL=80,BLKSIZE=3120, C
00080 MACRF=(GM)
00090 INBUF DS CL100
00100 END
IKJ52500I END OF DATA
|
|
|
| Back to top |
|
 |
dneufarth
Active User

Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
| Try using a base register from 2 thru 11. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2272 Location: USA
|
|
|
|
RTFM:
www.ibm.com/docs/en/zos/2.1.0?topic=services-register-use
| Quote: |
| Note that the system uses ARs 0, 1, 14, and 15 as work registers for every service, regardless of whether the caller is in primary or AR address space control (ASC) mode. The system does not use ARs 2 through 13 for any service. |
|
|
| Back to top |
|
 |
ryanh
New User
Joined: 13 Feb 2023 Posts: 7 Location: singapore
|
|
|
|
| dneufarth wrote: |
| Try using a base register from 2 thru 11. |
Thanks! It works finally. |
|
| Back to top |
|
 |
ryanh
New User
Joined: 13 Feb 2023 Posts: 7 Location: singapore
|
|
|
|
| sergeyken wrote: |
RTFM:
www.ibm.com/docs/en/zos/2.1.0?topic=services-register-use
| Quote: |
| Note that the system uses ARs 0, 1, 14, and 15 as work registers for every service, regardless of whether the caller is in primary or AR address space control (ASC) mode. The system does not use ARs 2 through 13 for any service. |
|
Thanks. It works finally with the following code.
It seems to be register problem, though I still don't know why.
| Code: |
00010 HELLO CSECT
00020 LR 2,15
00030 USING HELLO,2
00040 SAVE (14,12)
00050 ST 13,SAVE+4
00060 BC 15,START
00070 SAVE DC 18F'0'
00080 END DS 0H
00090 L 13,SAVE+4
00100 RETURN (14,12),RC=0
00110 START DS 0H
00120 OPEN (IN)
00130 GET IN,INBUF
00140 CLC INBUF(6),=C'AAABBB'
00150 BE EQUAL
00160 WTO 'NOT EQUAL'
00170 EQUAL WTO 'EQUAL'
00180 CLOSE (IN)
00190 BC 15,END
00200 IN DCB DSORG=PS,DDNAME=IN,RECFM=FB,LRECL=80,BLKSIZE=3120, C
00210 MACRF=(GM)
00220 INBUF DS CL100
00230 END
IKJ52500I END OF DATA
|
|
|
| Back to top |
|
 |
ryanh
New User
Joined: 13 Feb 2023 Posts: 7 Location: singapore
|
|
|
|
Probably becauses OPEN changes register 15 and only restores on CLOSE? This will cause the current USING HELLO,15 fail?
I change USING HELLO,15 to USING HELLO,2 , and everything works fine then. |
|
| Back to top |
|
 |
Willy Jensen
Active Member

Joined: 01 Sep 2015 Posts: 772 Location: Denmark
|
|
|
|
Great. Note that you will get 2 WTOs for an not equal situation as you don't jump around the 'EQUAL' WTO after the NOT EQUAL one. Also, BC 15,somewhere would look nicer (I think) if you use the extended mnemonics there too, i.e. B Start.
In general I would avoid BLKSIZE in DCBS, they override JCL and allocations, so might end up damaging your dataset, especially for an output DCB.
Keep up the good work. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2272 Location: USA
|
|
|
|
| ryanh wrote: |
| Probably becauses OPEN changes register 15 and only restores on CLOSE? This will cause the current USING HELLO,15 fail? |
Not "probably" but "for sure".
This is one of the basic postulates for anyone who has ever started reading some docs on Assembler programming...  |
|
| Back to top |
|
 |
dneufarth
Active User

Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
@ryanh,
As @sergeyken pointed out, registers 0,1,14,15 are best avoided whenever your code uses a macro (SAVE, DCB, WTO?) that IBM supplies and as base registers. The code in macros by convention may/probably utilize those registers. You must use them at times to follow IBM conventions.
FYI - I used them in very tight code blocks where I was certain execution was not interfacing with I/O and other calls to operating system services. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10900 Location: italy
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10900 Location: italy
|
|
|
|
sorry for the duplicate link |
|
| Back to top |
|
 |
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1054 Location: Richmond, Virginia
|
|
|
|
I retired quite a while back, but I still enjoy perusing this excellent forum (although I am familiar with less and less of the tech details!).
It has been a pleasure reading this posting.
It is a model for exchanges between a new user and the expert community.
Good luck ryanh in your career. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|