The Exclusive Or Character instruction performs a logical bit by bit “exclusive or” between two fields in memory. Operand 1, the target,  is a memory field and Operand 2, the source, also specifies a storage location in memory.  The number of characters which participate in the operation is determined by the first operand, and as a result, is limited to 256 bytes.  The storage fields are exclusive or-ed internally with the result placed in the target field. Typically, the source is unaffected, but can be altered by this operation if the fields overlap.  The table below shows the results of “exclusive or-ing” two bits together.

 

                                                       Bit 1      Bit 2    Result

                                                          0           0            0

                                                          0           1            1

                                                          1           0            1

                                                          1           1            0

 

   This instruction sets the condition code as follows:

 

                 0  if all target bits are set to 0.  Test this condition with BZ or BNZ.

                 1  if any target bit is set to 1.  Test this condition with BM or BNM.

 

        Some Unrelated Exclusive Or Characters

 

              FIELD1  DC   X’0001020304’

              FIELD2  DC   X’FFFFFF’

              FIELD3  DC   C’ABC’

              FIELD4  DC   X’000000’

 

     XC    FIELD1,FIELD1    FIELD1 = X’0000000000’ Condition Code = 0

     XC    FIELD2,FIELD1    FIELD2 = X’FFFEFD’     Condition Code = 1

     XC    FIELD3,FIELD1    FIELD3 = X’C1C3C1’     Condition Code = 1

     XC    FIELD2,FIELD3    FIELD2 = X’3E3D3C’     Condition Code = 1

     XC    FIELD3,FIELD3    FIELD3 = X’000000’     Condition Code = 0

     XC    FIELD3,FIELD4    FIELD3 = X’C1C2C3’     Condition Code = 1

     XC    FIELD1+2,FIELD3  FIELD1 = X’0001C3C1C7’ Condition Code = 1

     XC    FIELD1(3),FIELD2 FIELD1 = X’FFFEFD0304’ Condition Code = 1

 

 

 

 

 

 

 

 

   The XC instruction is occasionally used to clear a character field by exclusive or-ing it with itself:

                XC    FIELDA,FIELDA

 

The result is a field that contains binary 0’s.  If the field is printed, it will appear as sequence of blanks since binary 0’s are unprintable.  While this technique may work for reports, keep in mind that binary 0’s are not blanks.  If you need blanks, the following code might be used:

 

            MVI    FIELDA,C’ ’         MOVE THE 1ST BLANK

            MVI    FIELDA+1(L’FIELDA-1),FIELDA  MOVE THE OTHER BLANKS