ZIP Basic Compiler

Authors

Publication

Pub Details

Date

Pages

The resident language in the T/S 2068 is Sinclair BASIC (an altered version of Microsoft BASIC). BASIC is a relatively easy language to learn and thus an easy means of communicating with the microprocessor. The microprocessor can perform approximately 1/2 a million operations per second. Then, why is BASIC so slow? The processor only uses two numbers (1 and 0). Most humans cannot easily communicate or think in pure binary, and thus we need other “languages” in order to talk with our computer. Many microprocessor operations are lost while the computer laboriously translates from BASIC into machine code. Most programs you buy (especially games) are programed in machine code, bypassing BASIC, and are 100’s of times faster than any BASIC program you can write. Enter the compilers…

Compilers translate programs written in BASIC into machine code, eliminating the need to re-translate each time the program is run. ZIP is a program available for the T/S 2068 which can convert BASIC programs into fast-running machine code. The manual included with ZIP contains benchmark results (run on the Sinclair Spectrum) of BASIC vs. a British version of ZIP, showing speed ratios from 111:1 to 213:1. ZIP is an integer-based compiler (i.e., it only uses whole numbers–no fractions or floating point arithmetic). This compiler is an enhanced version of one published in the British magazine, “Your Spectrum”.

As an integer-based compiler, there are many commands which are not available. There are no mathematical functions available beyond +,-,*,/. You will not be able to compile programs containing any trigonometry functions (TAN, COS, SQR, ect.). Numbers are limited to the range of -32767 to 32767 (though the range of +/- 65535 is allowed if these numbers are not PRINTed, multiplied or divided). There are many other Keywords you may find necessary in some programming which also cannot be compiled. Unfortunately, the manual does not list all of the commands which are not allowed. Trial and error and some common sense must be your guide. Some of the other commands which are not compilable are: READ, DATA, DEF FN, CIRCLE (nor arcs using DRAW-though straight lines with DRAW is acceptable), SCREEN$, SAVE, LOAD, BЕЕР, ND, INKEY$. Some programmers will find the absence of character strings a major drawback. With proper programming, one can overcome many of these shortcomings (i.e., store character codes in a numerical array and print them with a FOR/NEXT loop using PRINT CHR$ A(X)). You are limited to 26 single-letter variables and 26 single dimensioned arrays. Arrays must be DIM’ed with the program listing by constants and cannot be re dimensioned, as their storage area is reserved during compilation. The manual does include routines to simulate INKEY$, RND, BEEP and STICK. It is also possible to access BASIC or machine code routines from within a compiled program.

The manual states there is room for a “little under 13k” of a BASIC program for compiling, occupying lines 1-4999. In actuality, I found there is only room for about 10.7k, but this left insufficient memory for ZIP to compile. I had to reduce the BASIC program to about 8k before ZIP could completely compile my program. There is approximately 10.5k of memory to store a compiled program and variables. ZIP also an optimizer, which provides for faster running programs. According to the manual, removing this from the package will allow about 2k more of BASIC for compiling. Again I found this to be an overstatement. After removing the optimizer, I only discovered about 1K available.

Programs that are compiled by ZIP run at speeds approaching those of well-written machine code, but actual compiling can be a slow process. of course, you will have hopefully removed all bugs by testing the program in BASIC and will only have to compile once. Included with ZIP is a demo game (written in BASIC) to be compiled using ZIP. The listing of the demo game is a little over 3k and took about 31 min. to compile. (It appears that ZIP is written entirely in BASIC.) First there is a check of the BASIC itself. Checks are made for correct KEYWORDS and any translation is done before actual compilation begins. There are seven error reports possible during this stage and any illegal KEYWORDS are pointed out, allowing correction before continuing. This process took about 6-3/4 min. to complete. The rest of the time was involved in converting the 3k of BASIC into approximately 3k of mc. Error reports are also provided during the final stage of compiling. Aside from the differences in the amounts of memory available, I found that ZIP lived up to its claims. It is fairly easy to use and “user friendly” with its error messages. If the Timex ROM discovers a syntax error while running a compiled program, you will receive a normal Sinclair BASIC error report. It will not report the exact location of the error, only its nature.

ZIP is not a program for a novice BASIC programmer. One who knows how to manipulate a limited BASIC into a code that produces expanded results is best suited as a ZIP user. For those of you who would like to market a program, but feel your knowledge or the time involved in developing machine code is holding you back, the authors of ZIP allow you to sell any programs compiled by ZIP, no fees required…or perhaps you just want to speed up some of those interesting (but slow) BASIC programs in magazines or books…then ZIP may be for you. Before committing yourself to any particular compiler, be sure you can live with its limitations. (Note: There are very few compilers available for the T/S 2068. I know of a few available for the Spectrum, on which can handle strings and multi-length variable names, but not FOR/NEXT loops.)

Though ZIP was not designed as a machine code tutor, I found it can be quite the instructor. One can compile a series of BASIC commands and using a monitor, disassemble the compiled code, and receive some enlightening lessons in writing mc routines. ZIP comes in a book sized plastic case with one cassette (containing ZIP and a demo game) and documentation. I had no problems in loading my copy on the first attempt. The program was written by Simon N. Goodwin and Jon A. Smith and is available from Knighted Computers.

Products

 

Downloadable Media

 
Scroll to Top