Example 2

Obtain the addresses of the UCBs for all tape devices. The scan should include UCBs for dynamic devices. On each invocation of UCBSCAN, return a UCB address at the address specified by UCBPTR and pin the UCB whose address is returned. After all processing related to each UCB has completed, unpin the UCB.
*
*        .....
*
SETUP    DS    0H
         XC    SCANWORK,SCANWORK             Clear work area
SEARCH   DS    0H
         UCBSCAN ADDRESS,UCBPTR=UCBPTR,WORKAREA=SCANWORK,              X
               DEVCLASS=TAPE,DYNAMIC=YES,PIN,TEXT=TEXTSCAN,            X
               PTOKEN=PTOKSCAN
         LTR   R15,R15                       Has a UCB been returned?
         BNZ   DONE                          No  end of device class
*
*    Process  UCB
*
         UCBPIN UNPIN,PTOKEN=PTOKSCAN
         B     SEARCH
DONE     DS    0H
*
*        .....
*
UCBPTR   DS    F                             UCB copy from SCAN
PTOKSCAN DS    CL8                           Pin Token
SCANWORK DS    CL100                         Work area for UCBSCAN
TEXTSCAN DC    CL58'PIN TEXT FOR UCBSCAN'    Pin Text