COMP-1 and confusion



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

COMP-1 and confusion

Postby polarlemniscate » Sat Jul 10, 2010 3:59 pm

Does anyone know what this program produces as output?

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. NUMBERS.
000300 AUTHOR. TEEBEE.
000400****************************************************************
000500* Simply transfer the present program to your favorite *
000600* mainframe computer, compile it, link it and submit some *
000700* appropriate JCL to run it. Its output tells the answer. *
000800****************************************************************
000900 ENVIRONMENT DIVISION.
001000 CONFIGURATION SECTION.
001100 OBJECT-COMPUTER. IBM-370.
001200 SOURCE-COMPUTER. IBM-370.
001300 DATA DIVISION.
001400 WORKING-STORAGE SECTION.
001500 01 THE-NUMBERS.
001600 10 FILLER USAGE IS COMP-1 VALUE -.24093455E+04.
001700 10 FILLER USAGE IS COMP-1 VALUE -.55439222E-47.
001800 10 FILLER USAGE IS COMP-1 VALUE -.33044246E-54.
001900 10 FILLER USAGE IS COMP-1 VALUE -.15622514E-50.
002000 10 FILLER USAGE IS COMP-1 VALUE .90854859E+00.
002100 10 FILLER USAGE IS COMP-1 VALUE -.27585575E-47.
002200 10 FILLER USAGE IS COMP-1 VALUE -.48936378E-36.
002300 10 FILLER USAGE IS COMP-1 VALUE .53763199E+00.
002400 10 FILLER USAGE IS COMP-1 VALUE .21482344E+74.
002500 10 FILLER USAGE IS COMP-1 VALUE .76006532E+00.
002600 10 FILLER USAGE IS COMP-1 VALUE -.22917763E-71.
002700 10 FILLER USAGE IS COMP-1 VALUE -.15607424E-50.
002800 01 THE-ANSWER REDEFINES THE-NUMBERS PIC X(48).
002900 PROCEDURE DIVISION.
003000 DISPLAY THE-ANSWER
003100 GOBACK.
003200 END PROGRAM NUMBERS.

My retired COBOL programmer friends tell me it produces some text (?) but as a total COBOL newbie (I can program in Delphi and Python, amongst others) I'm struggling.

Kind regards, I'm probably being dim.

Jim
polarlemniscate
 
Posts: 4
Joined: Sat Jul 10, 2010 3:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COMP-1 and confusion

 

Re: COMP-1 and confusion

Postby NicC » Mon Jul 12, 2010 3:49 pm

I would suggest you follow the indtructions in the comments in the ID Section. You can use a PC Cobol compiler. You should also look up the maual for REDEFINES and COMP-1
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: COMP-1 and confusion

Postby polarlemniscate » Mon Jul 12, 2010 9:52 pm

Thanks, but assuming I am just stupid and lazy, (and can't work a cobol compiler - I HAVE TRIED!) could someone just run this through a compiler for me!
polarlemniscate
 
Posts: 4
Joined: Sat Jul 10, 2010 3:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COMP-1 and confusion

Postby enrico-sorichetti » Mon Jul 12, 2010 9:56 pm

... but assuming I am just stupid and lazy, ...

then doing anything on your behalf would be just a useless waste of time
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: COMP-1 and confusion

Postby NicC » Mon Jul 12, 2010 10:21 pm

Anyway, there are 2 compile error messages - DISPLAY... and GOBACK should start in 'area b'

On the PC it displays a load of garbage but on the mainframe it displays a message in English. I think that if I cut and pasted the PC output to a file then one of my editors could be persuaded to read the file in EBCDIC rather than ASCII and I might then get the correct message.

It is all to do with how you interpret the bit patterns - you enter them as numerics and read them as text.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: COMP-1 and confusion

Postby polarlemniscate » Tue Jul 13, 2010 5:14 pm

okay, I'm prepared to understand this, but do you mean the english output is a readable string? If so, what string? If not, can you post the unreadable text and I'll have a go at translating it!
polarlemniscate
 
Posts: 4
Joined: Sat Jul 10, 2010 3:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COMP-1 and confusion

Postby Robert Sample » Tue Jul 13, 2010 6:01 pm

 Congratulations. Your answer is 'Big Blue Iron'.
is the precise output of the program.

If you use a PC compiler, you almost certainly will not get this result, which is based upon EBCDIC not ASCII. This can be done with any character string by doing something like (warning -- this is not tested code):
05  WS-TEXT PIC X(80) VALUE 'This is a test'.
05  WS-C1-VARS REDEFINES WS-TEXT.
    10  WS-C1-DATA OCCURS 20 USAGE COMP-1.
and then displaying the various WS-C1-DATA values.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: COMP-1 and confusion

Postby polarlemniscate » Tue Jul 13, 2010 6:15 pm

Thank you so much for this! I've been trying for ages!
polarlemniscate
 
Posts: 4
Joined: Sat Jul 10, 2010 3:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COMP-1 and confusion

Postby Robert Sample » Tue Jul 13, 2010 7:06 pm

Understanding this programs requires a good understanding of the internal storage formats for PIC X and USAGE COMP-1 variables. The same thing could be done on a PC COBOL compiler, but the data values would be completely different.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: COMP-1 and confusion

Postby Don Higgins » Mon Jul 26, 2010 1:00 am

I was able to compile, link, and execute this test COBOL program on my Windows Vista system using zCOBOL which is an open source portable mainframe COBOL compiler which generates HLASM mainframe assembler which is then assembled and executed running z390 which is open source portable mainframe assembler and emulator.

However, I first had to apply PTF 1126 to correct parsing error for floating point constants. There were 2 problems: the - exponent was being translated to _ and the unnessary + exponent was not being corrently handled. With these corrections, zcobol generted a valid HLASM assembler program which assembled and executed with the following display log:

15:00:07 numbers EZ390 START USING z390 V1.5.01ex2 ON J2SE 1.6.0_20 07/25/10
EZ390I Copyright 2008 Automated Software Tools Corporation
EZ390I z390 is licensed under GNU General Public License
EZ390I program = w:\work\z390\numbers.390
EZ390I options = SYS390(+zcobol\z390)
Congratulathons¢ Yotr answeq is 'Bif Blue Iron'¢
EZ390I instructions/sec = 2200
EZ390I total errors = 0
15:00:07 numbers EZ390 ENDED RC= 0 SEC= 0 MEM(MB)= 20 IO=185 INS=143

Notice the result is readable as zcobol and z390 do operate in EBCDIC default environment on Windows and LInux and execute all the problem state z/Architecture instructions. However there are a few characters that are off by a single bit. The differences are probably due to J2SE emulation of floating point not using enough guard digits. RPI 1124 was about the same sort of issue raised by another z390 user recently. For more on zcobol and z390 including previous presentations at SHARE visit www.z390.org.
Don Higgins
 
Posts: 1
Joined: Mon Jul 26, 2010 12:41 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post