REVIEWS COURTESY OF ZXSR

The Spectrum Machine Code Reference Guide
by Richard Ross-Langley
Interface Publications Ltd
1983
Your Spectrum Issue 2, Mar 1984   page(s) 73,75

CRACKING THE CODE

Machine code is often the stumbling block that stands int he way of those looking to take a more serious approach to Spectrum programming. Books there are a' plenty, but as ever it's horses for courses. Gary Marshall looks at the form.

It's an indisputable fact that the Spectrum can be made to do just about everything that's possible by programming it in machine code. A claim like that is much harder to make for other programming languages, for instance Basic, because although any computational task can be described, it may not always be performed fast enough.

A program written in any other language than machine code must first be translated into code by the computer before it can be executed - a task which inevitably takes some time. And speed of execution can be reduced further still in circumstances where the computer's translated code has failed to achieve the standards set by an expert human machine code programmer. Consequently, when it comes to speeding things up a bit, machine code is still the best answer. There's also the added advantage that machine code programs are a good deal harder to copy.

Input machine code programs to your Spectrum and you are presenting instructions direct to the Zilog Z-80 microprocessor in the language it understands. The number of instructions in this language is fairly limited and corresponds to the number of operations the microprocessor can perform. But the point is that the programmer deals directly with the electronic hardware, without any recourse to the Basic interpreter. That alone is a very good reason why Spectrum owners should get their hands dirty and find out exactly what's going on in that nifty little box of tricks.

But if all this sounds a bit complicated, not to worry because considerable benefits can be acquired without necessarily going the whole hog. Most Basic programs contain sections which take up a high proportion of the processor's time - elements known as 'critical segments' in the jargon. Programs can be speeded up considerably just by writing these critical segments in machine code.

Finally, before examining the outpourings of various writers on learning the art of machine code programming, it may be worth speculating on whether we ought to be using machine code at all!

In the non-microcomputer world of mainframes and the like, the trend is away from the use of machine code and more towards the structured high level languages. There could be a lesson to be learnt from this, especially with the launch of the Micro Prolog package - a version of the fifth generation language, Prolog (see Frontlines this issue). Overall, however, it's fair to say the facilities offered at present by the fifth generation languages are not entirely suitable for the Spectrum user - so there are still one or two good reasons for learning how to program in machine code.

MAKING THE INTRODUCTIONS

There are already a large number of books available to help enthusiasts program the Z-80 processor, mostly written by electronics engineers and hobbyists. A starter book for Spectrum owners should be as good as these, while at the same time staying relevant to the Spectrum and showing readers how to manipulate the hardware.

And, as always, the newcomer also needs a finely structured and carefully paced presentation of reliable information. Of course, encouragement to actually set the fingers tapping is another basic necessity - the best way to learn program writing is not by sitting down and reading about it. Motivation is another problem area - learning about machine code programming is no bed of roses and even the most manically keen can become discouraged.

Introducing Machine Code by Ian Sinclair provides a gently paced introduction that takes Basic programming as its starting point. Then, by showing how Basic programs are stored and run, it carries on to cover the same areas for machine code. The book introduces a wide range of instructions which are illustrated by way of programming examples. Unfortunately, these example programs rarely turn the spotlight on aspects specific to the Spectrum; in fact, many seem downright incestuous as they are used to examine Basic programs.

The Ultraviolet assembler from ACS Software gets a mention and although its use is quite well demonstrated, a more detailed treatment of hand assembly methods would have been better still. Nevertheless, this book would certainly take the reader from zero knowledge to the point where the more advanced machine code texts could take over.

Another introductory tome comes from James Walsh in the shape of Spectrum Machine Code Made Easy, Volume One. He includes a number of potentially useful machine code programs for activities specific to the Spectrum - such as scrolling the screen and manipulating colours. He's also not afraid to make good use of some intelligent machine code tricks.

However, despite the quality programming, it would have been better if the author had taken the reader further into the subject. The coverage is not very well structured and the pacing leans towards the erratic; for example, after being lulled into the false sense of security that machine code is really easy, after 30 pages the unprepared reader is abruptly launched towards the fairly weighty concepts of Carry, Borrow, Minuend, Subtrahend and two's complement notation!

Most of the programs use instructions before they've been properly introduced and some are not covered at all. For this reason, Volume One on its own is rather limited. Volume Two (surprise, surprise) is the second and more advanced tutor in the series, which provides much of the necessary reference material you need to fully understand Volume One.

In fact there's something of a striking contrast between Volume One and Two in the Spectrum Machine Code Made Easy series. Whereas Volume One strolls at a leisurely pace, and is very chatty and highly inventive in its risque chapter and section headings, Paul Holmes' Volume Two proves altogether more brisk and workmanlike. It comes packed with machine code routines, and that alone makes it a valuable source of information. The only worrying aspect is whether Volume One is fully able to prepare new riders of the machine code plains for the coming demands of Volume Two.

But for the complete novice, there's Spectrum Machine Language For the Absolute Beginner and although little of it is in fact specific to the Spectrum, the book's treatment of Z-80 code is entirely adequate and there's some useful reference material thrown in for good measure. The text is well sprinkled with examples of machine code used well, and also includes a sizeable games program, along with valuable notes on its development. Your author, however, will decline entering it without an assembler!

Toni Baker's Mastering Machine Code On Your Spectrum proclaims itself as championing those who, although familiar with Basic, have no knowledge at all of machine code. But the text fairly rattles along, covering acres of material in a relatively brief time. While there's absolutely nothing wrong with this kind of approach, the feeling is that, rather than a beginner's book, this is for people who know rather more than they're letting on.

Toni conjours up some good programs with interesting applications, including one that produces music from the Spectrum's own speaker. Incredible!

Before moving on to the more advanced titles, there is one last text that you may like to consider should you be starting your machine code career. Tony Woods' Learn And Use Assembly Language On The ZX Spectrum provides a complete course in Z-80 assembly language, complete with many illustrative program examples.

MOVE ON UP

The programmer who has paid his or her base level machine code dues may well like the idea of a book that includes ideas for further programs and new techniques, as well as providing a good source of reference. If you manage to find it, let us know! The trouble is that budding beginner's book start to branch out and a great degree of specialisation occurs.

Ian Logan and Frank O'Hara explain exactly what's inside every Spectrum ROM in their book The Complete Spectrum ROM Disassembly. It's all there, from how the screen is handled to the way Basic actually works. The book shows the location of all the routines in the ROM, so that programmers are able to call them into their own programs. And because the programs are all listed, the book is also a storehouse of programs and techniques.

Another publication that strikes the same vein is The Spectrum Machine Code Reference Guide. Although it didn't arrive in time for review here, the word is it contains a full disassembly listing of the 16K Spectrum ROM as well as a machine code programmer's guide to the Microdrives and Interface 1 unit; it sounds as if it could be worth a look.

Much of the material in Ian Logan and Frank O'Hara's ROM disassembly book appears again in Dr Logan's Understanding Your Spectrum. However, there s also useful stuff on how to use subroutines in the ROM, and by far the best reference section on the Z-80 instruction set your author has seen. The text also provides valuable data on the avail- able assembler and disassembler packages.

Last of all in our round-up, there's Super Charge Your Spectrum by David Webb. This is essentially a library of machine code programs, on hand for liberal sprinkling into Basic programs as and when required. Included amongst this amazing collection is a routine for developing Basic programs, and a number of useful utilities, for instance, a renumberer.

CONCLUSIONS

Your author has to admit a slight disappointment with the beginners' books. None seemed as good as the 'professional' Z-80 texts available, although in fairness this is compensated by the fact that they are specifically designed to be used with the Spectrum.

The more advanced books, however, have no apologies to make. They show exactly what the Spectrum can do, and how it can be made to do it, and all are intimately linked to the Spectrum. If ever you feel in need of encouragement as you stumble slowly through the early steps, check out the more advanced titles and see what you're missing. Inspiration - and motivation should soon follow.


REVIEW BY: Gary Marshall

Blurb: WE LOOKED AT... Introducing Spectrum Machine Code by Ian Sinclair. Granada ISBN 0 246 12082 7. £7.95 Spectrum Machine Code Made Easy, Volume One by James Walsh. Interface Publications ISBN 0 907563 43 0. £5.95 Spectrum Machine Code Made Easy, Volume Two by Paul Holmes. Interface Publications. ISBN 0 907563 44 9 £5.95 Spectrum Machine Language For The Absolute Beginner by William Tang Melbourne House ISBN 0 86161 110 1 £5.95 Mastering Machine Code On Your Spectrum by Toni Baker. Interface Publications ISBN 0 907563 23 6 £9.95 Learn And Use Assembly Language On The Spectrum by Tony Woods. McGraw-Hill ISBN 07 084705 3 £6.95 The Complete Spectrum ROM Disassembly by Ian Logan and Frank O'Hara. Melbourne House ISBN 0 86161 116 0 £9.95 The Spectrum Machine Code Reference Guide by Richard Ross-Langley. Interface Publications ISBN 0 907563 51 1 £4.95 Understanding Your Spectrum by Ian Logan. Melbourne House ISBN 0 86161 111 X £6.95 Super Charge Your Spectrum by David Webb. Melbourne House ISBN 0 86161 1128 £5.95

Transcript by Chris Bourne

All information in this page is provided by ZXSR instead of ZXDB