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


Using structured programming macros

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

The complexity of control flow in a program strongly affects its readability, the early detection of coding errors, and the effort needed to modify it later. You can generally simplify control flow (though sometimes at the cost of less efficiency and more redundant code) by restricting the ways in which branches occur. One way to restrict branches is to use only those necessary to implement a few basic structures such as:
  • Executing one of two blocks of code according to a true-false condition
  • Executing a block of code repeatedly until some limit is reached
  • Executing a specific block of code, in a given set, where the block was previously computed

If statements exist for all these structures in a programming language, then they are used exclusively. If some are missing, then simple branches are used to simulate those structures but only in standard patterns. In the case of OS assembler language, only the basic branch and branch-and-link instructions are implemented but macros that simulate the first three structures are available.

The first two structures are sufficient to implement any "proper" program (that is, with one entry point and one exit) if its blocks of code are suitably ordered. It is assumed that the structures may be nested to any depth. The technique of writing programs using only these structures for branching is known as "structured programming".

The standard structured programming figures have been implemented for the assembler language programmer through the following five sets of related macros.
  • The IF macro set:
    • IF
    • ELSE (optional)
    • ELSEIF (optional)
    • ENDIF
  • The DO macro set:
    • DO
    • DOEXIT (optional)
    • ITERATE (optional)
    • ASMLEAVE (optional)
    • ENDDO
  • The CASE macro set:
    • CASENTRY
    • CASE (one must be present)
    • ENDCASE
  • The SEARCH macro set:
    • STRTSRCH
    • EXITIF
    • ORELSE
    • ENDLOOP
    • ENDSRCH
  • The SELECT macro set:
    • SELECT
    • WHEN
    • OTHRWISE (optional)
    • ENDSEL
  • The ASMMREL macro set:
    • ASMMREL

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014