Computational Numbers Usage is COMP, COMP-3 or COMP-5 |
The SimoTime Home Page |
This document describes and demonstrates the internal format of the COMP, COMP-3 and COMP-5 numeric fields using COBOL programs. The sample program will show techniques for displaying a field in a hexadecimal dump format. This example will start by asking the question, "What is common about the following numbers?"
123 4,671 1,058,144,256
This question will be answered by reviewing this sample suite of programs.
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-2025
SimoTime Technologies and Services
All Rights Reserved
This section will provide a quick review of numeric formats.
The sample program starts by defining three fields in WORKING STORAGE.
05 NBS-07 pic 9(7) COMP value 4671. 05 NPS-07 pic 9(7) COMP-3 value 123. 05 N5S-07 pic 9(7) COMP-5 value 1058144256.
The primary CMD Files will call other command files to perform ancillary tasks. These secondary command files and programs will be described in the Ancillary Functionality section of this document.
The NBS-07 field is defined as follows.
05 NBS-07 pic 9(7) COMP value 4671.
The program that uses this field definition is compiled with the IBMCOMP and NOTRUNC directives.
The IBMCOMP directive sets "word-storage" mode. In word-storage mode every data item of USAGE IS COMP occupies either two bytes or a multiple of four bytes. A PIC 9(7) COMP field would only require a three (3) byte physical memory allocation. However, since we are using the IBMCOMP directive the actual physical length will be four (4) bytes (this is compatible with the IBM Mainframe).
The TRUNC directive specifies whether data being stored into a USAGE IS COMP item is to be truncated to the size given by the item's PICTURE clause or to the maximum size the item can hold. The NOTRUNC will not truncate to the picture size but will allow the arithmetic value to be the maximum size the item can hold which is x'FFFFFFFF" or 4,294,967,295 for an unsigned number.
Also, for COMP fields the units position of the arithmetic value is at the high-memory address.
A packed decimal representation stores two decimal digits in one byte. A packed decimal representation stores decimal digits in each "nibble" of a byte. Each byte has two nibbles, and each nibble is indicated by a hexadecimal digit. For example, the value 23 would be stored in two nibbles, using the hexadecimal digits 2 and 3. The sign indication is dependent on your operating environment. On an IBM mainframe, the sign is indicated by the last nibble of the last byte (or high memory address). For explicitly signed fields the "C" indicates a positive value and "D" indicates a negative value. For unsigned (or implied positive) fields the "F" indicates a positive value.
The NPS-07 field is defined as follows.
05 NPS-07 pic 9(7) COMP-3 value 123.
The N5S-07 field is defined as follows.
05 N5S-07 pic 9(7) COMP-5 value 1058144256.
Notice the picture clause specified a length of seven (7) digits and the value clause has a value of 1,058,144,256 which is ten (10) digits. The program that uses this field definition is compiled with the IBMCOMP and NOTRUNC directives.
The IBMCOMP directive sets "word-storage" mode. In word-storage mode every data item of USAGE IS COMP-5 occupies either two bytes or a multiple of four bytes. A PIC 9(7) COMP-5 field would only require a three (3) byte physical memory allocation. However, since we are using the IBMCOMP directive the actual physical length will be four (4) bytes (this is compatible with the IBM Mainframe).
The TRUNC directive specifies whether data being stored into a USAGE IS COMP-5 item is to be truncated to the size given by the item's PICTURE clause or to the maximum size the item can hold. The NOTRUNC will not truncate to the picture size but will allow the arithmetic value to be the maximum size the item can hold which is x'FFFFFFFF" or 4,294,967,295 for an unsigned number.
Also, for COMP-5 fields the units position of the arithmetic value is at the low-memory address.
The following shows the COBOL group definition of the data structure that contains the three numeric fields. This data structure will be used to dump the contents of memory in a hexadecimal format. This approach will show the actual physical contents of memory.
01 NUMBERS-01. 05 NBR-COMP. 15 FILLER pic X(8) value 'COMP===='. 15 NBS-07 pic 9(7) COMP value 4671. 15 FILLER pic X(4) value '=END'. 05 NBR-COMP-3. 15 FILLER pic X(8) value 'COMP-3=='. 15 NPS-07 pic 9(7) COMP-3 value 123. 15 FILLER pic X(4) value '=END'. 05 NBR-COMP-5. 15 FILLER pic X(8) value 'COMP-5=='. 15 N5S-07 pic 9(7) COMP-5 value 1058144256. 15 FILLER pic X(4) value '=END'. 15 FILLER pic X(4) value '=END'.
The following will show the first thing the three fields have in common, the physical length in memory of each of the fields is four (4) bytes. The second thing the three fields have in common is the content of the physical memory space for each of the fields is identical and contains x'0000123F'.
The following shows the memory dump of the preceding data structure. The areas high-lighted in yellow show the physical content of the three fields. The areas high-lighted in aqua show the physical length of the three fields.
* Offset Hex..... ........ ........ ........ ebcdic.......... ascii........... * 1-016 434F4D50 3D3D3D3D 0000123F 3D454E44 .|(&..........+. COMP====...?=END * 17-032 434F4D50 2D333D3D 0000123F 3D454E44 .|(&..........+. COMP-3==...?=END * 33-048 434F4D50 2D353D3D 0000123F 3D454E44 .|(&..........+. COMP-5==...?=END * 49-064 53697A65 2F434F4D 503D3D3D 30303034 ..:...|(&....... Size/COMP===0004 * 65-080 53697A65 2F434F4D 502D333D 30303034 ..:...|(&....... Size/COMP-3=0004 * 81-096 53697A65 2F434F4D 502D353D 30303034 ..:...|(&....... Size/COMP-5=0004
The following (NBRTSTE1.cmd) is a sample of the Windows CMD needed to run this job with Windows and Micro Focus COBOL.
@echo OFF rem * ******************************************************************* rem * NBRTSTW1.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 - COBOL and COMP, COMP-3 and COMP-5 Numeric Formats rem * Author - SimoTime Technologies rem * Date - November 11, 1989 rem * Version - 03.12.15 rem * rem * This set of programs illustrates the use of COMP, COMP-3 and rem * COMP-5 numeric formats. It will show the actual hex-dump content rem * to help understand the internal format. rem * rem * The COBOL programs are compiled with the ASSIGN(EXTERNAL) rem * directive. This provides for external file mapping of file names. rem * rem * When running with Net Express the IBMCOMP an NOTRUNC directives rem * will be required to maintain compatability with the mainframe rem * format and field sizes for binary fields. rem * rem * This technique provides for the use of a single COBOL source rem * program that will run on OS/390, Windows or Unix. rem * rem * This set of programs will run on a Personal Computer with Windows rem * and Micro Focus Net Express. rem * rem * ******************************************************************* rem * Step 1 of 2 Set the global environment variables... rem * set CmdName=NBRTSTW1 call ..\Env1BASE %CmdName% rem * call SimoNOTE "*******************************************************%CmdName%.CMD" call SimoNOTE "Starting JobName %CmdName%.CMD" rem * rem * ******************************************************************* rem * Step 1 of 1, Execute the Number Format Analysis Program... rem * run NBRTSTC1 if not "%ERRORLEVEL%" == "0" set JobStatus=0010 if not "%JobStatus%" == "0000" goto :EojNOK :EojAOK call SimoNOTE "SYSOUT=%SYSOUT%" call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%" goto :End :EojNOK call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%" goto :End :End if not "%1" == "nopause" pause
The following (NBRTSTJ1.jcl) is a sample of the JCL Member needed to run this job with ZOS or Micro Focus Server.
//NBRTSTJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* This program 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 and COMP, COMP-3 and COMP-5 Numeric Formats //* Author - SimoTime Technologies //* Date - November 11, 1989 //* Version - 03.12.15 //* //* This set of programs illustrates the use of COMP, COMP-3 and //* COMP-5 numeric formats. It will show the actual hex-dump content //* to help understand the internal format. //* //* The COBOL programs are compiled with the ASSIGN(EXTERNAL) //* directive. This provides for external file mapping of file names. //* //* When running with Net Express the IBMCOMP an NOTRUNC directives //* will be required to maintain compatability with the mainframe //* format and field sizes for binary fields. //* //* This technique provides for the use of a single COBOL source //* program that will run on OS/390, Windows or Unix. //* //* This set of programs will run on a Personal Computer with Windows //* and Micro Focus Net Express. //* //* ******************************************************************* //* Step 1 of 1, Execute the Number Format Analysis Program... //* //NBRTSTS1 EXEC PGM=NBRTSTC1 //SYSOUT DD SYSOUT=* //*
The following (NBRTSTC1.cbl) is the COBOL program that shows the format and content of the numeric fields.
*SET IBMCOMP NOTRUNC IDENTIFICATION DIVISION. PROGRAM-ID. NBRTSTC1. AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * Copyright (C) 1987-2019 SimoTime Technologies. * * * * All rights reserved. Unpublished, all rights reserved under * * copyright law and international treaty. Use of a copyright * * notice is precautionary only and does not imply publication * * or disclosure. * * * * Permission to use, copy, modify and distribute this software * * for any non-commercial purpose and without fee is hereby * * granted, 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. * * * * Permission to use, copy, modify and distribute this software * * for any commercial purpose requires a fee to be paid to * * SimoTime Technologies. Once the fee is received by SimoTime * * the latest version of the software 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 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 * * * * SimoTime Technologies * * 15 Carnoustie Drive * * Novato, CA 94949-5849 * * 415.883.6565 * * * * RESTRICTED RIGHTS LEGEND * * Use, duplication, or disclosure by the Government is subject * * to restrictions as set forth in subparagraph (c)(1)(ii) of * * the Rights in Technical Data and Computer Software clause at * * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of * * Commercial Computer Software - Restricted Rights at 48 * * CFR 52.227-19, as applicable. Contact SimoTime Technologies, * * 15 Carnoustie Drive, Novato, CA 94949-5849. * * * ***************************************************************** * This program is provided by SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * ***************************************************************** * ***************************************************************** * Source Member: NBRTSTC1.CBL ***************************************************************** * * NBRTSTC1 - A Focus on COMP, COMP-3 and COMP-5 Numeric Fields. * * * DESCRIPTION * ----------- * This set of programs is used to show the various internal * format used with COMP, COMP-3 and COMP-5 fields. * * It will show actual hex-dump content of the fields. * * The COBOL programs are compiled with the ASSIGN(EXTERNAL) * directive. This provides for external file mapping of file * names. * * To run with Net Express the IBMCOMP and NOTRUNC directives * will be required to maintain compatability with the mainframe * format and field sizes for binary fields. * * This program will run on a Personal Computer with Windows * and Micro Focus Net Express. * ***************************************************************** * * MAINTENANCE * ----------- * 1996/03/15 Simmons, Created program. * 1996/03/15 Simmons, 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 '* NBRTSTC1 '. 05 T2 pic X(34) value 'COMP, COMP-3 and COMP-5 Numbers '. 05 T3 pic X(10) value ' v11.12.04'. 05 T4 pic X(24) value ' http://www.simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* NBRTSTC1 '. 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 SIM-THANKS-01. 05 C1 pic X(11) value '* NBRTSTC1 '. 05 C2 pic X(32) value 'Thank you for using this program'. 05 C3 pic X(32) value ' provided from SimoTime Technolo'. 05 C4 pic X(04) value 'gies'. 01 SIM-THANKS-02. 05 C1 pic X(11) value '* NBRTSTC1 '. 05 C2 pic X(32) value 'Please send all inquires or sugg'. 05 C3 pic X(32) value 'estions to the helpdesk@simotime'. 05 C4 pic X(04) value '.com'. ***************************************************************** 01 NUMBERS-01. 05 NBR-COMP. 15 FILLER pic X(8) value 'COMP===='. 15 NBS-07 pic 9(7) COMP value 4671. 15 FILLER pic X(4) value '=END'. 05 NBR-COMP-3. 15 FILLER pic X(8) value 'COMP-3=='. 15 NPS-07 pic 9(7) COMP-3 value 123. 15 FILLER pic X(4) value '=END'. 05 NBR-COMP-5. 15 FILLER pic X(8) value 'COMP-5=='. 15 N5S-07 pic 9(7) COMP-5 value 1058144256. 15 FILLER pic X(4) value '=END'. 01 LENGTHS-01. 05 NBR-LENGTH-COMP. 15 FILLER pic X(12) value 'Size/COMP==='. 15 NBS-07-L pic 9(4) value 0. 05 NBR-LENGTH-COMP-3. 15 FILLER pic X(12) value 'Size/COMP-3='. 15 NPS-07-L pic 9(4) value 0. 05 NBR-LENGTH-COMP-5. 15 FILLER pic X(12) value 'Size/COMP-5='. 15 N5S-07-L pic 9(4) value 0. 01 WK-SIZE pic 9(5) value 0. copy PASSDUMP. ***************************************************************** PROCEDURE DIVISION. perform Z-POST-COPYRIGHT add length of NPS-07 to ZERO giving NPS-07-L add length of NBS-07 to ZERO giving NBS-07-L add length of N5S-07 to ZERO giving N5S-07-L perform DUMP-USING-MEMORY-FORMAT perform Z-THANK-YOU GOBACK. ***************************************************************** DUMP-USING-MEMORY-FORMAT. move 'NOTE' to SIMODUMP-REQUEST move 'OPR1' to SIMODUMP-OUTPUT move 'NBRTSTC1' to SIMODUMP-DUMP-ID add 4 to ZERO giving SIMODUMP-RESULT add 96 to ZERO giving SIMODUMP-LENGTH call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER move 'DUMP' to SIMODUMP-REQUEST move NUMBERS-01 to SIMODUMP-BUFFER add length of NUMBERS-01 to ZERO giving WK-SIZE move LENGTHS-01 to SIMODUMP-BUFFER(WK-SIZE + 1:WK-SIZE) call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER exit. ***************************************************************** Z-POST-COPYRIGHT. display SIM-TITLE upon console display SIM-COPYRIGHT upon console exit. ***************************************************************** Z-THANK-YOU. display SIM-THANKS-01 upon console display SIM-THANKS-02 upon console exit. ***************************************************************** * This routine was generated by SimoREC1 * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * Generation Date: 2009/11/24 Generation Time: 12:08:01:28 * *****************************************************************
The following (SIMODUMP.cbl) is the callable COBOL program that is used to dump the contents of memory and show the actual physical format of the numeric fields.
IDENTIFICATION DIVISION. PROGRAM-ID. SIMODUMP. *AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * Copyright (C) 1987-2019 SimoTime Technologies. * * * * All rights reserved. Unpublished, all rights reserved under * * copyright law and international treaty. Use of a copyright * * notice is precautionary only and does not imply publication * * or disclosure. * * * * Permission to use, copy, modify and distribute this software * * for any non-commercial purpose and without fee is hereby * * granted, 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. * * * * Permission to use, copy, modify and distribute this software * * for any commercial purpose requires a fee to be paid to * * SimoTime Technologies. Once the fee is received by SimoTime * * the latest version of the software 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 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 * * * * SimoTime Technologies * * 15 Carnoustie Drive * * Novato, CA 94949-5849 * * 415.883.6565 * * * * RESTRICTED RIGHTS LEGEND * * Use, duplication, or disclosure by the Government is subject * * to restrictions as set forth in subparagraph (c)(1)(ii) of * * the Rights in Technical Data and Computer Software clause at * * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of * * Commercial Computer Software - Restricted Rights at 48 * * CFR 52.227-19, as applicable. Contact SimoTime Technologies, * * 15 Carnoustie Drive, Novato, CA 94949-5849. * * * ***************************************************************** * This program is provided by SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * ***************************************************************** * ***************************************************************** * Source Member: SIMODUMP.CBL * Copy Files: PASSDUMP.CPY * HEXTABLE.CPY * Calls to: SIMOLOGS is optional ***************************************************************** * * SIMODUMP - Call SIMOLOGS to build hexadecimal dump information. * * CALLING PROTOCOL * ---------------- * Use standard procedure to EXECUTE, RUN or ANIMATE. * * DESCRIPTION * ----------- * This set of programs illustrate the use of COBOL for displaying * a data buffer in hexadecimal format. * * ************ * * CBLHBXJ1 * * ********jcl* * * * ************ * * CBLHBXC1 * * ********cbl* * * * ************ ************ ************ * * CBLHBXC1 *-----* SIMODUMP *-----* CONSOLE * * ********cbl* ********cbl* ******dsply* * * * * * ************ ************ * * SIMOLOGS *-----* CBLHBXD1 * * ********cbl* *******file* * ***************************************************************** * * MAINTENANCE * ----------- * 1989/02/27 Simmons, Created program. * 1997/03/17 Simmons, Updated for COBOL/2. * ***************************************************************** * ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. ***************************************************************** * Data-structure for Title and Copyright... * ------------------------------------------------------------ 01 SIM-TITLE. 05 T1 pic X(11) value '* SIMODUMP '. 05 T2 pic X(34) value 'COBOL Hexadecimal Dump Routine '. 05 T3 pic X(10) value ' v16.06.15'. 05 T4 pic X(24) value ' http://www.simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* SIMODUMP '. 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'. ***************************************************************** * Buffer used for posting messages to the console. * ------------------------------------------------------------ 01 MESSAGE-BUFFER. 05 MESSAGE-HEADER pic X(011) value '* SIMODUMP '. 05 MESSAGE-TEXT. 10 MESSAGE-TEXT-1 pic X(068) value SPACES. 10 MESSAGE-TEXT-2 pic X(188) value SPACES. 01 MSG-LSB pic 9(3) value 256. ***************************************************************** * Buffer used for posting dump information to the console. * ------------------------------------------------------------ 01 DUMP-BUFFER. 05 DUMP-TEXT pic X(79). ***************************************************************** 01 TWO-BYTES. 05 TWO-BYTES-01 pic X. 05 TWO-BYTES-02 pic X. 01 TWO-BYTES-BINARY redefines TWO-BYTES pic S9(3) comp. 01 IX-0 pic 9999 value 0. 01 IX-1 pic 9999 value 0. 01 IX-2 pic 9999 value 0. 01 IX-3 pic 9999 value 0. 01 IX-4 pic 9999 value 0. 01 IX-5 pic 9999 value 0. 01 IP-1 pic 9(5) value 0. 01 IP-2 pic 9(5) value 0. 01 POSITION-PTR pic 9(7) value 0. 01 LOOP-QUIT pic X value 'N'. 01 WA-4 pic X(4) value LOW-VALUES. 01 WA-5 pic X(5) value is SPACES. 01 WA-8 pic X(9) value '00000000'. 01 BUFFER-SIZE-LIMIT-GROUP. 05 BUFFER-SIZE-LIMIT pic 9(5) value 128. 01 BUFFER-LENGTH pic 9999 value 0. 01 LINE-LENGTH pic 9999 value 0. 01 DUMP-HEADER. * 05 filler pic X value '*'. 05 filler pic X value ' '. 05 H1 pic X(8) value 'Position'. 05 filler pic X value ' '. 05 H2 pic X(35) value 'Hex..... ........ ........ ........'. 05 filler pic X value ' '. 05 H3 pic X(16) value 'ebcdic..........'. 05 filler pic X value ' '. 05 H4 pic X(16) value 'ascii...........'. 01 DUMP-LINE. * 05 filler pic X value '*'. 05 filler pic X value ' '. 05 D1 pic X(8) value ' x00-x0F'. 05 filler pic X value ' '. 05 D2 pic X(35) value 'xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx'. 05 filler pic X value ' '. 05 D3 pic X(16) value '................'. 05 filler pic X value ' '. 05 D4 pic X(16) value '................'. 01 X-DUMP-LINE. * 05 filler pic X value '*'. 05 filler pic X value ' '. 05 X1 pic X(8) value ' x00-x0F'. 05 filler pic X value ' '. 05 X2 pic X(35) value 'xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx'. 05 filler pic X value ' '. 05 X3 pic X(16) value '................'. 05 filler pic X value ' '. 05 X4 pic X(16) value '................'. 01 ADDRESS-OFFSET-HEX. 05 A0 pic X(8) value ' x00-x0F'. 05 A1 pic X(8) value ' x10-x1F'. 05 A2 pic X(8) value ' x20-x2F'. 05 A3 pic X(8) value ' x30-x3F'. 05 A4 pic X(8) value ' x40-x4F'. 05 A5 pic X(8) value ' x50-x5F'. 05 A6 pic X(8) value ' x60-x6F'. 05 A7 pic X(8) value ' x70-x7F'. 01 ADDRESS-OFFSET-DEC. 05 B0 pic X(8) value ' 1-016'. 05 B1 pic X(8) value ' 17-032'. 05 B2 pic X(8) value ' 33-048'. 05 B3 pic X(8) value ' 49-064'. 05 B4 pic X(8) value ' 65-080'. 05 B5 pic X(8) value ' 81-096'. 05 B6 pic X(8) value ' 97-112'. 05 B7 pic X(8) value ' 113-128'. 01 DUMP-STATUS-LINE. 05 DS-DUMP-STATUS pic X(08) value 'Starting'. 05 filler pic X(2) value ', '. 05 filler pic X(15) value 'SIMODUMP-ID is '. 05 DS-DUMP-ID pic X(8) value 'HEXDUMP1'. 05 filler pic X(2) value ', '. 05 filler pic X(20) value 'Dump Buffer size is '. 05 DS-LENGTH pic 9999 value 0. 01 MESSAGE-0004-1. 05 filler pic X(9) value 'Warning, '. 05 filler pic X(29) value 'SIMODUMP-LENGTH is invalid, '. 05 filler pic X(29) value 'must be value from 1 to 128. '. 01 MESSAGE-0004-2. 05 filler pic X(9) value 'Warning, '. 05 filler pic X(29) value 'Assuming length of 128 bytes.'. 01 MESSAGE-0008-1. 05 filler pic X(9) value 'Warning, '. 05 filler pic X(24) value 'SIMODUMP-OUTPUT must be '. 05 filler pic X(12) value 'OUT1, OUT2, '. 05 filler pic X(19) value 'OPR1, OPR2 or LOG1.'. 01 MESSAGE-0008-2. 05 filler pic X(9) value 'Warning, '. 05 filler pic X(22) value 'Assuming OUT1 mode.'. 01 FIRST-TIME pic X value 'Y'. 01 USR-PTR-GROUP. 05 USR-PTR-VALUE usage is pointer. 01 USR-PTR-LENGTH pic 99 value 0. 01 USR-PTR-DUMP-ADDR pic X(8) value '00000000'. 01 HEX-OFFSET-GROUP. 05 HEX-OFFSET-VALUE pic 9(9) comp. 01 HEX-OFFSET-LENGTH pic 99 value 0. 01 HEX-OFFSET-DUMP-ADDR pic X(8) value '00000000'. 01 DEC-POSITION-GROUP. 05 DEC-POSITION-VALUE pic 9(8). 01 DEC-POSITION-LENGTH pic 99 value 0. 01 ADDRESS-DUMP-FMT-64. 05 ADDRESS-DUMP-FMT-32A pic X(8) value '00000000'. 05 ADDRESS-DUMP-FMT-32B pic X(8) value '00000000'. ***************************************************************** * Pass area for call SIMOLOGS. * ------------------------------------------------------------ COPY PASSLOGS. COPY HEXTABLE. ***************************************************************** LINKAGE SECTION. COPY PASSDUMP. ***************************************************************** PROCEDURE DIVISION using SIMODUMP-PASS-AREA, SIMODUMP-BUFFER. if FIRST-TIME = 'Y' perform FIRST-TIME-PROCESSING end-if evaluate SIMODUMP-REQUEST when 'NOTE' perform ACTION-IS-POST-TEXT-INFO when 'DUMP' perform ACTION-IS-POST-DUMP-INFO when 'USER' perform ACTION-IS-POST-USER-INFO when other move 'DUMP' to SIMODUMP-REQUEST perform ACTION-IS-POST-DUMP-INFO end-evaluate GOBACK. ***************************************************************** ACTION-IS-POST-TEXT-INFO. move SIMODUMP-DUMP-ID to MESSAGE-TEXT move SIMODUMP-BUFFER(1:68) to MESSAGE-TEXT(10:68) perform Z-DISPLAY-MESSAGE-BUFFER exit. ***************************************************************** ACTION-IS-POST-DUMP-INFO. perform EDIT-PASS-AREA set USR-PTR-VALUE to address of SIMODUMP-BUFFER move ZERO to HEX-OFFSET-VALUE add 1 to ZERO giving DEC-POSITION-VALUE move USR-PTR-GROUP to WA-4 perform ADDRESS-FORMATTING move WA-8 to USR-PTR-DUMP-ADDR move WA-8 to ADDRESS-DUMP-FMT-32B display '* SIMODUMP ADDR is ' ADDRESS-DUMP-FMT-64 if SIMODUMP-OUTPUT = 'LOG1' or = 'OUT1' or = 'OUT2' or = 'OPR1' or = 'OPR2' move 'Starting' to DS-DUMP-STATUS move SIMODUMP-DUMP-ID to DS-DUMP-ID move SIMODUMP-LENGTH to DS-LENGTH move DUMP-STATUS-LINE to MESSAGE-TEXT perform Z-POST-MESSAGE-BUFFER move DUMP-HEADER to MESSAGE-TEXT perform Z-POST-MESSAGE-TEXT end-if perform DUMP-PROCESSING * move SIMOLOGS-REQUEST to SIMODUMP-OUTPUT move SIMOLOGS-STATUS to SIMODUMP-RESULT exit. ***************************************************************** ACTION-IS-POST-USER-INFO. if SIMODUMP-BUFFER(1:7) = 'FORMAT=' evaluate SIMODUMP-BUFFER(8:8) when 'ADDRESS ' move ' Address' to H1 when 'POSITION' move 'Position' to H1 when 'OFFSET ' move ' Offset' to H1 end-evaluate end-if if SIMODUMP-BUFFER(1:6) = 'LIMIT=' perform until SIMODUMP-BUFFER(11:1) not = SPACE if SIMODUMP-BUFFER(11:1) = ' ' move SIMODUMP-BUFFER(10:1) to SIMODUMP-BUFFER(11:1) move SIMODUMP-BUFFER(09:1) to SIMODUMP-BUFFER(10:1) move SIMODUMP-BUFFER(08:1) to SIMODUMP-BUFFER(09:1) move SIMODUMP-BUFFER(07:1) to SIMODUMP-BUFFER(08:1) move ZERO to SIMODUMP-BUFFER(7:1) end-if end-perform move SIMODUMP-BUFFER(7:5) to BUFFER-SIZE-LIMIT-GROUP if BUFFER-SIZE-LIMIT is NUMERIC move 'Accepted User Request, increase Buffer Size ' to MESSAGE-TEXT move 'maximum limit to ' to MESSAGE-TEXT(45:17) move BUFFER-SIZE-LIMIT-GROUP to MESSAGE-TEXT(62:5) perform Z-POST-MESSAGE-BUFFER else add 128 to ZERO giving BUFFER-SIZE-LIMIT move 'Rejected User Request to increase Buffer ' to MESSAGE-TEXT move 'Size maximum, reset to ' to MESSAGE-TEXT(42:23) move BUFFER-SIZE-LIMIT-GROUP to MESSAGE-TEXT(64:5) perform Z-POST-MESSAGE-BUFFER end-if end-if exit. ACTION-IS-POST-USER-INFO-OLD. move DUMP-HEADER to MESSAGE-TEXT move '* Pos' to MESSAGE-TEXT(1:9) move '* ....Pos' to MESSAGE-TEXT(1:9) perform Z-POST-MESSAGE-TEXT move SPACES to D1 add 1 to ZERO giving POSITION-PTR move 'N' to LOOP-QUIT add 1 to ZERO giving IX-1 perform until LOOP-QUIT = 'Y' add 1 to ZERO giving IX-2 add 1 to ZERO giving IX-3 add 1 to ZERO giving IX-4 if SIMODUMP-LENGTH - IX-1 > 16 add 16 to ZERO giving LINE-LENGTH else compute LINE-LENGTH = SIMODUMP-LENGTH - IX-1 + 1 move 'Y' to LOOP-QUIT end-if * display 'DEBUG ' SIMODUMP-LENGTH ' ' LINE-LENGTH ' ' IX-1 move X2 to D2 move X3 to D3 move X4 to D4 perform until LINE-LENGTH = 0 * Get table element subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move SIMODUMP-BUFFER(IX-1:1) to TWO-BYTES-02 add TWO-BYTES-BINARY to 1 giving IX-5 move TAB-X1(IX-5) to WA-5 move WA-5(1:2) to D2(IX-2:2) * Increment to next position in hex-dump area of buffer add 2 to IX-2 if IX-2 = 9 or IX-2 = 18 or IX-2 = 27 add 1 to IX-2 end-if * EBCDIC Print Character and increment to next position move WA-5(3:1) to D3(IX-3:1) add 1 to IX-3 * ASCII Print Character and increment to next position move WA-5(4:1) to D4(IX-4:1) add 1 to IX-4 * Increment pointer to next input buffer byte add 1 to IX-1 subtract 1 from LINE-LENGTH end-perform * move POSITION-PTR to D1 move DUMP-LINE to MESSAGE-TEXT perform Z-POST-MESSAGE-TEXT add 16 to POSITION-PTR end-perform exit. ***************************************************************** ADDRESS-FORMATTING. add 1 to ZERO giving IP-1 add 1 to ZERO giving IP-2 perform 4 times subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move WA-4(IP-1:1) to TWO-BYTES-02 add TWO-BYTES-BINARY to 1 giving IX-5 move TAB-X1(IX-5) to WA-5 move WA-5(1:2) to WA-8(IP-2:2) add 1 to IP-1 add 2 to IP-2 end-perform exit. ***************************************************************** DUMP-PROCESSING. add 1 to ZERO giving IX-0 add 1 to ZERO giving IX-1 add 1 to ZERO giving IX-5 subtract SIMODUMP-IDX from SIMODUMP-IDX add SIMODUMP-LENGTH to ZERO giving BUFFER-LENGTH if BUFFER-LENGTH greater than 15 add 16 to ZERO giving LINE-LENGTH else add BUFFER-LENGTH to ZERO giving LINE-LENGTH end-if perform until BUFFER-LENGTH = 0 add 1 to ZERO giving IX-2 add 1 to ZERO giving IX-3 add 1 to ZERO giving IX-4 move X-DUMP-LINE to DUMP-LINE move DEC-POSITION-GROUP to D1 evaluate H1 when ' Address' move USR-PTR-GROUP to WA-4 perform ADDRESS-FORMATTING move WA-8 to D1 when ' Offset' move HEX-OFFSET-GROUP to WA-4 perform ADDRESS-FORMATTING move WA-8 to D1 end-evaluate add 8 to IX-0 perform DUMP-SINGLE-LINE if BUFFER-LENGTH greater than 15 subtract 16 from BUFFER-LENGTH set USR-PTR-VALUE up by 16 add 16 to HEX-OFFSET-VALUE add 16 to DEC-POSITION-VALUE else subtract BUFFER-LENGTH from BUFFER-LENGTH set USR-PTR-VALUE to address of SIMODUMP-BUFFER move ZERO to HEX-OFFSET-VALUE add 1 to ZERO giving DEC-POSITION-VALUE end-if if BUFFER-LENGTH greater than 15 add 16 to ZERO giving LINE-LENGTH else add BUFFER-LENGTH to ZERO giving LINE-LENGTH end-if end-perform exit. ***************************************************************** DUMP-SINGLE-LINE. perform until LINE-LENGTH = 0 * Get table element subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move SIMODUMP-BUFFER(IX-1:1) to TWO-BYTES-02 add TWO-BYTES-BINARY to 1 giving IX-5 move TAB-X1(IX-5) to WA-5 move WA-5(1:2) to D2(IX-2:2) * Increment to next position in hex-dump area of buffer add 2 to IX-2 if IX-2 = 9 or IX-2 = 18 or IX-2 = 27 add 1 to IX-2 end-if * EBCDIC Print Character and increment to next position move WA-5(3:1) to D3(IX-3:1) add 1 to IX-3 * ASCII Print Character and increment to next position move WA-5(4:1) to D4(IX-4:1) add 1 to IX-4 * Increment pointer to next input buffer byte add 1 to IX-1 subtract 1 from LINE-LENGTH end-perform move DUMP-LINE to DUMP-TEXT if SIMODUMP-IDX < 8 add 1 to SIMODUMP-IDX move DUMP-LINE to SIMODUMP-LINES(SIMODUMP-IDX) end-if if SIMODUMP-OUTPUT = 'LOG1' or = 'OUT2' or = 'OPR2' move DUMP-LINE to SIMOLOGS-MESSAGE perform POST-TO-LOG-FILE else move DUMP-LINE to MESSAGE-TEXT perform Z-POST-MESSAGE-TEXT end-if exit. ***************************************************************** EDIT-PASS-AREA. perform EDIT-PASS-AREA-SYSOUT perform EDIT-PASS-AREA-LENGTH exit. EDIT-PASS-AREA-LENGTH. subtract SIMODUMP-RESULT from SIMODUMP-RESULT if SIMODUMP-LENGTH not NUMERIC add 128 to ZERO giving SIMODUMP-LENGTH add 4 to ZERO giving SIMODUMP-RESULT end-if if SIMODUMP-LENGTH less than 1 or SIMODUMP-LENGTH greater than BUFFER-SIZE-LIMIT add 4 to ZERO giving SIMODUMP-RESULT add 128 to ZERO giving SIMODUMP-LENGTH end-if if SIMODUMP-RESULT not = ZERO move MESSAGE-0004-1 to MESSAGE-TEXT perform Z-POST-MESSAGE-BUFFER move MESSAGE-0004-2 to MESSAGE-TEXT perform Z-POST-MESSAGE-BUFFER end-if exit. EDIT-PASS-AREA-SYSOUT. if SIMODUMP-OUTPUT = 'NONE' or = 'OUT1' or = 'OUT2' or = 'OPR1' or = 'OPR2' or = 'LOG1' subtract SIMODUMP-RESULT from SIMODUMP-RESULT else add 4 to ZERO giving SIMODUMP-RESULT move 'OPR1' to SIMODUMP-OUTPUT move MESSAGE-0008-1 to MESSAGE-TEXT perform Z-POST-MESSAGE-BUFFER move MESSAGE-0008-2 to MESSAGE-TEXT perform Z-POST-MESSAGE-BUFFER end-if exit. ***************************************************************** FIRST-TIME-PROCESSING. add 8 to ZERO giving SIMODUMP-RESULT if SIMODUMP-COPYRIGHT not = 'HIDE' perform POST-COPYRIGHT end-if add 1 to ZERO giving SIMODUMP-IDX perform 8 times move SPACES to SIMODUMP-LINES(SIMODUMP-IDX) add 1 to SIMODUMP-IDX end-perform subtract SIMODUMP-IDX from SIMODUMP-IDX move 'N' to FIRST-TIME exit. ***************************************************************** POST-COPYRIGHT. move SIM-TITLE to MESSAGE-TEXT perform Z-POST-MESSAGE-TEXT move SIM-COPYRIGHT to MESSAGE-TEXT perform Z-POST-MESSAGE-TEXT exit. ***************************************************************** POST-TO-LOG-FILE. add 16 to ZERO giving SIMOLOGS-STATUS * move DUMP-BUFFER to SIMOLOGS-MESSAGE call 'SIMOLOGS' using SIMOLOGS-PASS-AREA if SIMOLOGS-STATUS not = ZERO move 'OPR1' to SIMODUMP-OUTPUT add SIMOLOGS-STATUS to ZERO giving SIMODUMP-RESULT end-if exit. ***************************************************************** Z-DISPLAY-MESSAGE-BUFFER. perform Z-CALCULATE-MSG-LENGTH if SIMODUMP-OUTPUT(1:3) = 'OUT' display MESSAGE-BUFFER(1:MSG-LSB) else display MESSAGE-BUFFER(1:MSG-LSB) upon console end-if move SPACES to MESSAGE-TEXT exit. ***************************************************************** Z-POST-MESSAGE-BUFFER. evaluate SIMODUMP-OUTPUT(1:4) when 'OUT1' perform Z-POST-MESSAGE-BUFFER-2-SYSOUT when other perform Z-POST-MESSAGE-BUFFER-2-SYSOUT end-evaluate exit. ***************************************************************** Z-POST-MESSAGE-TEXT. evaluate SIMODUMP-OUTPUT(1:4) when 'OUT1' perform Z-POST-MESSAGE-TEXT-TO-SYSOUT when other perform Z-POST-MESSAGE-TEXT-TO-SYSOUT end-evaluate exit. ***************************************************************** Z-POST-MESSAGE-BUFFER-2-SYSOUT. perform Z-CALCULATE-MSG-LENGTH display MESSAGE-BUFFER(1:MSG-LSB) move all SPACES to MESSAGE-TEXT exit. ***************************************************************** Z-POST-MESSAGE-TEXT-TO-SYSOUT. perform Z-CALCULATE-MSG-LENGTH display MESSAGE-TEXT(1:MSG-LSB - 11) move all SPACES to MESSAGE-TEXT exit. ***************************************************************** Z-CALCULATE-MSG-LENGTH. add 267 to ZERO giving MSG-LSB if MESSAGE-TEXT-2 = SPACES subtract 188 from MSG-LSB else perform until MSG-LSB < 12 or MESSAGE-BUFFER(MSG-LSB:1) not = SPACE if MESSAGE-BUFFER(MSG-LSB:1) = SPACE subtract 1 from MSG-LSB end-if end-perform end-if exit. ***************************************************************** * This example is provided by SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * *****************************************************************
Note: The SIMODUMP routine is part of the SIMOMODS software package that is available from SimoTime.
This document (with sample programs) describes the internal format of the COMP, COMP-3 and COMP-5 numeric fields. 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.
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.
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.
The following links may be to the current server or to the Internet.
Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the icon. If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the icon.
Explore the Numbers Connection for additional information about the structure and processing of numeric data items (or numeric fields).
Explore The Binary or COMP format for numeric data strings. This numeric structure is supported by COBOL and may be explicitly defined with the "USAGE IS COMP" or "USAGE IS BINARY" clause.
Explore The Edited for Display format for numeric data strings. This numeric structure is supported by COBOL and may be used with an edit-mask to prepare the presentation for readability by human beings.
Explore The Packed-Decimal or COMP-3 format for numeric data strings. This numeric structure is supported by COBOL and may be explicitly defined with the "USAGE IS COMP-3" clause.
Explore The Zoned-Decimal format for numeric data strings. This numeric structure is the default numeric for COBOL and may be explicitly defined with the "USAGE IS DISPLAY" clause.
Explore the Compiler Directives available for the Micro Focus COBOL technologies.
Explore the JCL Connection for more examples of JCL functionality with programming techniques and sample code.
Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.
Explore An Enterprise System Model that describes and demonstrates how Applications that were running on a Mainframe System and non-relational data that was located on the Mainframe System were copied and deployed in a Microsoft Windows environment with Micro Focus Enterprise 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.
Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.
The following links will require an internet connect.
This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.
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.
Explore the GnuCOBOL Technologies available from SourceForge. SourceForge is an Open Source community resource dedicated to helping open source projects be as successful as possible. GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler with run time support. The compiler (cobc) translates COBOL source to executable using intermediate C, designated C compiler and linker. This link will require an Internet Connection.
Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.
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.
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 |
Computational Numeric Values with a focus on COMP, COMP-3 and COMP-5 |
Copyright © 1987-2025 SimoTime Technologies and Services All Rights Reserved |
When technology complements business |
http://www.simotime.com |