bug-gnucobol
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-GnuCOBOL] Binary allocations - -fbinary-size=2-4-8


From: Bruce Zupek
Subject: Re: [Bug-GnuCOBOL] Binary allocations - -fbinary-size=2-4-8
Date: Mon, 14 May 2018 13:34:03 -0400
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Just 2 cents worth on SYNC / SYNCHRONIZED.
SYNC / SYNCHRONIZED came to be back in the days of IBM Macro CICS. Macro CICS used "DS 0H" (align on a half word boundary) in BMS mapset generation.
Cobol also needed to honor the half word alignment for CICS mapsets represented in Cobol - hence SYNC.
Beyond ancient CICS macro compliance I can't think of any important use for SYNC - if it is on by default I would suggest it be an explicit enable.
Bruce Zupek

On 5/14/2018 1:26 PM, Ron Norman wrote:
The 'reportwriter' branch had -fibmcomp added to it just over 3 years ago and this update has not yet been merged into the main trunk!
IBMCOMP also cause SYNC to be honoured. With out IBMCOMP, SYNC is just a comment.

On Mon, May 14, 2018 at 1:23 PM, Bruce Zupek <address@hidden> wrote:
MF utilizes a compiler directive "IBMCOMP"  akin to GNU 2-4-8.
Lacking an IBMCOMP directive the default would be GNU 1-2-4-8.
MF wise, if IBMCOMP is in effect the 2-4-8 paradigm prevails across all binary defined data fields (COMP-X excluded because I don't remember the behavior.)
MF also confounds Cobol with PIC x(nn) COMP-X. Albeit the definition character (XX) MF permits arithmetic operations on fields so defined.
MF also confounds Cobol with PIC 9(nn) COMP-X.

I do have a MF program that displays the lengths of all Binary data types for all valid PIC (NN) declarations.
I can share the results with y'all - I'll run it one time with IBMCOMP, another time sans IBMCOMP.

Please advise if y'all would want the MF results from above.
Y'all are also welcome to the source code.

Bruce Zupek

Here is the IBM documentation on Binary data types. It appears as if 2-4-8 is always in effect.
Binary (COMP) items
BINARY, COMP, and COMP-4 are synonyms. Binary-format numbers occupy 2, 4, or 8 bytes of storage. If the PICTURE clause specifies that an item is signed, the leftmost bit is used as the operational sign.

A binary number with a PICTURE description of four or fewer decimal digits occupies 2 bytes; five to nine decimal digits, 4 bytes; and 10 to 18 decimal digits, 8 bytes. Binary items with nine or more digits require more handling by the compiler. Testing them for the SIZE ERROR condition and rounding is more cumbersome than with other types.

You can use binary items, for example, for indexes, subscripts, switches, and arithmetic operands or results.

Use the TRUNC(STD|OPT|BIN) compiler option to indicate how binary data (BINARY, COMP, or COMP-4) is to be truncated.

Native binary (COMP-5) items
Data items that you define as USAGE COMP-5 are represented in storage as binary data. However, unlike USAGE COMP items, they can contain values of magnitude up to the capacity of the native binary representation (2, 4, or 8 bytes) rather than being limited to the value implied by the number of 9s in the PICTURE clause.

When you move or store numeric data into a COMP-5 item, truncation occurs at the binary field size rather than at the COBOL PICTURE size limit. When you reference a COMP-5 item, the full binary field size is used in the operation.

COMP-5 is thus particularly useful for binary data items that originate in non-COBOL programs where the data might not conform to a COBOL PICTURE clause.

The table below shows the ranges of possible values for COMP-5 data items.

Table 1. Ranges in value of COMP-5 data items
PICTURE                    Storage representation        Numeric values
S9(1) through S9(4)        Binary halfword (2 bytes)    -32768 through +32767
S9(5) through S9(9)        Binary fullword (4 bytes)    -2,147,483,648 through +2,147,483,647
S9(10) through S9(18)      Binary doubleword (8 bytes)  -9,223,372,036,854,775,808 through +9,223,372,036,854,775,807
9(1) through 9(4)          Binary halfword (2 bytes)    0 through 65535
9(5) through 9(9)          Binary fullword (4 bytes)    0 through 4,294,967,295
9(10) through 9(18)        Binary doubleword (8 bytes)  0 through 18,446,744,073,709,551,615


On 5/14/2018 12:49 PM, Simon Sobisch wrote:
I haven't checked IBMs docs on this but I assume the correct thing to do for std ibm and bs2000 would be to implement COMP-5 as different comp type. What does MicroFocus do in ibm mode?

Simon




--
Cheers
Ron Norman


reply via email to

[Prev in Thread] Current Thread [Next in Thread]