>>SOURCE FORMAT IS FREE *> *************************************************************** *> OpenCOBOL Logical bit operation library call examples *> *************************************************************** *> *> Copyright (C) 2008 The OpenCOBOL Project *> *> This program is free software; you can redistribute it and/or *> modify it under the terms of the GNU General Public License as *> published by the Free Software Foundation; either version 2, *> or (at your option) any later version. *> *> This program is distributed in the hope that it will be *> useful, but WITHOUT ANY WARRANTY; without even the implied *> warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *> PURPOSE. See the GNU General Public License for more details. *> *> You should have received a copy of the *> GNU General Public License along with this software; *> see the file COPYING. If not, write to *> the Free Software Foundation, 51 Franklin Street, Fifth Floor *> Boston, MA 02110-1301 USA *> *************************************************************** *> Author: Brian Tiffin *> Date: 26-Jun-2008 *> Purpose: Demonstrate usage of OpenCOBOL bitwise logical calls *> Tectonics: cobc -x logicals.cob identification division. program-id. logicals. data division. working-storage section. *> define an alphnum field large enough to hold call name 01 BITWISE pic x(8). *> results from library call are 32 bit integers 01 result pic x(4) comp-5. *> The default source is an 8 byte binary X'FFFF0000FFFF0000' *> default destination target 8 byte 0 *> length is passed by value, and for demo varies from 1 to 8 *> NOTE: using a length greater than target size is dangerous *> and can overwrite memory. 01 src pic s9(18) comp-5 value -281470681808896. 01 dst pic s9(18) comp-5 value 0. 01 len pic 9 comp-5. 01 disp pic z. *> org is defined to resest destination target for each len 01 org pic s9(18) comp-5 value 0. *> *> Demonstration of callable bitwise logical operators *> NOTE: By default, OpenCOBOL resolves library references *> at runtime. *> procedure division. display "Bitwise logical library calls" end-display. move "CBL_AND" to BITWISE. move -1 to org. perform demonstrate-bitwise. move "CBL_OR" to BITWISE. move 0 to org. perform demonstrate-bitwise. move "CBL_NOR" to BITWISE. move 0 to org. perform demonstrate-bitwise. move "CBL_XOR" to BITWISE. move 4294901760 to org. perform demonstrate-bitwise. move "CBL_IMP" to BITWISE. move 0 to org. perform demonstrate-bitwise. move "CBL_NIMP" to BITWISE. move 0 to org. perform demonstrate-bitwise. move "CBL_EQ" to BITWISE. move 0 to org. perform demonstrate-bitwise. *> *> NOT only uses the target field, no source *> move src to org. display "CBL_NOT" end-display. perform varying len from 1 by 1 until len > 8 move len to disp move org to dst call "CBL_NOT" using dst by value len returning result end-call display "org: ", org, ", dst: ", dst, ", len: ", disp end-display if result not equal 0 display "res: ", result end-display end-if end-perform. exit program. stop run. *> *> ************************************************************** *> demonstrate-bitwise. display BITWISE end-display perform varying len from 1 by 1 until len > 8 move len to disp move org to dst call BITWISE using src dst by value len returning result end-call display "src: ",src,", org: ",org,", dst: ",dst,", len: ",disp end-display if result not equal 0 display "res: ", result end-display end-if end-perform.