05 HE COMP PIC 9999
05 LL COMP PIC 9999
05 OCOMMA COMP PIC 9999
05 SPACEW COMP PIC 9999
05 ORTEXT COMP PIC 9999
05 LD COMP PIC 9999
05 EXCLAMATION COMP PIC 9999
01 FILLER REDEFINES HELLOWORLDBINARY
05 HELLOWORLDTEXT PIC XXXXXXXXXXXXX
05 FILLER PIC X
MOVE 51333 TO HE
MOVE 37779 TO LL
MOVE 38507 TO OCOMMA
MOVE 16614 TO SPACEW
MOVE 38553 TO ORTEXT
MOVE 37764 TO LD
MOVE 23104 TO EXCLAMATION
Required some changes to become truly alphanumeric source only.
PROGRAM-ID can be dropped. You get a generated program name (see messages).
WORKING-STORAGE can be dropped. Again the compiler moans.
Since both of these lines previously had missing full-stops/periods, which are no longer relevant now that the descriptions are entirely missing, the number of error messages is the same as before, and still does not affect the generated code for the program.
In changing COMP-5 to COMP, the VALUE clauses are no longer allowed, as COMP 9999 is only four decimal digits whereas COMP-5 is a two-byte binary with all bit-values available.
The values in the MOVEs are the decimal values which give the binary values which give the pairs of characters.
Even though the COMP fields have four digits, and do not allow VALUE clauses with more than four digits, you can use more digits in the MOVE of a literal value without truncation at that point... don't ask me why. Compiler option DIAGTRUNC (which I have turned off) will produce Warning diagnostics for these.
Compiler option TRUNC(BIN) could be used to treat COMP as COMP-5, but the MOVEs are another way to do it.
Since it is COBOL, the output must be in UPPER CASE (a lie, but just for fun).
OK, relented, now produces:
Which, being an odd-number of characters, required some further changes, since we can't have odd-number-byte binary fields with this compiler. Look at that line of 13 Xs! It would normally be written as X(13), but can be as I've shown...
And ORTEXT is needed (or not OR, anyway) as a name because OR is a reserved word to the compiler (it means OR, of course).
These are EBCDIC values, not ASCII, since it is running on an EBCDIC-aware, and Big Endian, box.
Oh, COBOL requires lots of full-stops/periods. I left them out (they're banned) so got lots of compile messages. Just told the compiler to generate the code anyway (none of the messages relate to the object code).
Even without DIAGTRUNC, the messages are now up to 17...
1 IGYDS1003-E A "PROGRAM-ID" paragraph was not found.
Program-name "CBLNAM01" was assumed.
2 IGYDS1082-E A period was required. A period was assumed
3 IGYDS1082-E A period was required. A period was assumed
Same message on line: 11
3 IGYDS1040-E A data item was found in the "DATA DIVISION"
before a section header was encountered.
"WORKING-STORAGE SECTION" was assumed.
4 IGYDS1082-E A period was required. A period was assumed
Same message on line: 5 6 7 8
9 10 12 13
14 IGYDS1082-E A period was required. A period was assumed
15 IGYPS2145-E A period was required. A period was assumed
23 IGYSC1082-E A period was required. A period was assumed
before "END OF PROGRAM".