HLASM Toolkit Feature User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


The SEARCH macro set

HLASM Toolkit Feature User's Guide
GC26-8710-10

The SEARCH macro set is provided to allow more complex loops to be coded. All of the operands noted above for DO loops may also be used on the STRTSRCH macro.

The flowchart for the SEARCH macro set is:
       ┌─────────────────←───────────────────────────┐
       ↓                                             ↑  not finished
       │                                        ┌────┴────┐
       │   ┌───┐   ┌───────────┐ false  ┌───┐   │test for │   ┌───┐
──────→┴─→─┤ A ├─→─┤ EXITIF (x)├─→──────┤ C ├─→─┤end loop ├─→─┤ D ├─→─┬──→
STRTSRCH   └───┘   └─────┬─────┘        └───┘   │condition│   └───┘   ↑
                         ↓ true         ORELSE  └─────────┘  ENDSRCH  │
                      ┌──┴──┐                     ENDLOOP             │
                      │  B  ├─────────────────────────────────────→───┘
                      └─────┘
The general structure of the SEARCH macro set is:
        STRTSRCH  (any DO-type loop operands)
          Process Code A
        EXITIF    (any IF-type operands)
          Process Code B
        ORELSE
          Process Code C
        ENDLOOP
          Process Code D
        ENDSRCH

Multiple EXITIFs are permissible. However, for each EXITIF, an ORELSE must appear at some point in the code before the next EXITIF. However, the last ORELSE (the one before the ENDLOOP macro) is optional.

For example:
        STRTSRCH  UNTIL=(TM,0(R4),X'55',NO),WHILE=(CH,R9,LT,=H'58')
          Process A
        EXITIF CC=8
          Process B
        ORELSE
          Process C
        ENDLOOP
          Process D
        ENDSRCH
produces:
        STRTSRCH UNTIL=(TM,0(R4),X'55',NO),WHILE=(CH,R9,LT,=H'58')
#@LB3     DC    0H
          CH    R9,=H'58'
          BC    15-4,#@LB2
          Process A
        EXITIF CC=8
           BC   15-8,#@LB9
           Process B
         ORELSE
           BC   15,#@LB1
#@LB9      DC   0H
           Process C
         ENDLOOP
#@LB6      DC   0H
           TM   0(R4),X'55'
           BC   15-14,#@LB3
#@LB2      DC   0H
           Process D
         ENDSRCH
#@LB1      DC   0H
Another example:
        STRTSRCH  WHILE=(CLM,R2,M1,GE,D2(B2)),UNTIL=P
*       No Process A
        EXITIF  Z,AND,                                               X
          LTR,R2,R3,O,ORIF,                                          X
          (CLC,DEC(L,B),EQ,=C'WORD'),AND,                            X
          NP
          Process B
        ORELSE
          Process C
        EXITIF  CC=5
          Process D
        ENDLOOP
          Process E
        ENDSRCH
produces:
        STRTSRCH  WHILE=(CLM,R2,M1,GE,D2(B2)),UNTIL=P
#@LB3     DC    0H
          CLM R2,M1,D2(B2)
          BC    15-11,#@LB2
*         No Process A
        EXITIF  Z,AND,                                                X
              LTR,R2,R3,O,ORIF,                                       X
              (CLC,DEC(L,B),EQ,=C'WORD'),AND,                         X
          NP
          BC    15-8,#@LB9
          LTR   R2,R3
          BC    1,#@LB10
#@LB9     DC    0H
          CLC   DEC(L,B),=C'WORD'
          BC    15-8,#@LB11
          BC    15-13,#@LB11
#@LB10    DC    0H
          Process B
        ORELSE
          BC    15,#@LB1
#@LB11    DC    0H
          Process C
        EXITIF  CC=5
          BC    15-5,#@LB12
          Process D
        ENDLOOP
          BC    15,#@LB1
#@LB12    DC    0H
#@LB6     DC    0H
          BC    15-2,#@LB3
#@LB2     DC    0H
          Process E
        ENDSRCH
#@LB1     DC    0H

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014