ZX Computing
1st October 1983
Author: Patrick Cain
Publisher: Papermac
Machine: Sinclair ZX81
Published in ZX Computing #9
Advanced Programming For The 16K ZX81
The ZX81 is a good computer. Obviously its capabilities are restricted by price and size, but its abilities are great. Its potential greatness though may never be realised, as the challenge of highly impressive, similarly priced machines is not too far off. The weakness which will prevent the ZX81 staying off the challenge is not an on-board deficiency but improper development of realistic software. This is the opinion of Mike Costello, author of Advanced Programming For The 16K ZX81, an opinion which has much to justify it.
As author of several papers and programs for microcomputers and owner of a business publishing microcomputer software and magazines, Mr. Costello is ably suited to voice such opinions. Does then his book Advanced Programming For The 16K ZX81 offer any real alternative or redirection?
Obviously any advanced level of programming on a machine with as limited a level of Basic as that possible with the Z80A microprocessor requires the employment of direct programming in assembly language. Realising that this is true, there are three chapters dealing specificially with machine code implementation. The previous six chapters look at how, with thought and ingenuity, the Basic that is available may be used more effectively.
Before going any further it has to be said that from page one through the subsequent 126 pages it is assumed that the reader has already gained and developed his or her skills in Basic programming and has some elementary knowledge of the workings of the machine beyond Basic.
Two of the main drawbacks of the ZX81 are its restrictive available memory and its speed. Chapter one takes these two problems to task. By examining how and why there is an excessive use of memory and by offering suggestions as to how the call of the operating system upon the memory can be reduced. Following these suggestions will realiise much greater potential of the 16K RAM. Techniques too, to increase the inhibitive speed of the ZX81 will significantly increase the expectancy of the machine. Those techniques suggested do not call for anything too elaborate but merely point to methods the professional programmers use; each is simply described and detailed clearly enough to ensure that a good understanding of them is possible after only a few applications.
Many other books of this ilk make great play of Basic routines - short programs which allow the programmer to achieve more elaborate effects or 'fill-in- for deficiencies of the ZX81's version of BASIC. Often though these are self-defeating, demanding too much memory to allow useful subsequent programming. Thankfully those included in chapter two are not guilty of this.
One of those aspects of Basic which is deficient on the ZX81 is input. The best of programs can come to grief at the hands of a novice operator. Where it it not possible to prompt the correct type of answer by arranging for text to be displayed on the screen before the awaiting cursor, as in the ZX81, the likelihood of computer slaughter is even greater. To overcome this drawback, a small 30 line subroutine is listed, implement this and 'Hey presto!' suddenly you're in command, not only specifying where on the screen the input should go but also what type of input. To 'kill the cat' each line of the apparent magic is explained.
Similarly, the output capabilities of the ZX81 leave a lot to be desired. It is not possible to specify the format of numeric or string data using only those facilities on-board. Business applications on other machines have a statement like "PRINT USING" which allows the programmer to pre-define the number of decimal digits either side of a point, or to select any substring from a string. Such a facility would greatly enhanced the screen output of any data. Again, in the absence of such a tool, Mike Costello shows how a subroutine, PRINT USING, can be simulated. While he is certainly not the first to think of such a thing, the strength of his subroutines is that it does what is necessary and still leaves sufficient memory available for worthwhile programming.
A subroutine to simulate the READ DATA statement completes the chapter. Like the previous two utilities, it is effective, powerful and an obvious aid to writing better software.
Chapter four deals with Supergraphics, making the screen do things the way professional programmers do. However, nothing here falls into the innovative software category. The animation and screen drawing areas are fairly well-trodden ground in such books and in many they receive far better treatment.
Any serious real attempt of 'real' programming on the ZX81 must have a study of the computer's assembly language. Many books are available on the subject - however, too often they tend to leave the reader even more confused than ever. The cursory handling of the matter in three chapters in this book is sufficient to guide someone with some previous knowledge through application of assembly language subroutines to some achieveable level of understanding. Starting with a discussion of the topic in chapter seven, 'Using Assembly Language On The ZX81', the text moves on to finally offer and examine full assembly language application programs. The topic is clearly and logically discussed and an improvement on the quality of software you write, and hence the use to which you put your computer, should be evident.
Throughout, I am unconvinced that Advanced Programming For The 16K ZX81 realises its goal to produce better software; that will only come from the imagination of those who program. What it does achieve is to ensure that the transformation of those ideas to working programs will not be restricted by the shortcomings of the system.
Scores
Sinclair ZX81 VersionOverall | 80% |