Classic Computer Magazine Archive ANTIC VOL. 5, NO. 5 / SEPTEMBER 1986


"Don't even think about another C compiler"


Megamax C ($199.85), a new C compiler for the ST, is a full Kernighan & Ritchie implementation of the language. It supports floating point, overlays, recursion, batch processing and custom libraries. Aside from the Digital Research Inc. (DRI) Alcyon C, which comes in Atari's $300 ST Developer's Kit, Megamax is the only C that comes with a resource construction set that creates GEM objects such as menus, dialog boxes and icons. It also supports all the AES, VDI and GEM routines.

Megamax C has an environment shell that makes program development a joy. The shell supports and allows access to the editor, compiler, linker, librarian and any other program that can run in TOS. Initiation of programs is through drop-down menus.

The shell has a locate function which lets you tell the system where you have placed development programs such as the compiler and linker, as well as a MAKE file containing the compile and link commands for a specific program. The shell takes its commands from athe MAKE file and runs automatically, permitting a compile and link with one click of the mouse.

To use this file, pull down the utilities menu and click on the MAKE line. If any changes have been made, the shell then compiles and links the program. Thus development in the shell is efficient: you click on the editor, modify your program, leave the editor and then click on the MAKE file. Errors would be placed in an error file, cancelling the MAKE process, and you are returned to the editor with two screens coming up automatically. The first screen displays the source code to the program you were compiling and the second shows the error file. This allows you to correct the errors while looking at the error file. The shell also lets you to rename or delete files and use whatever desk accessories you have running.


One of the first things you want to know about a programming language is its speed. I used a 3.5-inch disk system and a Sieve program to compare this compiler to Alcyon C. The Alcyon compiled and linked the Sieve program in six minutes, seven seconds. The resulting code was 11,852 bytes long, taking 2.47 seconds to run. The Megamax compiled the Sieve in one minute, 34 seconds--almost six times faster than DRI's Alcyon C. The code was 6,049 bytes long--just over half the length of the DRI compilation. And it took 2.28 seconds to run.

I also compared the compile and link time for the Apskel.C (application skeleton) program that comes with both packages. The DRI compiler took four minutes, 16 seconds, producing object code 6,086 bytes long. The Megamax C compiler ran in 41 seconds and produced 4,808 bytes of object code. The DRI-supplied linker took two minutes, 17 seconds to link, producing a program of 4,315 bytes. The Megamax linker took 59 seconds and produced a program 4,058 bytes long. With Megamax C you can comfortably do development on a single disk. The DRI system requires two disks or a hard disk drive.


The mouse-driven editor is easy to use, Which I found hard to get used to at first--being a veteran of MicroEmacs and other keyboard-controlled editors.

The design of the editor shows that a great deal of thought went into it. The main commands are accessible from both the drop-down menus and the keyboard. You can open multiple file windows at once and move information between them. The windows can be in Overlap or Tile mode (where they don't overlap). You can cut and paste blocks, delete marked blocks or shift marked text right or left.

One real lifesaver is the Undo key buffer--if, for example, you've erased half of your program, just press the Undo key and it all comes back. This has saved my skin several times already.

The editor's configuration menu allows it to be customized to almost anyone's taste. You can set the tab size, toggle the auto-indent mode, choose the auto-save feature, make the tabs visible, or turn the case sensitivity on and off. The auto-save feature is handy if you live where electric power isn't too stable. The editor supports full search-and-replace features as well as a GOTO-line command. It also has a built-in table of the C operators and their precedence, which adds a nice touch. Finally, there is an information screen that gives you statistics on the program you are currently editing.


A primary reason for the Megamax C compiler's speed is that it is a single-pass compiler. It only needs to read once through your source code to generate code for the linker. This is quite different than DRI's Alcyon C, which is a three-pass compiler. Single-pass compilers often have restrictions on how you must place your code (most often a function must be defined before it can be used). I am happy to report that Megamax has somehow gotten around this. After using that system for some time now, I have yet to run into anything that hints at those single-pass limitations.

The Megamax compiler also allows in-line assembly code, so you don't need to buy an assembler for time-critical routines. Unlike some other languages, the assembler isn't cut-down, nor does it require you to do most of the assembly by hand. Rather, it's full-featured. Just type ASM and a left curly bracket. From this point on, until a right curly bracket is encountered, write as though you were in an assembler, and the compiler will act as one.

Since the assembler is part of the compiler it has two major advantages. First, the code is efficient and well integrated into the program. Second, all the variables that would normally be accessed by a function are available to the assembly code, greatly simplifying the passing of data to the assembly routine.


The linker is more complex than the DRI counterpart and it allows use of multiple libraries. Aside from the default system library, you can add your own custom libraries containing your functions and routines. The linker will load in only the library modules that the code needs. So your programs use only the routines necessary, instead of having the code for the whole library tacked onto it. The linker handles the process of overlays automatically. You don't need to specify anything in your code other than the word "overlay." The linker takes care of all the headaches.

The linker also gives you priority over the functions in the libraries. Any name that you define in your program is given precedence over the one in the library, so you can customize functions as the need arises. But the cost of all these benefits is speed. I found the Megamax linker to be only twice as fast as the DRI linker.

As if all of these features weren't enough, the Megamax package also includes a code improver (speed increase about 3 percent, size reduction about 10 percent), a disassembler and a librarian for setting up your own libraries.

The resource construction set is also a nice surprise. It seems easier to use than the Atari version. The documentation is complete and includes all the ST system calls. But don't expect to learn the language or the interrupt system from the manual, it was written to provide information on the implementation, not to teach.

Under Megamax's upgrade policy, you send in your master disk and a check for $20, and you'll receive the latest revision and all necessary documentation updates. Also, them are no royalties for selling programs produced with Megamax.


There an a few drawbacks to Megamax C, though. It cannot compile into blocks larger than 32K, due to the limits of the computer that the progam was ported from. This means you must use overlays for large programs.

Arrays also cannot be larger than 32K, so moving an entire screen gets a bit tricky if you expect to do it in an array. But you can access plus or minus 2 billion bytes by using pointers, so this isn't very hard to overcome.

Megamax C is a good deal. If you plan to program in C on the Atari ST, don't even think about another C compiler. This one has it all. The ease of use and the speed of compilation would pay for Megamax C just in the time saved.

Megamax, Inc.
P.O. Box 851521
Richardson, TX 75085
(214) 987-4931