Classic Computer Magazine Archive A.N.A.L.O.G. ISSUE 1 / JANUARY/FEBRUARY 1981 / PAGE 6

Parlez~vous Pascal?

COMPUTER LANGUAGES
By Charles Bachand

Picture if you will two doctors huddled together in a corner of a hospital cafeteria talking shop. As you approach these two learned men and try to listen in on their conversation, you will no doubt become confused and bewildered by the terminology used. Items such as scalpels, hemostats, and respirators will probably have little meaning to you. These terms are foreign to you. It is as if you had just arrived in another country. The same is true of computer languages. Computer languages are different because they perform different functions, different jobs.

Meanwhile, back at the hospital, a dentist joins our two colleagues in the cafeteria. He is much more at home in this setting than we will ever be, but he is not completely accepted as an equal. The dentist would like nothing better than to talk about cavities and molars and the cleaning of teeth, whereas our two friends are busy discussing heart transplants and kidney operations and Mrs. Smith in room 3 1 A who has a terminal case of bad breath. We see that the dentist is left out of the conversation. Not because he isn't a doctor, but because he wants to talk about dentistry, a different dialect of the language of medicine.

The analogy could have been made using carpenters and plumbers, cowboys and indians, or even Laurel and Hardy. But the points to stress are that there are many different languages and there are many different dialects within any given language. This goes for computer languages as well as for human languages. There are many different computer languages. There are many dialects within any one computer language.

Differences in computer languages are mostly brought about by their use or function. FORTRAN, for example, (its name stands for FORmula TRANslation) was designed for use by scientists. In fact, they were usually the only ones to access to computers back in the 1960's. In those days, computers were made of tubes and transistors instead of the large scale integrated circuits used in the mini and micro computers of today. And because scientists use numbers extensively, FORTRAN was designed with number handling in mind. It is a great language for processing large quantities of numbers, what is called number crunching. It can work with integers (whole numbers), real numbers (floating point numbers), and complex numbers (imaginary).

FORTRAN example:
C - READ THREE NUMBERS AND PRINT THE SUM.
C - READ (5,100)X,Y,Z
100 - FORMAT(3F10.2)
SUM=X+Y+Z
WRITE(6,200)SUM
200 - FORMAT(FIO.2) STOP END

Differences in computer languages, and especially among the different dialects can be caused by the wide range of hardware used in today's computer systems. ATARI software is geared heavily towards color graphics and sound effects. A Radio Shack TRS-80 does not have the software to run such devices because it does not have the necessary hardware. It would be a waste of time for everyone involved to write software for hardware that is not available.

The only thing that FORTRAN is not very good at is working with character strings. It does have some elementary string handling abilities, but they are mostly for labeling the printed data. It is just not very good at handling more complicated string manipulations. This brings us to another very important language.

Its name is COBOL. If there are any loyal fans of the now cancelled and sorely missed television series "BATTLESTAR GALACTICA" reading this, they will no doubt think that I am talking about the planet on which all human life is supposed to have evolved. However, since I am talking about computer languages, I must mean COBOL (COmmon Business Oriented Language).

COBOL is not a very good language for number crunching. It was not meant to be. Instead it keeps inventories for department stores, prints out reports on productivity, updates medical records for hospitals, as well as other business activities. COBOL is designed for a business environment, unlike FORTRAN which is geared towards scientific applications. It is a very wordy language. You can read a COBOL program like a chapter in a book and understand what is going on.

COBOL example:
START.
OPEN INPUT MASTER-IN OUTPUT MASTER-OUT.
NEXT-RECORD.
READ MASTER-IN RECORD AT END GO TO FINISH-IT.

(continue on page 7)

MOVE HOURLY-RATE IN PAYROLL-IN TO HOURLY-RATE IN PAYROLL-OUT. MOVE HOURS WORKED IN PAYROLLIN TO HOURS-WORKED IN PAYROLL-OUT. MULTIPLY HOURLY-RATE IN PAYROLLOUT BY HOURS-WORKED IN PAYROLL-OUT GIVING PAY-CHECK. WRITE PAYROLL-OUT. GO TO NEXT RECORD.
FINISH-IT.
CLOSE MASTER-IN MASTER-OUT.

There are a couple of reasons I can think of, on why you are not likely to see any of the above languages gracing your ATARI computer. There is very little call, and even less need, for programs like COBOL or FORTRAN on such a small and inexpensive system. Now you might consider the $500-$ 1,000 that you spent on your system so far to be a lot of money. It is, but there are computer centers out there that spend that much in a month on electricity alone. By their standards, an ATARI computer system and anything that is remotely like it is a little toy. Luckily, you and I do not think this way and are having the time of our lives with these toys.

These corporate executives with their big machines have tens of thousands of dollars to spend on business and scientific software. We, on the other hand, just do not have this kind of cash to throw around. Even in a microcomputer environment, FORTRAN is selling for about $400 and COBOL costs twice that at $800. These items cost big bucks. No wonder they will not likely be found in any future catalog put out by ATARI.

You probably will not be able to use these big computer languages on your ATARI because they are just that, Big. Memory requirements run up to 48K of RAM (random access memory), which completely fills up an ATARI 800. And a model 400 is out of the race completely with its memory limit of 16K of RAM. The fact that FORTRAN and COBOL are disk based programs 'makes them even less attractive. This is no problem for those among us who have bought a disk drive or two, but that is maybe 10% of all ATARI owners. If it were possible to use cassette tape, it would take hours, even days, to get a program running. Indeed, there are far too many problems involved to call for the implementation of these languages at this time. Don't get me wrong. If someone should come out with either language in a small and inexpensive form, I will be one of the first to buy it. But I will not be caught holding my breath, waiting for that day.

A language in which programs can usually be written in minutes is BASIC (Beginners All-purpose Symbolic Instruction Code). This language is implemented on just about every computer made today, large or small. BASIC as written for our ATARI computer is an interpreter. This means that the programs we run are kept in the computer's memory where BASIC analyzes them and performs the necessary actions. Its operation is usually quite slow compared to other languages, but it has the advantage of ease of program modification and is very easy to learn.

BASIC example:
10 REM ACCEPT 3 NUMBERS AND PRINT THE SUM
20 REM
30 INPUT A,B,C
40 LET S=A+B+C
50 PRINT S
60 END

Now, how does one go from super slow to lightning speed? The answer is to write your programs in machine language, the language of the computer. In this way, you can achieve the fastest execution time possible and make the best use of available memory resources. To attain this goal you must think like the machine thinks. If you can break down to the smallest detail what you want the computer to do and just how you want the computer to do it, you have the problem solved. Now, not too many of us can think on the level that our machines operate at. For example, who is going to remember that the instruction to jump to a subroutine is 32, or to store value in memory you use 141. There are about 150 such instructions, known as opcodes, in the 6502 instruction set (the 6502 microprocessor chip is the one used in all ATARI computers and Video Game systems). If you were to try to program something large, like Star Raiders in machine language, you probably would be put away in an asylum. Luckily for us, someone came up with a system to remember these instructions called MNEMONICS.

With mnemonics, machine language comes very easy. Instead of having to remember that number 32 is to jump to a subroutine, all we have to remember is JSR. And number 141, to store data is simply STA. This is indeed a marvelous system to work with. Great things have been done and can still be done with it. But there is one little problem. The computer hasn't the first clue as to what you are talking about. It doesn't understand JSR's and STA's. It can only understand the 32's and 14 1's. What we need is a program that the computer can understand; that will convert into its language what we understand. This program is called an ASSEMBLER. It is rumored to contain a text editor, an assembler, and a debug program. The Editor is used to create text files in the computer's memory that can be saved on either cassette or' disk. It will likely have the editing functions available in the BASIC cartridge. The Assembler will do the conversion from mnemonics to computer code for you. The Debugger is a program to keep you in control of a machine language program. You will be able to examine and modify registers and memory locations, and trace a programs execution.

The following programs retrieve two values from the computer's memory at locations 1 and 2, adds them and stores the answer in memory location 3. The first is written in machine code and the numbers

(continue on page 8)

are represented in the format known as hexadecimal notation or hex for short. While decimal numbers are represented by the digits 0-9, hex numbers have 16 combinations. The possible hex digits are 0-9 and A-F. So our JSR and STA from the description on mnemonics which were represented in decimal as 32 and 141, become 20 and 8D. The second is an Assembly language version of the first. Notice how much easier it is to comprehend what is going on over the machine coded version. This program will run a thousand times faster than BASIC doing the same thing.

Machine code example:
A5 01 18 65 02 85 03

Assembly language example:
LDA 1 ;LOAD LOCATION 1
CMC CLEAR CARRY BIT
ADC 2 ADD IN LOCATION 2
STA 3 PUT IN LOCATION 3

Listing from ASSEMBLER:
A5 01 LDA 1 ; LOAD LOCATION 1
18 CMC ;CLEAR CARRY BIT
65 02 ADC 2 ADD IN LOCATION 2
85 03 STA 3 PUT IN LOCATION 3

The language PILOT will be available along with the ASSEMBLER cartridge this year. PILOT is what is known as an instructional language. It is used for teaching many subjects in both high school and college. It is essentially a question and answer language. PILOT asks questions of a student, accepts answers, checks if the answers are correct, and informs the student. It can then either ask the same question again or go on to another. An example might be to ask you to name a computer language mentioned in this article and then check to see if you were paying attention.

PILOT example:
*STRT
T : NAME A LANGUAGE THAT STARTS WITH "P"
A :
M: PILOT, PASCAL
Y: VERY GOOD. YOU ARE RIGHT.
N: YOU WEREN'T LISTENING. TRY AGAIN.
JN: *STRT

The last language that I know is due from ATARI is Pascal. This is currently my favorite language, with ASSEMBLY coming in a close second (I go crazy over fast execution speeds). Pascal is a very exact language. All variables must be defined in the program. It is also harder to learn than BASIC. But once you have this language mastered, you will be able to think in Pascal. It is usually referred to as a structured language. This means among other things that it is a GOTOless language. While GOTO statements are allowed in some cases, heavy dependence is a sign of poor programming. It is possible to write large and intricate Pascal programs without using a GOTO statement even once. Another plus factor in favor of the language is that it executes up to five times faster than a BASIC program doing the exact same thing.

Pascal example:
PROGRAM DEMO;
VAR
X,Y,Z,SUM:INTEGER;
BEGIN
(*REPEAT UNTIL SUM = 0
REPEAT
WRITE ('ENTER THREE NUMBERS?');
READLN(X,Y,Z);
SUM:= X+Y+Z;
WRITELN ('THE SUM IS',SUM)
UNTIL SUM = 0
END.

An article for a computer magazine is a very easy thing to write. In only a couple of days you are on your way to fame and fortune. Well maybe not fortune, but just think of how proud you will be when after hours of trying to explain to your Aunt and Uncle, why you bought the computer in the first place, you produce the issue of ANALOG that contains the article that took you three whole weeks to write and show it to them. They will be so impressed that your ideas were accepted for printing that they will just have to take you seriously from then on. So compose that article or write that program. It does not matter if you think it was done before. This is a new publication, with a new readership. These people haven't heard it before. And it doesn't matter if your spelling is terrible. These articles are proofread before being printed. It will be fixed up. If your ideas are important to you, they are important to us, and are worth printing. All it takes is a pen and paper.

Parlez-vous Pascal? — original illustration or listing

Digitized by CyberRoach Publishing for CyberRoach’s Digital A.N.A.L.O.G. Archive; restored here with permission.