Amstrad Computer User


Machine Code For Beginners On The Amstrad

Publisher: Micro Press
Machine: Amstrad CPC464/664

 
Published in Amstrad Computer User #5

Machine Code For Beginners On The Amstrad

Amstrad have been very kind to the machine code programmer. Usually it is necessary to work out the inner secrets of the machine yourself, which is why most of the best software for a computer is written by a few programming geniuses and appears months after the launch of the machine. Arm yourself with the Concise Firmware Specification (SOFT 158) and a Z80 assembler (two are currently available for the CPC464 and you have all the tools you need to enter the wonderful world of machine code.

Machine code is rather more demanding, and less forgiving, than BASIC, and a guide is helpful. So it isn't surprising that one of the first books to appear for the CPC464 is this one, which is intended as a tutorial for newcomers to this thorny topic. Rather more surprising is the fact that the author has taken the trouble to enlist two machine code novices to advise him in the preparation of the manuscript, unlike many people who assume too much awareness on the part of the beginner. And most surprising of all is that these novices let him get away with badly structured text, meandering non-sequiturs, and gross errors of fact.

This sounds harsh so I'd better justify myself, quick. I believe that, when you are trying to teach beginners anything, you have a duty to eliminate all errors. It's no good hoping that reader will pick up the mistakes: he's more likely to give up in confusion when something makes no sense, because "if it's in the book it must be right".

OK, let's take Chapter 10. This deals with the Z80 instructions that work on a single bit. It contains a single example program, two-and-a-half pages long, with no explanation of how it works (indeed, the author tells you not to bother to type it in), and it's introduced with the words "A number of 'dirty tricks' have been employed in the program. See if you can find where the 'Y' at the end of message 8 in line 1140 goes." Dirty tricks? In a book for beginners? And no explanation of what they are, of course. Line 1140 doesn't contain a message: message 8 is in line 1240 and I can't see what's so special about the Y. Nor do I see why I should waste my time trying to work out what the author is getting at: it is the job of a teaching book t o explain, not set riddles, and I see no reason to do the author's donkey work for him.

In Chapter 6, Simple maths, program 6.8 (referred to as 6.9 in the text) has a deliberate bug in it. Having identified the problem, the text rambles on for two pages about a couple of new instructions, then returns to the bug and shows they can be used to fix it.

After a sudden change of subject and trying to cope with new instructions, the reader has probably forgotten the original problem. This messy, almost random presentation of the subject matter is one of the book's biggest failings, making it hard to follow the author's thread.

A final example: throughout the book the author has made use of two system calls, one to get a keypress from the keyboard and another to print the character whose ASCII code is in the Z80's accumulator. Chapter 15 tells you that the print routing is part of the Key Manager (it's actually in the Text VDU) and gets the labels GETKEY and PRINT swapped over. Sigh.

I hesitate to recommend this book, because anyone capable of spotting its shortcomings and errors is probably canny enough to get what they need from a general-purpose Z80 book and the Concise Firmware Specification (admittedly the latter is a bit expensive for dabblers). It does provide an Amstrad-specific view of things and a listing for a hex loader, although you'd certainly have to buy an assembler for any serious work), but I'd have to say you're better off buying a book like Programming The Z80 by Rodnay Zaks (published by Sybex, sold in the UK by Computer Bookshop, Birmingham), or else wait a while for something better to appear.