bdfs1m1hStructured Programming Macros

LEAVE-Exit from a DO Loop

Use this macro to exit a DO loop when the condition being tested by the corresponding CASE, IF, or SELECT macro is true.

Format




level
is a self-defining term or SETA assembler variable equal to the number of DO loop nesting levels to leave. For example, if a DO loop contains a nested DO loop, coding LEAVE 2 in the inner DO loop causes processing to branch to the outer ENDDO macro, which ends the outer DO loop. If you do not specify level, the default is 1; that is, a branch is taken to the end of the innermost DO loop that contains the LEAVE macro.

Entry Requirements

You must code this macro between a DO and ENDDO macro group and after a CASE, IF-THEN, or SELECT macro statement.

Return Conditions

When the condition being tested for is true, LEAVE causes processing to continue with the next sequential instruction following the ENDDO statement of the current DO-ENDDO block, or as many levels of DO-ENDDO blocks as specified by the level parameter.

Programming Considerations

None.

Examples

This example sets up a DO loop to add 1 to the contents of R1 10 times. When the value of control variable LPCNT exceeds 8, the IF statement is true and the LEAVE macro is processed. This causes processing to continue with R1 equal to 8 beginning after the ENDDO statement.

         LA R1,0
         DO LPCNT,=,1,TO,10
            IF LPCNT,GT,8
              THEN
                 LEAVE ,
            ENDIF
         LA R1,1(,R1)
         ENDDO
 

Related Macros