Classic Computer Magazine Archive COMPUTE! ISSUE 38 / JULY 1983 / PAGE 10

Automatic BASIC To Machine Language Converter

Is there anything on the market that will convert standard BASIC programs into machine language? I need this for my Commodore 64 and its graphics.

Ben Savage

Your question is about speed: a program written in machine language can run a thousand times faster than the same thing programmed in BASIC. Some games, large sorting tasks, and other kinds of computation require that the computer run at maximum velocity. That means machine language.

There are large programs called compilers which do something similar to what you want. They take a BASIC program apart and generate a high-speed version written in "P-code," a fast-running language similar to Forth. You can expect a "compiled" BASIC program to run anywhere from 10 to 40 times faster. One minor drawback is that the compiled program will usually be somewhat larger than the original BASIC version.

There are also "optimizing" compilers which, during the process of compilation into P-code, also rearrange the program's structure to maximize efficiency. For example, the most commonly used variables in the program might be stored in zero page (the computer's first 256 memory cells) where storage and retrieval is far faster than it would be higher up in memory.

In any case, there is no way to turn BASIC programs into true machine language. You might want to use compilers for some programs, but also learn to program in machine language for those situations when speed is of the essence. Compiler programs for various computers are advertised in COMPUTE!.