Content Swap of Data Fields
COBOL calls HLASM, XC Instruction
  Table of Contents  v-24.01.01 – lorxor00.htm 
  Introduction
  Call Interface
  The CMD Member
  The JCL Member
  The Source Members
  COBOL Driver Program
  HLASM Callable Routine
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Contact or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This test case shows how to swap the content of two data strings (or fields) without using a 3rd intermediary field as a holding space. The primary program is a COBOL program. This program calls an Assembler routine (HLASM) to do the field swap.

This test case contains one JCL member to execute the COBOL program. The main COBOL program (LORXORC0.cbl) is used to create the data strings and call the HLASM routine (AIXC00A1.mlc)to do the field swap. The Exclusive OR instruction (XC) is used to do the field swap. This test case may run as a batch job on an IBM Mainframe System running ZOS or a Windows System running Micro Focus Enterprise Server. A Windows command file is provided to run the job on a Windows System using Micro Focus technology.


We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.

Copyright © 1987-2024
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Call Interface

The callable interface requires three (3) parameters, two data strings and a length value.

This section illustrates an XOR using two data strings with a length of twenty-six (26) characters. The following shows the data structures that are passed to the XOR routine.

       01  A-Z-TEXT    pic X(26) value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
       01  Z-A-TEXT    pic X(26) value 'ZYXWVUTSRQPONMLKJIHGFEDCBA'.
           . . .
           . . .
           The following shows the call to the XOR routine.
           . . .
           . . . 
           add 26 to ZERO giving XOR-LENGTH-A-01
           call 'AIXC00A1' using A-Z-TEXT Z-A-TEXT XOR-LENGTH-A-01
           call 'AIXC00A1' using Z-A-TEXT A-Z-TEXT XOR-LENGTH-A-01
           call 'AIXC00A1' using A-Z-TEXT Z-A-TEXT XOR-LENGTH-A-01

The preceding snippet of code shows three (3) calls to the XOR routine. The 1st call and 3rd call are the same. The 2nd call has the sequence of the data strings reversed. Executing an exclusive OR three times in this sequence will cause the content of the two data strings to be swapped.

The following is the expected result that is posted to SYSOUT by the mainline COBOL program that calls the Assembler program.

* LORXORC0 Content Swap, Two Data Strings XOR v08.06.05 http://www.simotime.com
* LORXORC0 Copyright 1987-2017    SimoTime Technologies     All Rights Reserved
ABCDEFGHIJKLMNOPQRSTUVWXYZ-ZYXWVUTSRQPONMLKJIHGFEDCBA
ZYXWVUTSRQPONMLKJIHGFEDCBA-ABCDEFGHIJKLMNOPQRSTUVWXYZ
* LORXORC0 Complete RC=00000

Table of Contents Previous Section Next Section The CMD Member

The following is the Windows Command file (LORXORW0.cmd) that is required to run as a job on a Windows System using Micro Focus Technology.

@echo OFF
rem  * *******************************************************************
rem  *               LORXORW0.cmd - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Test Case for XOR Logical Operator Routine.
rem  * Author - SimoTime Technologies
rem  * Date   - December 15, 2016
rem  *
rem  * This set of programs illustrates the use a HLASM program to do
rem  * an Exclusive OR (XOR) function.
rem  *
rem  *   ************
rem  *   * LORXORW0 *
rem  *   ********cmd*
rem  *        *
rem  *        *
rem  *   ************      ************
rem  *   * LORXORC0 *------*  SYSOUT  *
rem  *   ********cbl*      ************
rem  *        *   *
rem  *        *   *        ************
rem  *        *   *--call--* AIXOR0A1 *
rem  *        *            ******hlasm*
rem  *        *
rem  *   ************
rem  *   *   EOJ    *
rem  *   ************
rem  *
rem  * *******************************************************************
rem  * Step 1, Prepare the Environment...
rem  *
     set CmdName=LORXORW0
     call ..\ENV1BASE %CmdName%
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
     set JobStatus=0000
rem  *
     call SimoNOTE "*******************************************************%CmdName%"
     call SimoNOTE "Starting JobName %CmdName%"
rem  *
rem  * *******************************************************************
rem  * Step 2, Execute the XOR Test Program...
     call SimoNOTE "Continue JobName %CmdName% Execute the XOR Test Program"
     run LORXORC0
     if not ERRORLEVEL = 0 set JobStatus=0010
     if not %JobStatus% == 0000 goto :EojNok
rem  *
rem  * *******************************************************************
rem  * Step 3, End-of-Job Processing...
:EojAok
     call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%"
:End
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section The JCL Member

The following is the mainframe JCL member (LORXORJ0.jcl) that is required to run as a job on an IBM Mainframe System using ZOS or a Windows System using Micro Focus Technology.

//LORXORJ0 JOB SIMOTIME,'CBL BIT MANIPULATE',CLASS=1,MSGCLASS=0,
//             NOTIFY=CSIP1
//* *******************************************************************
//*       LORXORJ0.jcl - a JCL Member for Batch Job Processing        *
//*       This JCL member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - COBOL calls HLASM for XOR Function
//* Author - SimoTime Technologies
//* Date   - January 01, 1989
//*
//* This set of programs illustrates the use an HLASM program to do
//* an Exclusive OR (XOR) function.
//*
//* The DD statement for SYSOUT is required by this example. The
//* COBOL program may be compiled using the SYSOUT directive and
//* without the DD statement for SYSOUT an RTS173 or RTS227 may occur.
//*
//* This set of programs may be compiled and executed on a Mainframe
//* System with ZOS or a Windows System with Micro Focus
//* Enterprise Developer.
//*
//*   ************
//*   * LORXORJ0 *
//*   ********jcl*
//*        *
//*        *
//*   ************      ************
//*   * LORXORC0 *------*  SYSOUT  *
//*   ********cbl*      ************
//*        *   *
//*        *   *        ************
//*        *   *--call--* AIXOR0A1 *
//*        *            ******hlasm*
//*        *
//*   ************
//*   *   EOJ    *
//*   ************
//*
//* *******************************************************************
//* Step 1 of 1, This is a single step job.
//*
//LORXORS1 EXEC PGM=LORXORC0
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//SYSOUT   DD  SYSOUT=*
//*

Table of Contents Previous Section Next Section The Source Members

There are two (2) members in this suite of programs, a COBOL mainline (or driver) program and a callable HLASM routine that does the field XOR function.

Table of Contents Previous Section Next Section COBOL Driver Program

This COBOL program (LORXORC0.cbl) was written to test the callable HLASM program (AIXC00A1.mlc) that does the Exclusive OR (XOR) Function

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    LORXORC0.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * SOURCE MODULE LORXORC0.CBL
      *****************************************************************
      * LORXORC0 - Driver program, XOR Function Test.
      *
      * DESCRIPTION
      * -----------
      * This program will do an XOR of two data strings.
      *
      * This program is one of a suite of Logical Operator Routines.
      * LORANDC1 calls STANDPGM to perform a logical AND Function.
      * LORORRC1 calls STORRPGM to perform a logical OR Function.
      * LORXORC1 calls STXORPGM to perform an Exclusive OR Function.
      * LORXORC0 calls AIXC00A1 to perform an Exclusive OR Function.
      *
      *****************************************************************
      * MAINTENANCE
      * -----------
      * 1999/03/89 SimoTime, Created program.
      * 1999/03/89 SimoTime, No changes to date.
      *
      *****************************************************************
       ENVIRONMENT DIVISION.
      *****************************************************************
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    ------------------------------------------------------------
       01  SIM-TITLE.
           05  T1 pic X(11) value '* LORXORC0 '.
           05  T2 pic X(34) value 'Content Swap, Two Data Strings XOR'.
           05  T3 pic X(10) value ' v08.06.05'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* LORXORC0 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  XOR-ONE-BYTE-STRUCTURE.
           05  XOR-SOURCE-A-01     pic X       value LOW-VALUE.
           05  XOR-TARGET-A-01     pic X       value LOW-VALUE.
           05  XOR-LENGTH-A-01     pic 9(4)    COMP  value 0.

       01  A-Z-TEXT    pic X(26) value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
       01  Z-A-TEXT    pic X(26) value 'ZYXWVUTSRQPONMLKJIHGFEDCBA'.

      *****************************************************************
       PROCEDURE DIVISION.
           perform POST-STARTUP-INFO-TO-SYSOUT

           perform TEST-CASE-02

           display '* LORXORC0 Complete RC=' RETURN-CODE upon console
           display '* LORXORC0 Complete RC=' RETURN-CODE

           GOBACK.

      *****************************************************************
       TEST-CASE-02.
      *    Use the Exclusive OR (XOR) function to swap the contents of
      *    two data strings. This is accomplished by doing three (3)
      *    XOR's of the two data strings. The second XOR has the
      *    sequence of the data strings reversed.
      *
      *         =========A-Z-TEXT=========   =========Z-A-TEXT=========
      *  Before ABCDEFGHIJKLMNOPQRSTUVWXYZ   ZYXWVUTSRQPONMLKJIHGFEDCBA
      *  After  ZYXWVUTSRQPONMLKJIHGFEDCBA   ABCDEFGHIJKLMNOPQRSTUVWXYZ
      *
           display A-Z-TEXT '-' Z-A-TEXT
           add 26 to ZERO giving XOR-LENGTH-A-01

           call 'AIXC00A1' using A-Z-TEXT Z-A-TEXT XOR-LENGTH-A-01
           call 'AIXC00A1' using Z-A-TEXT A-Z-TEXT XOR-LENGTH-A-01
           call 'AIXC00A1' using A-Z-TEXT Z-A-TEXT XOR-LENGTH-A-01

           display A-Z-TEXT '-' Z-A-TEXT
           exit.

      *****************************************************************
       POST-STARTUP-INFO-TO-SYSOUT.
           display SIM-TITLE
           display SIM-COPYRIGHT
           exit.

Table of Contents Previous Section Next Section HLASM Callable Routine

The original version of this program (AIXC00A1) was created on an IBM Mainframe System and was written in IBM Assembler/H and later recompiled using HLASM. A replacement program was required when it was necessary to move a segment of a business application to a Windows System.

AIXC00A1 CSECT
***********************************************************************
*             AIXC00A1.MLC - This is an HLASM Program                 *
*                 Provided by SimoTime Technologies                   *
*           (C) Copyright 1987-2019 All Rights Reserved               *
*              Web Site URL:   http://www.simotime.com                *
*                    e-mail:   helpdesk@simotime.com                  *
***********************************************************************
*                                                                     *
* Created: 1988/06/01, Simmons                                        *
* Changed: 1993/03/01, Simmons, Migrate to Micro Focus                *
*                                                                     *
***********************************************************************
*                                                                     *
* This program will run on an IBM Mainframe using MVS or a PC using   *
* Micro Focus Mainframe Express, version 2.5 or later (MFE) with      *
* the Assembler Option.                                               *
*                                                                     *
* This program provides an example of an HLASM program that           *
* receives control from a COBOL program via a call.                   *
*                                                                     *
* Using the Micro Focus Animation you can immediately see the results *
* of each instruction execution. This is a very effective way to      *
* become familiar with how these techniques work.                     *
*                                                                     *
***********************************************************************
         SAVE  (14,12)
         BALR  12,0              PREPARE A BASE REGISTER
         USING *,12              ESTABLISH BASE REGISTER
*
         LTR   R1,R1
         BZ    NOPARMS
*
         LR    R2,R1           * Put addr of addr list into reg-2
*
         WTO   '* AIXC00A1 is starting...'
*
*
         L     R5,0(,R2)       * Use reg-5 for ADDR of Parm-1
         TM    0(,R2),X'80'    * Is this last parameter...
         BO    ABEND08         * If yes, ABEND...
*
         LA    R2,4(,R2)       * Increment to next addr in list
         L     R6,0(,R2)       * Use reg-6 for ADDR of Parm-2
         TM    0(,R2),X'80'    * Is this last parameter...
         BO    ABEND08         * If yes, ABEND...
*
         LA    R2,4(,R2)       * Increment to next addr in list
         L     R7,0(,R2)       * Use reg-7 for ADDR of Parm-3
         TM    0(,R2),X'80'    * Is this last parameter...
         BO    DOXOR           * If yes, do the XOR request
         B     ABEND08         * else ABEND
*
*---------------------------------------------------------------------*
* Do the requested Exclusive OR Function
*
DOXOR    EQU   *
         LH    R8,0(,R7)       * Get length from COBOL
         SH    R8,=XL2'0001'   * Decrement length by 1
         STH   R8,BIN02        * Store Length - 1 in memory
         MVC   *+7(1),BIN02B   * Modify XC inst with user length
         XC    0(26,R6),0(R5)  * Execute an Exclusive OR Function
*
*---------------------------------------------------------------------*
* NORMAL END-OF-JOB
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
EOJAOK   EQU   *
         WTO   '* AIXC00A1 is returning...'
         RETURN (14,12),RC=0
*
***********************************************************************
* ABENDING WITH RETURN-CODE OF 8
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
ABEND08  EQU   *
         WTO   '* AIXC00A1 is abending...RC=0008'
         RETURN (14,12),RC=8
*
***********************************************************************
* Post a non-paramter message...
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
NOPARMS  EQU   *
         WTO   '* AIXC00A1 called with zero parameters'
         RETURN (14,12),RC=4
*
***********************************************************************
* Post a too-many-paramters message...
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
TOOMANY  EQU   *
         WTO   '* AIXC00A1 called with too many parameters'
         RETURN (14,12),RC=4
*
***********************************************************************
* Define Constants and EQUates
*
         DS    0F            + Force alignment
BIN02    EQU   *
BIN02A   DC    XL1'00'
BIN02B   DC    XL1'00'
*
* Register EQUates
*
R0       EQU   0
R1       EQU   1
R2       EQU   2
R3       EQU   3
R4       EQU   4
R5       EQU   5
R6       EQU   6
R7       EQU   7
R8       EQU   8
R9       EQU   9
R10      EQU   10
R11      EQU   11
R12      EQU   12
R13      EQU   13
R14      EQU   14
R15      EQU   15
*
         END

The HLASM version of the XOR program was re-written in COBOL and complies with the ANSI/85 standard and has been compiled and executed using various COBOL compilers with various dialects (OS/390, Enterprise COBOL and more).

For additional information about this program please call or send an e-mail to: helpdesk@simotime.com

Table of Contents Previous Section Next Section Summary

This suite of programs is provided as a COBOL and HLASM programming example of one of the possible solutions when performing Boolean logic. This Test Case will perform an Exclusive OR (XOR) Function. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.

In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.

SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the  Contact or Feedback  section of this document.

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Technologies.

SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Technologies shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material.

Table of Contents Previous Section Next Section Downloads and Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.

Note: A SimoTime License is required for the items to be made available on a local system or server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Link to Internet   Link to Server   Explore Bit Manipulation using a COBOL program calling COBOL to do the accessing of individuals bits within a byte.

Link to Internet   Link to Server   Explore Bit Manipulation using a COBOL program calling Assembler to do the accessing of individuals bits within a byte.

Link to Internet   Link to Server   Explore How to do a logical OR Function using a COBOL program that calls a COBOL routine to do the actual logical OR of two data strings.

Link to Internet   Link to Server   Explore How to do a logical AND Function using a COBOL program that calls a COBOL routine to do the actual logical AND of two data strings.

Link to Internet   Link to Server   Explore How to do an Exclusive OR (XOR) using a COBOL program that calls a COBOL routine to do the actual XOR of two data strings.

Link to Internet   Link to Server   Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.

Link to Internet   Link to Server   Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.

Link to Internet   Link to Server   Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection

Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Contact or Feedback

This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.

1. Send an e-mail to our helpdesk.
1.1. helpdesk@simotime.com.
2. Our telephone numbers are as follows.
2.1. 1 415 763-9430 office-helpdesk
2.2. 1 415 827-7045 mobile

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.

Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Exclusive OR using COBOL
Copyright © 1987-2024
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com