Classic Computer Magazine Archive COMPUTE! ISSUE 50 / JULY 1984 / PAGE 6

Compilers For The 64

I would appreciate some clarification on compilers. I have seen advertisements for several compilers (DTL-BASIC, and Metacompiler for Forth) and would like to know if they actually produce ML code that will run on any 64.

In other words, can I write a program in BASIC or Forth, run it through the compiler, and have ML code that will run on another 64 that doesn't have access to the compiler?

Paul Filiant

There are two types of compilers: those that produce native code (machine language), and those that generate pseudocode (P-code). P-code compilers translate the source program into another, smaller, faster language. This pseudocode must still be interpreted, like BASIC, but it's interpreted much more quickly. Also, P-code interpreters can run the same P-code program on many machines, whatever the microprocessor used. But to run a P-code compiled program, you must have a copy of the P-code interpreter.

Other compilers generate true machine language. This has the advantage of speed, if not portability. The object code produced by the compiler needs a set of general-purpose subroutines. Otherwise, the compilation of PRINT would expand into a large chunk of machine language each time it is used. Instead, it is more memory-efficient to compile PRINT into a subroutine call to the general PRINT routine. The set of subroutines required is called the runtime package, and is included in the compiled program.

A compiler generally produces a complete program that will run on any machine, without the compiler itself. However, we now run into the problem of copyright. You have written and therefore own the rights to the original, uncompiled program, but who owns the compiled program? You might think you retain the copyright, since compiling is something like translating a book into a different language.

However, you don't own the runtime package. Some companies require you to pay a royalty for selling the compiled program. Other companies require a special security key to run the compiled program. (A security key prevents a program from running without it. It is usually a ROM chip or some device that plugs into a joystick or cassette port.) This is like a royalty; you must buy security keys for every copy of the compiled program you distribute. Still other companies give you the freedom to distribute your compiled code, as long as you include a notice specifying that it was compiled with their product. Be sure you understand what copyright rules are enforced by the compiler company. If in doubt, write them.