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


Leaving a nested DO

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

It is possible to leave a nested DO macro by specifying a label on the DO macro and the same label as a parameter on a contained ASMLEAVE macro. Here is the flowchart for this structure:
              ┌─←─────────────────────────────────────────────←─┐Not Done
              │              ┌──Loop Body───┐                   ↑
┌──┐  ┌────┐  ↓  ┌─────┐True :              :    ┌─────┐False┌──┴──┐Done ┌─────┐
│DO├─→│Init├─→┴─→┤WHILE├───→ :  some code   :─→──│UNTIL├────→┤Count├─→┬─→┤ENDDO│
└──┘  └────┘     │Test │     :              :    │Test │     │Test │  ↑  └─────┘
                 └──┬──┘     : ┌──────────┐ :    └──┬──┘True └─────┘  │
                    │ False  : │ ASMLEAVE ├───→─┬───┴────────────────→┤
                    │        : └──────────┘ :   └──→ outer ENDDO      │
                    ↓        └──────────────┘                         │
                    └──────────────────────────→─────────────────────→┘

If a label is not specified, then the current macro is exited.

In the following example, asmleave loop breaks from the inner DO loop to the end of the outer (labeled) DO loop, while the asmleave without a label just breaks to the end of the current DO loop:
  loop   do while=2
          do while=4
            mvc a,d
            if (clc,a,eq,b)
               asmleave loop
            else
               asmleave
            endif
          enddo
        enddo
produces:
 loop     do while=2
+loop     DC    0H
+         BC    15,#@LB2
+#@LB3    DC    0H
           do while=4
+         BC    15,#@LB7
+#@LB8    DC    0H
             mvc a,d
             if (clc,a,eq,b)
+              clc             a,b
+         BC    15-8,#@LB11
                asmleave loop
+         BC    15,#@LB1
             else
+         BC    15,#@LB13
+#@LB11   DC    0H
                asmleave
+         BC    15,#@LB6
             endif
+#@LB13   DC    0H
           enddo
+#@LB7    DC    0H
+         BC    4,#@LB8
+#@LB6    DC    0H
         enddo
+#@LB2    DC    0H
+         BC    2,#@LB3
+#@LB1    DC    0H

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014