The following routine illustrates how an assembler routine can handle a program check if one should occur. The following occurs:
SMP1 TITLE 'Sample of main program that registers a handler'
*
* Symbolic Register Definitions and Usage
*
R0 EQU 0 Parameter list address (CMS only)
R1 EQU 1 Parameter list address, 0 if no parms
R10 EQU 10 Base register for executable code
R12 EQU 12 Language Environment Common Anchor Area
* address
R13 EQU 13 Save Area/Dynamic Storage Area address
R14 EQU 14 Return point address
R15 EQU 15 Entry point address
*
* Prologue
*
CEEHDRA CEEENTRY AUTO=DSASIZ, Amount of main memory to obtain
MAIN=YES, This routine is a MAIN program
PPA=PPA1, Program Prolog Area for this routine
BASE=R10 Base register for executable code
* constants, and static variables
USING CEECAA,R12 Common Anchor Area addressability
USING CEEDSA,R13 Dynamic Storage Area addressability
*
* Announce ourselves
*
WTO 'CEEHDRA Says "HELLO"',ROUTCDE=11
*
* Register User Handler
*
LA R1,USRHDLPP Get addr of proc-ptr to Handler rtn
ST R1,PARM1 Make it 1st parameter
LA R1,TOKEN Get addr of 32-bit token
ST R1,PARM2 Make it 2nd parameter
LA R1,0 Omit address for Feedback Code:
* If an error occurs while
* registering the handler,
* Language Environment signals
* the condition, rather than
* passing it back to caller
ST R1,PARM3 Make it 3rd parameter
LA R1,HDLRPLST Point to parameter list for CEEHDLR
CALL CEEHDLR Invoke CEEHDLR callable service AWI
*
* Call subroutine to cause an exception
*
CALL LEASMHD2
*
* Un-Register User Handler
*
LA R1,USRHDLPP Get addr of proc-ptr to Handler rtn
ST R1,HDLUPRM1 Make it 1st parameter
LA R1,FEEDBACK Address for Feedback Code
ST R1,HDLUPRM2 Make it 2nd parameter
LA R1,HDLUPLST Point to parameter list for CEEHDLU
CALL CEEHDLU Invoke CEEHDLU callable service AWI*
* Bid fond farewell
*
WTO 'CEEHDRA Says "GOOD-BYE"',ROUTCDE=11
*
* Epilogue
*
CEETERM RC=4,MODIFIER=1 Terminate program
*
* Program Constants and Local Static Variables
*
USRHDLPP DC V(LEASMHD3),A(0) Procedure-pointer to Handler routine
*
LTORG , Place literal pool here
SPACE 3
PPA1 CEEPPA , Program Prolog Area for this routine
EJECT
*
* Map the Dynamic Storage Area (DSA)
*
CEEDSA , Map standard CEE DSA prologue
*
* Local Automatic (Dynamic) Storage..
*
HDLRPLST DS 0F Parameter List for CEEHDLR
PARM1 DS A Address of User-written Handler
PARM2 DS A Address of 32-bit Token
PARM3 DS A Address of Feedback Code cond token
*
HDLUPLST DS 0F Parameter List for CEEHDLR
HDLUPRM1 DS A Address of User-written Handler
HDLUPRM2 DS A Address of Feedback Code cond token
*
TOKEN DS F 32-bit Token: fullword whose *value* will
* be passed to the user handler each
* time it is called.
*
FEEDBACK DS CL12 Feedback Code condition token
*
DSASIZ EQU *-CEEDSA Length of DSA
EJECT
*
* Map the Common Anchor Area (CAA)
*
CEECAA
END CEEHDRA
HDR2 TITLE 'Sample of subprogram that forces a program check'
*
* Symbolic Register Definitions and Usage
*
R1 EQU 1 Parameter list address, 0 if no parms
R11 EQU 11 Base register for executable code
R12 EQU 12 Language Environment Common Anchor Area
* address
R13 EQU 13 Save Area/Dynamic Storage Area address
R14 EQU 14 Return point address
R15 EQU 15 Entry point address*
* Prologue
*
LEASMHD2 CEEENTRY AUTO=DSASIZ, Amount of main memory to obtain *
PPA=PPA2, Program Prolog Area for this routine *
MAIN=NO, This program is a Subroutine *
NAB=YES, YES because called by enabled rtn *
BASE=R11 Base register for executable code,
* constants, and static variables
USING CEECAA,R12 Common Anchor Area addressability
USING CEEDSA,R13 Dynamic Storage Area addressability
*
* Announce ourselves
* WTO 'LEASMHD2 Says "HELLO"',ROUTCDE=11
*
* Cause Data Exception (Language Environment condition 3207)
*
XC A,A Clear to Binary Zeros
* (not a valid packed number)
AP A,=P'7' Cause Data exception
*
* Say good-bye
*
WTO 'LEASMHD2 Says "GOOD-BYE"',ROUTCDE=11
*
* Epilogue
*
CEETERM RC=0 Terminate program
SPACE 3
*
* Program Constants and Local Static Variables
*
PPA2 CEEPPA , Program Prolog Area for this routine
*
LTORG , Place literal pool here
EJECT
*
* Map the Dynamic Storage Area (CAA)
*
CEEDSA , Map standard CEE DSA prologue
*
* Local Automatic (Dynamic) Storage..
*
A DS PL2 Packed operand (uninitialized)
*
DSASIZ EQU *-CEEDSA Length of DSA
EJECT
*
* Map the Common Anchor Area (CAA)
*
CEECAA
END , of LEASMHD2
SMP3 TITLE 'User-written condition handler'*
* Symbolic Register Definitions and Usage
*
R1 EQU 1 Parameter list address (upon entry)
R2 EQU 2 Work register
R3 EQU 3 Parameter list address (after CEEENTRY)
R4 EQU 4 Will point to Result Code Argument
R10 EQU 10 Will point to Condition Token Argument
R11 EQU 11 Base register for executable code
R12 EQU 12 Common Anchor Area address
R13 EQU 13 Save Area/Dynamic Storage Area address
R14 EQU 14 Return point address
R15 EQU 15 Entry point address
*
* Prologue
*
LEASMHD3 CEEENTRY AUTO=DSASIZ, Amount of main memory to obtain *
PPA=PPA3, Program Prolog Area for this routine *
MAIN=NO, This program is a Subroutine *
NAB=YES, YES--called under Language Env. *
PARMREG=R3, R1 value is saved here *
BASE=R11 Base register for executable code,
* constants, and static variables
USING CEECAA,R12 Common Anchor Area addressability
USING CEEDSA,R13 Dynamic Storage Area addressability
USING UHDLARGS,R3 User Handler Args addressability
*
* Locate Arguments
*
L R10,@CURCOND Get address of Condition Token
USING $CURCOND,R10 Condition Token addressability
L R4,@RESCODE Get address of Result Code
USING $RESCODE,R4 Result Code addressability
*
* Announce ourselves
*
WTO 'LEASMHD3 Says "HELLO"',ROUTCDE=11
*
* Process Condition
*
CLC CURCOND(8),CEE347 Was this handler entered due to the
* condition it was created to
* deal with (data exception) ?
BE BADPDATA Yes -- go process it
* No..
MVC RESCODE,=A(PERCOLAT) Indicate PERCOLATE action
B OUT Return to Language Environment
* condition manager
*
BADPDATA EQU * Processing for data exception:
MVC RESCODE,=A(RESUME) Indicate RESUME action*
* Call CEE3DMP to Dump machine state
*
LA R1,DUMPTITL Get address of Dump Title
ST R1,PARM1 Make it first parameter
LA R1,DUMPOPTS Get address of Dump Options string
ST R1,PARM2 Make it second parameter
LA R1,FC Address of Feedback Code
ST R1,PARM3 Make it third parameter
LA R1,DMPPARMS Point to parameter list for CEE3DMP
CALL CEE3DMP Invoke CEE3DMP callable service AWI
*
* Sign-off
*
OUT EQU *
WTO 'LEASMHD3 Says "GOOD-BYE"',ROUTCDE=11
*
* Epilogue
*
CEETERM RC=0
*
* Program Constants and Local Static Variables
*
DUMPOPTS DC CL256'THR(ALL) BLOCK STORAGE' Dump Options
*
DUMPTITL DC CL80'LEASMHD3 - Sample Dump ' Dump Title
*
PPA3 CEEPPA , Program Prolog Area for this routine
*
LTORG , Place literal pool here
*
* Define Symbolic Value Constants for Condition Tokens
*
CEEBALCT
EJECT
*
* Map Arguments to User-Written Condition Handler
*
UHDLARGS DSECT
@CURCOND DS A Address of CIB
@TOKEN DS A Address of 32-bit token value from CEEHDLR
@RESCODE DS A Address of Result Code
@NEWCOND DS A Address of New Condition
SPACE 3
$CURCOND DSECT , Mapping of the current condition
CURCOND DS A Condition token that identifies the
* current condition being processed
SPACE 3
$TOKEN DSECT , Mapping of the 32-bit Token Argument
TOKEN DS A Value of 32-bit Token from CEEHDLR call
SPACE 3
$RESCODE DSECT , Mapping of Result Code Argument
RESCODE DS F Result Code specifies the action for
* the condition manager to take when
* control returns from the user handler:
RESUME EQU 10 Resume at the resume cursor
* (condition has been handled)
PERCOLAT EQU 20 Percolate to the next condition handler
* (if a Result Code is not explicitly set
* by the handler, this is the default)
PROMOTE EQU 30 Promote to the next condition handler
* (New Condition has been set)
* (See the Language Environment Programming Guide for other result
* code values.)
SPACE 3
$NEWCOND DSECT , Mapping of the New Condition Argument
NEWCOND DS CL12 New Condition (condition token) specifies
* the condition promoted to.
EJECT
*
* Map the Dynamic Storage Area (DSA)
*
CEEDSA , Map standard CEE DSA prologue
*
* Local Automatic (Dynamic) Storage..
*
DMPPARMS DS 0F Parameter list for CEE3DMP
PARM1 DS A Address of Title string
PARM2 DS A Address of Options string
PARM3 DS A Address of Feedback Code
*
FC DS CL12 Feedback Code condition token
*
DSASIZ EQU *-CEEDSA Length of DSA
EJECT
*
* Map the Common Anchor Area (CAA)
*
CEECAA
END , of LEASMHD3