Use the SETB instruction to assign a bit value to a SETB symbol. You can assign the bit values, 0 or 1, to a SETB symbol directly and use it as a switch.
If you specify a logical (Boolean) expression in the operand field, the assembler evaluates this expression to determine whether it is true or false, and then assigns the value 1 or 0, respectively, to the SETB symbol. You can use this computed value in condition tests or for substitution.
|
A global variable symbol in the name field must have been previously declared as a SETB symbol in a GBLB instruction. Local SETB symbols need not be declared in a LCLB instruction. The assembler considers any undeclared variable symbol found in the name field of a SETB instruction as a local SET symbol. The variable symbol is assigned a type attribute value of N.
An arithmetic value enclosed in parentheses is allowed. This value can be represented by:
If the value is 0, the assembler assigns a value of 0 to the symbol in the name field. If the value is not 0, the assembler assigns a value of 1.
A logical expression is evaluated to determine if it is true or false; the SETB symbol in the name field is then assigned the binary value 1 or 0, corresponding to true or false, respectively. The assembler assigns the explicitly specified binary value (0 or 1) or the computed logical value (0 or 1) to the SETB symbol in the name field.
Rules for Coding Logical Expressions: The following is a summary of coding rules for logical expressions:
*-----------*
| |
|Logical1 |
|Expression |
| |
*-----*-----*
|
V Can be any of
*-------------*-------------------------------------------------* Logical Operators Allowed
V V V
*-----*-----* *-----*-----*-----------*-----------* *-----------*-----*-----* OR Intersection
| | | | OR | | | | | AND Union
| Logical2 | |Logical2 | OR NOT | Logical | | NOT |Logical2 | NOT Negation
| Term | |Expression | AND | Term | | |Expression | XOR Exclusive OR
| | | | AND NOT | | | | |
| | | | XOR | | | | |
| | | | XOR NOT | | | | |
*-----*-----* *-----------*-----------*-----------* *-----------*-----------*
|
V Can be any of
*-------------*-------------*-------------*-------------*-------------*-------------*
V V V V V V V
*-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----*
| | | SETB2 | | | | | | | | Predefined| | |
| Logical2 | | Variable | |Arithmetic2| | 02 | | 12 | | Absolute | | Logical2 |
| Relation | | Symbol | |Value | | | | | | Ordinary | | Function |
| | | | | | | | | | | Symbol | | |
*-----*-----* *-----------* *-----------* *-----------* *-----------* *-----------* *-----------*
|
V Can be any of
*-----------------------------------------*
V V
*-----*-----* *-----*-----*
| | | |
|Arithmetic | | Character |
|Relation | | Relation |
| | | |
*-----*-----* *-----*-----*
| | Relational Operators Allowed
V Which is V Which is
*-----*-----*-----------*-----------* *-----*-----*-----------*-----------* EQ Equal
| | EQ, NE | | | | EQ, NE | | NE Not equal
|Arithmetic | LE, LT |Arithmetic | | Character3| LE, LT | Character3| LE Less than or equal
|Comparand | GE, GT |Comparand | | Comparand | GE, GT | Comparand | LT Less than
| | | | | | | | GE Greater than or equal
*-----*-----*-----------*-----------* *-----*-----*-----------*-----------* GT Greater than
| |
V Which can be V Can be any of
| *-------------*-------------*-----------------*
| V V V V
*-----*-----* *-----*-----* *-----*-----* *-----*----------* *-----*-----*
| | | | | | | Type Attribute | |Character |
|Arithmetic | |Character | | Substring | | or Operation | |Exp. and |
|Expression | |Expression | | Notation | | Code | |Substring |
| | | | | | | Reference4 | |Notation |
*-----------* *-----------* *-----------* *----------------* *-----------*
The SETB symbol in the name field can be subscripted. If the same SETB symbol has not been previously declared in a GBLB or LCLB instruction with an allowable dimension, then the symbol is implicitly declared as a local SETB array variable.
The assembler assigns the binary value explicitly specified, or implicit in the logical expression present in the operand field, to the position in the declared array given by the value of the subscript. The subscript expression must not be 0 or have a negative value.
You can use a logical expression to assign a binary value to a SETB symbol. You can also use a logical expression to represent the condition test in an AIF instruction. This use lets you code a logical expression whose value (0 or 1) varies according to the values substituted into the expression and thereby determine whether or not a branch is to be taken.
Figure 41 defines a logical expression.
It is important to note that logical expressions contain unquoted spaces that do not terminate the operand field. This is called "logical-expression format", and such expressions are always enclosed in parentheses.
A logical expression can consist of a logical expression and a logical term separated by a logical operator delimited by spaces. The logical operators are:
Example
After the following statements &VAR contains the arithmetic value 0.
Name Operation Operand &OP1 SETB 1 &OP2 SETB 0 &VAR SETB (&OP1 AND &OP2)
Example
(1 AND NOT 0) is equivalent to (1 AND 1).
Example (1 XOR NOT 1) is equivalent to (1 XOR 0).
Relational operators provide the means for comparing two items. A relational operator plus the items form a relation. An arithmetic relation is two arithmetic expressions separated by a relational operator, and a character relation is two character strings (for example, a character expression and a type attribute reference) separated by a relational operator.
The relational operators are:
The assembler evaluates logical expressions as follows:
The two comparands in a character relation are compared, character by character, according to binary (EBCDIC) representation of the characters. If two comparands in a relation have character values of unequal length, the assembler always takes the shorter character value to be less.
The logical value assigned to a SETB symbol is used for the SETB symbol appearing in the operand field of an AIF instruction or another SETB instruction.
If a SETB symbol is used in the operand field of a SETA instruction, or in arithmetic relations in the operand fields of AIF and SETB instructions, the binary values 1 (true) and 0 (false) are converted to the arithmetic values 1 and 0, respectively.
If a SETB symbol is used in the operand field of a SETC instruction, in character relations in the operand fields of AIF and SETB instructions, or in any other statement, the binary values 1 (true) and 0 (false), are converted to the character values '1' and '0', respectively.
The following example illustrates these rules. It assumes that (L'&TO EQ 4) is true, and (S'&TO EQ 0) is false.
MACRO
&NAME MOVE &TO,&FROM
LCLA &A1
LCLB &B1,&B2
LCLC &C1
&B1 SETB (L'&TO EQ 4) Statement 1
&B2 SETB (S'&TO EQ 0) Statement 2
&A1 SETA &B1 Statement 3
&C1 SETC '&B2' Statement 4
ST 2,SAVEAREA
L 2,&FROM&A1
ST 2,&TO&C1
L 2,SAVEAREA
MEND
-------------------------------------------------------------------
HERE MOVE FIELDA,FIELDB
-------------------------------------------------------------------
+HERE ST 2,SAVEAREA
+ L 2,FIELDB1
+ ST 2,FIELDA0
+ L 2,SAVEAREA
Because the operand field of statement 1 is true, &B1 is assigned the binary value 1. Therefore, the arithmetic value +1 is substituted for &B1 in statement 3. Because the operand field of statement 2 is false, &B2 is assigned the binary value 0. Therefore, the character value 0 is substituted for &B2 in statement 4.
[ Top of Page | Previous Page | Next Page | Contents | Index ]