Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
The CASE macro set HLASM Toolkit Feature User's Guide GC26-8710-10 |
|
The CASE macro set selects one of a set of functions for execution, depending on the value of an integer found in a specified register. The determination of which of the functions is to be executed involves the use of either an address vector (sequence of addresses) or a branch vector (sequence of branch instructions). The flowchart for the CASE program figure is:
↓ ┌────┴────┐ │ │ │ IF(i) │ │ │ └────┬────┘ ↓ ┌─────┐ │i=1 │ │ ├─────→────┤ F1 ├─→───┐ │ │ │ │ │ └─────┘ │ ↓ │ │ ┌─────┐ │ │i=2 │ │ │ ├─────→────┤ F2 ├─→───┼───→ │ │ │ │ │ └─────┘ │ ↓ │ │ ┌─────┐ │ │i=m │ │ │ └─────→────┤ Fm ├─→───┘ │ │ └─────┘ The macro is written like this:
Notes:
Where the case numbers a, b, …, t are either members of a set of integers greater than zero, or nonzero multiples of a power of 2 (for example, 4, 12, and 16). Zero (0) is not a valid case number. Rx is a positional operand that specifies a general register containing the case number. The keyword operands POWER and VECTOR are optional. The operand POWER=n (where n is an integer) refers to a power of 2 and indicates that the case numbers are multiples of that power of 2. Thus, POWER=3 indicates that the case numbers are multiples of 8. The default value for POWER is 0 which indicates that the case numbers are positive integers that are necessarily powers of 2. The operand VECTOR=B or VECTOR=BR indicates that a branch vector is to be generated rather than an address vector. Fewer instructions are generated for branch vectors. However, you must be sure that the branch vector table is addressable by the initialization code, that the code for each of the cases is addressable, and that the code after the ENDCASE macro is addressable by a current base register. If branch relative instructions are being used, then the CASENTRY macro will ignore the VECTOR keyword, will always generate a branch table, and may use register 0 in the generated code. Register 0 may not be used as the case value register (Rx). It is your responsibility to load the desired case number into Rx and to ensure that it is within the indicated range. The macro expansion then adjusts this value according to the POWER value (whether explicitly or implicitly specified), so that the correct CASE is selected. The content of the register indicated in the CASENTRY statement is destroyed and is only required during the execution of the initial code generated by the macro expansion. Hence, it is possible to use the same register for other purposes within the function code for any CASEs. This example of a CASE macro uses case numbers 1, 2, 3, 4, and
5:
This is interpreted to mean that if a 1, 2, or 4 is present in general register Rx, the code for F1 is executed. If a 5 is present, the code for F2 is executed. If a value of 3 is in Rx, no function code is to be executed. In all cases, control is then to be passed to the code after the ENDCASE macro. The example produces:
This example shows a CASE macro using a branch vector and case
number that are multiples of 8:
The example produces:
The next example shows the use of register 0 and the BRAS instruction
when ASMMREL ON is in effect. Also, the macros have a branch table
generated by default.
The next example shows the use of LARL when both ASMMREL and SYSSTATE
ARCHLVL=2 are in effect.
|
Copyright IBM Corporation 1990, 2014
|