BASIC, Number Guess

Now that I’ve completed the Assembly version of this little game, I want to contrast the required Assembly source with the equivalent BASIC source.

For those that don’t know, BASIC is a simplified computer language that uses an English like syntax. The word BASIC stands for Beginners All-purpose Symbolic Instruction Code. On the Atari 8 bit it is an interpreted language, meaning your program source does not compile down into machine opcode instructions. Rather the BASIC program itself executes each line of a programs source code on the fly when its run (interpreted).

BASIC often was, and perhaps still is in some cases, the first language a new programmer learns. It was designed to be easy to use, and it was included with many (now) vintage computers. Often these computers booted straight into BASIC if no other programs were present – as was the case with the Atari 8 bits. Today there is debate surrounding BASIC’s relevance.

From my point of view, BASIC and Assembly may as well be complete opposites.

Assembly Source

First the Assembly source code (in Mac/65 Assembly) for Number Guess, as presented in the last post.

BASIC Source

I crated two versions. The first version follows the same flow format and line numbering for an easy comparison. The second is shorter version without the same flow restrictions imposed. Both BASIC versions of Number Guess are in Atari BASIC.

Version 1

This is version that emulates the assembly program flow and line numbers to make an easy comparison. Any line number here can be matched up to the same line in the Assembly source above. The Assembly version will generally require more steps (lines) to do the same thing.

Comparison

See, BASIC does a lot of work for you! But at the cost of speed and the fact that BASIC must be loaded in some form before your program can be executed. With Assembly programs they can be run without any other programs (or interpreters) loaded first, which makes more memory available to your program.

Results

First a screen shot of the Assembly version being run:

Now a screen shot from the game being played with the first BASIC version:

And lastly, a screen shot from the game being played with the second BASIC version:

As you can see they are basic-ally the same. 😉 The only real difference with the BASIC versions is there is not a space after the “?” when the user inputs the guess.