Bit Operations

The bit operations are:

Table 60. Bit Operations
Operation Traditional Syntax Free-Form Syntax
Set bits on BITON %BITOR
Set bits off BITOFF %BITAND with %BITNOT
Test bits TESTB %BITAND (see example of Figure 195)

The BITOFF and BITON operations allow you to turn off and on specific bits in a field specified in the result field. The result field must be a one-position character field.

The TESTB operation compares the bits identified in factor 2 with the corresponding bits in the field named as the result field.

The bits in a byte are numbered from left to right. The left most bit is bit number 0. In these operations, factor 2 specifies the bit pattern (bit numbers) and the result field specifies a one-byte character field on which the operation is performed. To specify the bit numbers in factor 2, a 1-byte hexadecimal literal or a 1-byte character field is allowed. The bit numbers are indicated by the bits that are turned on in the literal or the field. Alternatively, a character literal which contains the bit numbers can also be specified in factor 2.

With the BITAND operation the result bit is ON when all of the corresponding bits in the arguments are ON, and OFF otherwise.

With the BITNOT operation the result bit is ON when the corresponding bit in the argument is OFF, and OFF otherwise.

With the BITOR operation the result bit is ON when any of the corresponding bits in the arguments are ON, and OFF otherwise.

With the BITXOR operation the result bit is ON when just one of the corresponding bits in the arguments are ON, and OFF otherwise.



[ Top of Page | Previous Page | Next Page | Contents | Index ]