Search code examples
assemblybinaryfilescobollanguage-design

Does COBOL force the first 6 characters of a line to be numbers because it compiles easier to binary executables?


I was watching a Ben Eater video and noticed that first 8 characters of a bin file line all had some form of address and remembered COBOL. Are these related or just coincidences? Is it just a convention making compilation easier?


Solution

  • Answer: No, there is no COBOL compiler that forces the sequence as it always was for either the people that operate the punchcards COBOL originally was written on - if you ever drop those it was quite useful to has the sequence numbers in there. As those numbers were punched, too - there also were sort machines that would take a pile of punch cards and sort them for you. Later on people felt that it was also good to orientate in the program (before you had IDEs, jump shortkeys, big screens, ...).

    At least one COBOL compiler has an optional warning that you can enable - in this case the compiler will check that the content is either whitespace or an increasing number - but that's for the programmer, not for the compiler.

    In COBOL itself - as far as I know, definitely even back in COBOL74 - those numbers were never for the compiler. The VAX COBOL74 manual says:

    Sequence Number Area - Character positions 1 through 6. Reserved for source line sequence numbers that enable you to locate and edit source lines in your program. The compiler ignores the contents of this field.

    For jumping around - beloved GO TO, but also PERFORM - COBOL has paragraphs (and later also SECTIONs).

    While many people do code COBOL in fixed-form reference-format only a subset has those numbers in there and actively use them, but I've seen a lot of people using it for marking changes that belong together or have short docs / programmer labels in there (and or after column 72).