Lightspeed C
Most serious Atari 8-bit users, learn BASIC and many try assembly language,
but the trend in the computer industry and education is toward high-level
languages such as Pascal, C and Ada. The current language of choice for
the Atari ST and most other personal computers is C. If you're ready to
move up to the structured programming world of C, for just a small investment,
Lightspeed C ($34.95) is just your speed.
is slightly
quirky in
Lightspeed C.
This C compiler comes on several disks and includes Lightspeed DOS as well as support files for SpartaDOS. A runtime library is required for SpartaDOS, but it's integrated with Lightspeed DOS. Everything you need to create an executable C program is provided with the compiler, linker and optimizer. You can use the C program editor (CEDIT) to create your own programs or develop them with an editor of your choice.
Lightspeed C supports floating-point and trignometric functions and provides many other features, such as a fast graphics package, that you would not expect to find in such an affordable program.
Floating-point is rather quirky in Lightspeed. All your variables must be declared as six-character strings in-stead of "float" values. For example, in standard C we would declare and multiply two floating-point numbers as follows:
float x, y, z;
x = 1.75;
y = 3.45;
z = x *y;
printf("%f TIMES %f is %t\' x, y, z);
Here's how you do it in Lightspeed C:
char x[6], y[6], z[6];
atof(x, "1.75");
/ * Ascil to floating-point * /
atof(y, "3.45");
/* conversion */
fmul(x, y, z);
printf("%f TIMES %f is %f\", x, y z);
I had few problems using Lightspeed C to create a sophisticated fractal generation program, which is floating-point intensive. The listings for this fractal demonstration are bonus files on this month's Antic Disk, details are explained at the end of the article.
The biggest problem with floating-point in Lightspeed is there is no support for floating-point compares (in IF and WHILE statements). It takes some unusual string manipulation techniques to handle the job.
1. Complete Mandedelbrot Set, generated with a Lightspeed C program.
2. Extreme close-up of the image on the opisite page.
INTEGRATED ENVIRONMENT
The most impressive feature of Lightspeed C is its totally integrated
programming environment-if you use the C editor. CEDIT is virtually identical
to the editors in MAC/65 and BASIC XL in that you use line numbers for
referencing, and auto-entry is supported. From here, the power of Lightspeed
becomes apparent.
Pressing [BREAK] to exit the auto-entry mode invokes the Ligitspeed syntax checker. The code you just entered is immediately checked for syntax errors, saving you valuable time in debugging compile errors. The syntax checker isn't smart enough to check for multiple line statements, however, occasionally reporting bogus errors. For example, the following would result in a syntax check error with an "unbalanced parenthesis" indication:
1200 x=((a + b)
1210 * (c + d));
The code above is correct, however, and won't generate a compile error. This is not a bug in the syntax checker, just a limitation in that it only checks syntax by physical lines and not logical lines.
Line numbers are used only for reference. CEDIT lets you list a code block to the display and then use the cursor keys to perform full-screen editing. If new code needs to be inserted, the auto-entry mode simply asks for the line to follow with new code. You need not worry about running out of line numbers while inserting either, since CEDIT will take care of this automatically. This is an improvement over MAC/65 or BASIC XL, which force you to stop code entry, renumber, and then continue inserting.
Once your source code is complete, you can save it to disk or compile it with auto-save. CEDIT uses Light-speed DOS and SpartaDOS to full advantage, simulating batch-command files. You can specify compilation of your source code, automatically followed by LINK (the linker) and RUN. If there's an error during compilation, enter the drive number containing CEDIT. Control will go back to CEDIT, with the errant line displayed as well as a descriptive error diagnostic. If no errors occur, the intermediate file is LINKed and then RUN.
Use the FASTER utility to optimize a compiled file. According to the documentation, FASTER can be part of the compile, link and run command line. This confuses Lightspeed, however, and the linker attempts to link your program with FASTER .CCC and create a FASTER.COM file, thus trashing your FASTER utility. Generally I just compile, link and run until the program is fully debugged. Then I run FASTER separately. After optimization, relinking results in a smaller, faster program.
Using a RAMdisk or a hard disk speeds up the whole process considerably. Running Lightspeed C from floppies works just fine, but it's rather slow. You cannot compile directly to memory as you can with ACTION! or MAC/65.
SpartaDOS users will need RUNTIME.OBJ on the same disk as the .COM file created by the linker. When the .COM program is executed, the runtime support library is retrieved from disk automatically. You can put the runtime and executable files on disks with Atari DOS 2.0 or 2.5, or with just about any other DOS disks, and run them if the LOMEM doesn't conflict with the memory requirements of the Lightspeed files. Memory use is reported by the LINKer program.
THE MANUAL
The Lightspeed C manual is well-written and complete, except for the
notable lack of an index. All other C manuals I've used have a full alphabetic
list of the functions supported. Lightspeed has a handy command summary-by
category-in the middle of the manual. (It should have been printed on the
inside cover for quicker access.)
Kemighan and Ritchie's C Programming Language is considered the standard for all C compilers. Lightspeed C measures up quite nicely, considering the 8-bit's memory limitations and a low-tech microprocessor like the 6502. Appendix A of the Lightspeed C manual covers all its differences and shortcomings relative to the Kernighan and Ritchie standard-a very honest and useful reference.
If you want to get into the more advanced features of C, such as structures, unions and multidimensional arrays, forget it. Lightpseed C can't handle them. This is its most significant limitation.
Lightspeed C makes the transition from BASIC to C painless with equivalent functions for PEEK, POKE, GRAPHICS and more. The most-used procedure of C has to be printf-print formatted output. Lightspeed supports it fully, including output of floating-point numbers.
If your application is too large to fit in memory, it can be broken
up into separate modules. Lightspeed C lets you chain between programs,
with a command line DOS such as Sparta-DOS or their own Lightspeed DOS.
C has found a
permanent home
on my hard
drive.
File input/output conforms closely to the standard. Lightspeed provides full support for Player/Missile Graphics and an advanced graphics manager package with functions like mbox, mfill, circle and more. DCOPY comes with Lightspeed to help manage your files.
I have found Lightspeed C to be complete and extremely user-friendly. I have been programming in C on the ST, PC and mainframe computers for a couple of years now, and I find the Lightspeed programming environment among the most elegant. With all the other "bigger computers" you must manage your file creation with a MAKE facility. Lightspeed C automatically generates your MAKE files for the linker.
You won't be able to write extremely large applications in Lightspeed without a lot of chaining, since its smallest runtime library is over 7K. Lightspeed C is a welcome relief from the tedium of assembly language programming and chaos of developing large BASIC programs.
Lightspeed C has found a permanent home on my hard drive and is currently my 8-bit language of choice for utilities and graphics development. Try it-you'll love it.
DEMOS ON DISK
To grow your own fractals you will need MANDEL.COM, MANVIEW.COM and
RUNTIME.OBJ from this month's Antic Disk. A complete fractal picture is
also on the November 1988 disk. Choose selection 5 from Side A of the Antic
Disk to read complete operating instructions. And for full explanation
of how fractal images are created on your computer, see the April 1986
Computer Mathematics issue of Antic.
RUNTIME.OBJ comes from the Lightspeed C support library and is used here by permission of the manufacturer. It loads automatically when you execute either of the other two programs.
MANDEL .COM generates the fractal pictures, a slow process with any computer and software. Each completed image will require four hours or more. Load the program from DOS and select your parameters by following the prompts. Sample values are included at each prompt to start you off, or you can select values following the instructions in the HELP file on Side B of this month's disk.
MANVIEW.COM is used for displaying finished fractal images. Load it from DOS and follow the prompts. Press [RETURN] to move to the next picture and press [ESC] to return to DOS.
LIGHTSPEED C
Clearstar Softechnologies
P.O. Box 140
Harrells, NC 28444
(919) 532-2359
$39.95, 48K disk
On the Antic Disk: LSPEEDC.TXT Download / View
,
MANDEL.COM Download / View
,
MANVIEW.COM Download / View
,
RUNTIME.OBJ Download
,
FRACFULL.PI4 Download