PL/I handling a divide-by-zero condition

The following example shows the PL/I program that performs the tasks in Handling a divide-by-zero condition in C, C++, COBOL, or PL/I.
*Process macro;
 /* Module/File Name: IBMHDLR                        */
 /****************************************************/
 /*                                                  */
 /*  EXCOND               .-> DIVZERO                */
 /*  - register handler   |   - force a divide-by-0  */
 /*  - call DIVZERO     --'                          */
 /*  ==> "resume point"                              */
 /*  - unregister handler                            */
 /*                         USRHDLR:                 */
 /*                         - if divide-by-zero then */
 /*                           - move resume cursor   */
 /*                           - resume at "resume"   */
 /*                                          point   */
 /*                                                  */
 /****************************************************/
 Excond :Proc Options(Main);

   /**************************************************/
   /* Important elements are found in these includes */
   /* - feedback declaration                         */
   /* - fbcheck macro call                           */
   /* - condition tokens such as CEE000              */
   /* - entry declarations such as ceehdlr           */
   /**************************************************/

   %include ceeibmct;
   %include ceeibmaw;

   dcl Usrhdlr external entry;

   dcl 1 fback feedback;
   dcl divisor fixed bin(31);
   dcl token   fixed bin(31);

   /*********************************************/
   /* Register a user-written condition handler */
   /*********************************************/
   token = 97;
   Call ceehdlr(Usrhdlr, token, fback);
   If fbcheck (fback, cee000) then
     display ('MAIN: registered USRHDLR');
   else
     do;
       display ('CEEHDLR failed with message number ' ||
                 fback.MsgNo);
       stop;
     end;
   /*********************************************/
   /* Call DIVZERO to divide by zero            */
   /*  and drive USRHDLR                        */
   /*********************************************/
   divisor = 0;
   call divzero (divisor);
   display ('MAIN: resumption after DIVZERO');

   /*********************************************/
   /* Unregister the user condition handler     */
   /*********************************************/

   Call ceehdlu (Usrhdlr, fback);
   If fbcheck (fback, cee000) then
     display ('MAIN: unregistered USRHDLR');
   else
     do;
       display ('CEEHDLU failed with message number ' ||
                 fback.MsgNo);
       stop;
     end;

     /*********************************************/
     /* Subroutine that simply raises ZERODIVIDE  */
     /*********************************************/
     divzero: proc (arg);
       dcl arg fixed bin(31);

       display('  DIVZERO: starting.');
       arg = 1 / arg;
       display('  DIVZERO: Returning to its caller');

     end divzero;

 end Excond;
The following example is the usrhdlr program (PL/I) to handle divide-by-zero conditions.
*Process macro;
 /* Module/File Name: IBMMRCR                        */
 /****************************************************/
 /*                                                  */
 /* Usrhdlr - the user handler routine.              */
 /* Handle DIVIDE-BY-ZERO conditions,                */
 /*     percolate all others.                        */
 /*                                                  */
 /****************************************************/
 Usrhdlr:  Proc (@condtok, @token, @result, @newcond)
           options(byvalue);

   %include ceeibmct;
   %include ceeibmaw;

   /* Parameters */
   dcl  @condtok    pointer;
   dcl  @token      pointer;
   dcl  @result     pointer;
   dcl  @newcond    pointer;
   dcl 1 condtok based(@condtok) feedback;
   dcl token  fixed bin(31) based(@token);
   dcl result fixed bin(31) based(@result);
   dcl 1 newcond based(@newcond) feedback;
   dcl 1 fback feedback;
   dcl move_type fixed bin(31);
   dcl resume     fixed bin(31) static initial(10);
   dcl percolate  fixed bin(31) static initial(20);
   dcl promote    fixed bin(31) static initial(30);
   dcl promote_sf fixed bin(31) static initial(31);
   display ('>>> USRHDLR: Entered user handler');
   display ('>>> USRHDLR: passed token value is ' ||
            token);

   /* Check if this is the divide-by-zero token */
   if fbcheck (condtok, cee349) then
     do;
       move_type = 0;
       call ceemrcr (move_type, fback);
       If fbcheck (fback, cee000) then
         do;
           result = resume;
           display ('>>> USRHDLR: Resuming execution');
         end;
       else
         do;
           display
           ('CEEMRCR failed with message number ' ||
             fback.MsgNo);
           stop;
         end;
     end;
   else     /* something besides div-zero token */
     do;
       result = percolate;
       display ('>>> USRHDLR: Percolating it');
     end;
 end Usrhdlr;