Conditional Expressions

This document contains the following chapters:

1.0 Description

Conditional expressions are used by a variety of macros in Bixoft's eXtended Assembly Language. They basically appear as a sequence of operands - the exact number being variable - on the IF macro statement. Various other macros will accept a condition too, and if one is specified they internally generate an IF statement with the specified condition.
Some of these macros are:

Macro name Operands
IF Condition Expression
CASE Condition Expression
DO WHILE[,Condition Expression]
DO UNTIL[,Condition Expression]
LEAVE [Condition Expression]
LOOP [Condition Expression]
GOTO Label[,Condition Expression]

The exact syntax of the conditional expressions is rather complicated. There are nine different basic formats. These basic formats evaluate as a simple condition.

These basic conditions can be combined into comlpex conditions by specifying several simple conditions, separating them with AND or OR keywords. Mixing AND and OR in a single complex conditional expression is not supported yet. The same holds for the use of parentheses to fix the order of evaluation.

2.0 Simple Conditions

2.1 Simple Condition Syntax 0

Simple conditions in format-0: Menmonic


mnemonic Condition Mnemonic: one of E, H, L, M, O, P, Z, NE, NH, NL, NM, NO, NP, NZ

2.2 Simple Condition Syntax 1

Simple conditions in format-1: one or more named bit-fields


bit-field The specified bit must have been declared with the DCL macro, or it must be in a DSECT that has been mapped thru the PGM or GENMAPS macro.
... If more than one bit-field is specified the bits must share a single byte location in storage. The specified bit-conditions are logically AND-ed together.

2.3 Simple Condition Syntax 2

Simple conditions in format-2: NOT, one or more named bit-fields


NOT
bit-field The specified bit must have been declared with the DCL macro, or it must be in a DSECT that has been mapped thru the PGM or GENMAPS macro.
... If more than one bit-field is specified the bits must share a single byte location in storage. The specified bit-conditions are logically AND-ed together.

2.4 Simple Condition Syntax 3

Simple conditions in format-3: ANY, one or more named bit-fields


ANY
bit-field The specified bit must have been declared with the DCL macro, or it must be in a DSECT that has been mapped thru the PGM or GENMAPS macro.
... If more than one bit-field is specified the bits must share a single byte location in storage. The specified bit-conditions are logically OR-ed together to create a mask for a TM-instruction.

2.5 Simple Condition Syntax 4

Simple conditions in format-4: field, mnemonic


field Any defined register or field in addressable storage
mnemonic Condition Mnemonic: one of Z, M, P, NZ, NM, NP. These are taken to mean Zero, Minus, Plus, respectively. The operand is treated as a signed binary number.

2.6 Simple Condition Syntax 5

Simple conditions in format-5: field1, relation, field2


field1 Any defined register or field in addressable storage
relation Relation: one of EQ, NE, LT, LE, GT, GE. These are taken to mean Equal, Not-Equal, Less-Than, Less-or-Equal, Greater-Than, Greater-or-Equal respectively. Not-Greater is specified as LE, Not-Less is specified as GE.
field2 Any defined register or field in addressable storage

If the types or lengths of the operands are not equal, then one of the operands will be converted, if possible. E.g. when comparing a zoned field to signed or unsigned binary field or or to a register.

If the comparison cannot logically be made, an assembly error message will be issued. E.g. comparing a zoned field with an access register will not assemble.

2.7 Simple Condition Syntax 6

Simple conditions in format-6: mnemonic, opcode, field1, field2


mnemonic Condition Mnemonic: one of E, H, L, M, O, P, Z, NE, NH, NL, NM, NO, NP, NZ
opcode One of a limited list of opcodes and macros that will set the condition code
field1 any appropriate first operand for the specified opcode
field2 any appropriate second operand for the specified opcode

2.8 Simple Condition Syntax 7

Simple conditions in format-7: named code-value


code-value The specified value must have been declared with the DCL macro, or it must be in a DSECT that has been mapped thru the PGM or GENMAPS macro.

A code-field is like a bit field, in that it takes distinct values with separate meanings. E.g. a gender indication or an order status. Once each possible value has been defined the named code-values can be tested. E.g. MALE or BACKORDER.

2.9 Simple Condition Syntax 8

Simple conditions in format-8: NOT, named code-value


NOT
code-value The specified value must have been declared with the DCL macro, or it must be in a DSECT that has been mapped thru the PGM or GENMAPS macro.

A code-field is like a bit field, in that it takes distinct values with separate meanings. E.g. a gender indication or an order status. Once each possible value has been defined the named code-values can be tested. E.g. MALE or BACKORDER.

3.0 Complex Conditions

3.1 Complex Condition Syntax 0

Complex conditions in format-0: Basic Condition

The format-0 Complex condition takes the form of a single basic condition in any of the nine formats specified above

3.2 Complex Condition Syntax 1

Complex conditions in format-1: AND-ed Basic Conditions

The format-1 Complex condition takes the form of multiple basic conditions, each in any of the nine formats specified above. The basic conditions are separated by the keyword AND. The condition will evaluate as true when each of the specified basic conditions is met.

Performance remark:
The basic conditions are evaluated from left to right, until one is found that does not match (if any). Therefore performance benefits if the condition that is most likely to evaluate as false is specified first.

3.3 Complex Condition Syntax 2

Complex conditions in format-2: OR-ed Basic Conditions

The format-2 Complex condition takes the form of multiple basic conditions, each in any of the nine formats specified above. The basic conditions are separated by the keyword OR. The condition will evaluate as true when any of the specified basic conditions is met.

Performance remark:
The basic conditions are evaluated from left to right, until one is found that does matches (if any). Therefore performance benefits if the condition that is most likely to evaluate as true is specified first.

3.4 Complex Condition Syntax 3

Complex conditions in format-3: AND-e and OR-ed Basic Conditions

This format has not yet been implemented. For the IF-macro this can be emulated by specifying OR-able basic conditions as a format-2 complex condition, while separating AND-able basic conditions into separate conditions

3.5 Complex Condition Syntax 4

Complex conditions in format-4: Parenthesized Basic Conditions

This format has not yet been implemented. For the IF-macro this can be emulated by specifying OR-able basic conditions as a format-2 complex condition, while separating AND-able basic conditions into separate conditions


Please e-mail us with your comments. Thanks in advance.

To our homepage.

 

This site is a member of WebRing.
You are invited to browse the list of mainframe-loving sites.
Running
    Tyrannosaurus Rex Dinos are not dead. They are alive and well and living in data centers all around you. They speak in tongues and work strange magics with computers. Beware the dino! And just in case you're waiting for the final demise of these dino's: remember that dinos ruled the world for 155-million years!
Dinos and other anachronisms
[ Join Now | Ring Hub | Random | << Prev | Next >> ]