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?
CodePudding user response:
These numbers were common at "this time"
In cobol, this numbers was used to jump around
Much like C/C labels
If you wanted to jump to other part, you used this lines You will se that lines jumped from 10 to 10, this was to create room for future new lines (IDEs were as limited as the compillers)
In Assembly, you could specify the exactly location of a bunch of code (a procedure)
Every code must have it's addresses, in assembly this is your responsibility (is a low level language, "you should do all the hard work")
Event that the Cobol/VB numbers looks similar and their usage is very alike, there is a important difference. Cobol numbers, are "local" to the scope and the compiler take some care of them. Asm ones, not only are Global references but will be on the exact same place on the executable*
* You can use some indirect refence
Answering you question: It's not there to help the compiler, is there so the programmer can reference and jump around.
One thing I do not remember is about "COBOL forcing the first....". I think that only the early versions forced you to, later was optional
CodePudding user response:
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).
