Groups | Search | Server Info | Login | Register
Groups > comp.lang.cobol > #12855
| Date | 2024-04-06 04:10 -0500 |
|---|---|
| Subject | Re: GnuCOBOL 3.2 and CBL_OR. What am I doing wrong? |
| Newsgroups | comp.lang.cobol |
| References | <uuq9l5$1n5b7$1@dont-email.me> |
| From | Arnold Trembley <arnold.trembley@att.net> |
| Message-ID | <u4mdnVyVQcoKjIz7nZ2dnZfqnPGdnZ2d@giganews.com> (permalink) |
On 2024-04-05 8:48 PM, Bruce Axtens wrote: > What have I broken here? Based on code in > https://gnucobol.sourceforge.io/faq/GnuCOBOLFAQ.pdf > ... > 01 LOGICALS. > 03 ITEM-1 PIC 999 USAGE COMP-5. > 03 ITEM-2 PIC 999 USAGE COMP-5. > 03 RESULT USAGE BINARY-LONG. > ... > LOGICAL-OR. > INITIALIZE RESULT. > CALL "CBL_OR" USING ITEM-1 ITEM-2 BY VALUE 1 > RETURNING RESULT. > DISPLAY ITEM-1 SPACE ITEM-2 SPACE RESULT. > EXIT. > > ITEM-1 ITEM-2 RESULT > 00001 00253 +0000000000 > 00002 00253 +0000000000 > 00004 00253 +0000000000 > 00008 00253 +0000000000 > 00016 00253 +0000000000 > 00032 00253 +0000000000 > 00064 00253 +0000000000 > 00128 00253 +0000000000 > > Why do I only get +0? According to the GnuCOBOL 3.2 Programmer's Guide, the result of CBL_OR using ITEM-1 ITEM-2 BY VALUE 1 is the leftmost 8 bits (BY VALUE 1 BYTE) and is stored in ITEM-2. So the reason that RESULT is always zero is that it is initialized to zero, and it is either never changed or else CBL_OR is always successful and always sets the return code to zero. But I would wonder why ITEM-2 is always 253. How wide is a variable defined as PIC 999 USAGE COMP-5? According to the GnuCOBOL manual, COMP-5 is the native binary format for your local machine (i.e. little endian on x86) and the width depends on the number of digits in the picture clause and the "binary-size" setting in your GnuCOBOL configuration file. In the "default.conf" file the allowed binary sizes are 1-2-4-8 (or 8, 16, 32, and 64 bits). Since values of 999 must be supported, ITEM-1 and ITEM-2 would both be 16 bits little-endian, assuming the default.conf is used and the instruction set is x86/AMD64. Kind regards, -- https://www.arnoldtrembley.com/ -- This email has been checked for viruses by Avast antivirus software. www.avast.com
Back to comp.lang.cobol | Previous | Next — Previous in thread | Find similar
GnuCOBOL 3.2 and CBL_OR. What am I doing wrong? Bruce Axtens <snetxa@hotmail.com> - 2024-04-06 09:48 +0800 Re: GnuCOBOL 3.2 and CBL_OR. What am I doing wrong? Arnold Trembley <arnold.trembley@att.net> - 2024-04-06 04:10 -0500
csiph-web