The SELECT macro set
The SELECT macro set selects one of a set of functions for execution, depending on the result of a comparison. The flowchart for the SELECT program figure is:
OTHRWISE is optional.
This example uses the SELECT, WHEN, OTHRWISE, and ENDSEL macros:
SELECT CLI,0(R6),EQ Defines the comparison
WHEN (X'20')
Code for F1
WHEN (1,5,13)
Code for F2
WHEN (3,7,15)
Code for F3
OTHRWISE
Code for F4
ENDSEL
It produces: SELECT CLI,0(R6),EQ Defines the comparison
WHEN (X'20')
CLI 0(R6),X'20'
BC 15-8,#@LB2
Code for F1
WHEN (1,5,13)
BC 15,#@LB1 SKIP TO END
#@LB2 DC 0H
CLI 0(R6),1
BC 8,#@LB5
CLI 0(R6),5
BC 8,#@LB5
CLI 0(R6),13
BC 15-8,#@LB4
#@LB5 DC 0H
Code for F2
WHEN (3,7,15)
BC 15,#@LB1 SKIP TO END
#@LB4 DC 0H
CLI 0(R6),3
BC 8,#@LB7
CLI 0(R6),7
BC 8,#@LB7
CLI 0(R6),15
BC 15-8,#@LB6
#@LB7 DC 0H
Code for F3
OTHRWISE
BC 15,#@LB1 SKIP TO END
#@LB6 DC 0H
Code for F4
ENDSEL
#@LB1 DC 0H
Here is another example of the SELECT Macro Set:
SELECT CLM,2,B'1100',EQ
WHEN (=C'AA',=C'BB')
Process A
WHEN =C'AB'
Process B
WHEN =C'12'
Process C
ENDSEL
It produces: CLM 2,B'1100',=C'AA'
BC 8,LB3
CLM 2,B'1100',=C'BB'
BC 15-8,LB2
LB3 DC 0H
Process A
B LB1
LB2 DC 0H
CLM 2,B'1100',=C'AB'
BC 15-8,LB4
Process B
B LB1
LB4 DC 0H
CLM 2,B'1100',=C'12'
BC 15-8,LB6
Process C
LB6 DC 0H
LB1 DC 0H
The SELECT group allows a SELECT with no operands followed by WHEN macros with IF style operands. This produces the same structure as the IF/ELSEIF/ELSE/ENDIF macros.
For example: :
SELECT
WHEN (CLI,WORD1,EQ,1),OR,(CLI,WORD1,EQ,2),OR,(CLI,WORD1,EQ,3)
<code for first condition>
WHEN (CLI,WORD2,EQ,2),AND,(CLI,WORD3,EQ,3)
<code for second condition>
OTHRWISE
<otherwise code>
ENDSEL
produces (assuming that ASMMREL ON has
been coded earlier): SELECT
WHEN (CLI,WORD1,EQ,1),OR,(CLI,WORD1,EQ,2),OR,(CLI,WORD1,EQ,3)
CLI WORD1,1
BRC 8,#@LB3
CLI WORD1,2
BRC 8,#@LB3
CLI WORD1,3
BRC 15-8,#@LB2
#@LB3 DC 0H
<code for first condition>
WHEN (CLI,WORD2,EQ,2),AND,(CLI,WORD3,EQ,3)
BRC 15,#@LB1 SKIP TO END
#@LB2 DC 0H
CLI WORD2,2
BRC 15-8,#@LB4
CLI WORD3,3
BRC 15-8,#@LB4
<code for second condition>
OTHRWISE
BRC 15,#@LB1 SKIP TO END
#@LB4 DC 0H
<otherwise code>
ENDSEL
#@LB1 DC 0H