This is my first attempt at re-entrant coding. The idea behind this program is to just open a PS file and get the data out of it.
Code:
TEST0016 CSECT
YREGS
BAKR R14,0
LR R7,R15
USING TEST0016,R7
*
GETMAIN R,LV=WORKLEN
LR R4,R1
USING WORKAR,R4
MVC IN(SIZE_INDCB),INDCB
MVC OPENWK(SIZE_OPN),OPENS
MVC CLOSWK(SIZE_CLO),CLOSES
GETMAIN R,LV=80
LR R3,R1
OPEN (IN),MF=(E,OPENWK)
*
LOOP1 DS 0H
GET IN,(3)
B LOOP1
DONE CLOSE (IN),MF=(E,CLOSWK)
FREEMAIN R,LV=80,A=(R3)
FREEMAIN R,LV=WORKLEN,A=(R4)
PR
INDCB DCB DSORG=PS,MACRF=GM,DCBE=IN_DCBE,DDNAME=INDD
SIZE_INDCB EQU *-INDCB
IN_DCBE DCBE EODAD=DONE,RMODE31=BUFF
OPENS OPEN (,,),MF=L
SIZE_OPN EQU *-OPENS
CLOSES CLOSE (,,),MF=L
SIZE_CLO EQU *-CLOSES
WORKAR DSECT
IN DS XL(SIZE_INDCB)
OPENWK DS XL(SIZE_OPN)
CLOSWK DS XL(SIZE_CLO)
WORKLEN EQU *-WORKAR
END
This is giving me a S0C4 error saying as below.
Code:
********************************************************************************
*********************** P O I N T O F F A I L U R E **********************
********************************************************************************
This supervisor call (SVC) in CSECT TEST0016 resulted in the S0C4 abend.
NOTE: Source code information for CSECT TEST0016 could not be presented because
no compiler listing or side-file data sets were provided.
Load Module Name. . . . . . : M11130.SYSASM.LOADLIB(TEST0016)
At Address. . . . . . . . : 00007EC0
Load Module Length. . . . : X'140'
Link-Edit Date and Time . : 2011/04/07 11:57:53
Instructions around point of failure:
Offset Hex Instruction
------ -------------- ---------------------------------------------------
-32 D25F 4000 7094 MVC 0(96,R4),148(R7)
-2C D207 4060 712C MVC 96(8,R4),300(R7)
-26 D207 4068 7134 MVC 104(8,R4),308(R7)
-20 4100 0050 LA R0,80
-1C 4510 7032 BAL R1,50(,R7)
-18 0A0A SVC 10 (FREEMAIN GETMAIN)
-16 1831 LR R3,R1
-14 4110 4060 LA R1,96(,R4)
-10 43E1 0000 IC R14,0(R1)
-C 4100 4000 LA R0,0(,R4)
-8 5001 0000 ST R0,0(R1)
-4 42E1 0000 STC R14,0(R1)
***** 0A13 SVC 19 (OPEN)
+2 4110 4000 LA R1,0(,R4)
+6 1803 LR R0,R3
+8 1FFF SLR R15,R15
+A BFF7 1031 ICM R15,7,49(R1)
+E 05EF BALR R14,R15
+10 47F0 704C BC 15,76(,R7)
+14 4110 4068 LA R1,104(,R4)
Program Status Word (PSW) . : 078D0000 00007F0C
General Purpose Registers:
R0: 00006EF0 (4368 bytes of storage addressable)
R1: 00006F50 (4272 bytes of storage addressable)
R2: 00000040 (1984 bytes of storage addressable)
R3: 00006EA0 (4448 bytes of storage addressable)
R4: 00006EF0 (4368 bytes of storage addressable)
R5: 009FF350 (3248 bytes of storage addressable)
R6: 009B5FE0 (303136 bytes of storage addressable)
R7: 00007EC0 (Module TEST0016 CSECT TEST0016 + X'0')
R8: 009FC010 (16368 bytes of storage addressable)
R9: 009C7CC8 (230200 bytes of storage addressable)
R10: 00000000 (2048 bytes of storage addressable)
R11: 009FF350 (3248 bytes of storage addressable)
R12: 8802DCA2 (Module IEFSD060 + X'9CA2')
R13: 00006F60 (4256 bytes of storage addressable)
R14: 80FD8800 (151816192 bytes of storage addressable)
R15: 00000000 (2048 bytes of storage addressable)
<H2> EVENT 2 OF 2: ABEND S0C4
Abend Code. . . . . . . . . : S0C4-X'4'
Program-Interruption Code . : 0004 (Protection Exception)
An attempt was made to access a protected storage
location using an incorrect storage access key.
I came across the concept of re-entrant programs in assembler couple of weeks back. Ever since, I am trying to get myself accustomed to all the norms of re-entrant programs. I am sure this is something that experienced programmers would do, but I feel it would be real good if such programming technique could be made as a habit. I could not see any drawbacks in such a technique. I request your assitance to get me introduced to this concept of programming.
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
Try changing -
Code:
BAKR R14,0
to -
Code:
BALR R15,0
And -
Code:
USING TEST0016,R7
to -
Code:
USING *,R7
and see if this makes a difference.
Also, before the BALR, add -
Code:
SAVE (14,12)
And, substitute -
Code:
PR
with -
Code:
RETURN (14,12),RC=(15)
You've omitted allocating a reentrant area for your 18-word RSA (Register Save Area), which is standard practice, possibly due to the misinterpretation of BAKR.
otherwise if literals are used in the program later then they will, by default, be added after the end of the program and will be addressed by R4 because of
Code:
USING WORKAR,R4
And this may produce unpredictable results at runtime