CRASH - The Online Edition
— Issue 8 Contents|
You are sitting in the cockpit of a Lear jet at 1000 feet and approaching the runway at a sickening speed. Damn the instructor! Okay, so he had given you the instruction manual on how to land this bird a fortnight ago, and you have read it over and over again and think you know the proper procedure, step by step, on how to approach the land. The instructor had said it would be dead easy and yet, where is he? He isn’t sitting in the co-pilot’s seat, talking you gently down, guiding you along and making sure that you develop a hands down experience and live to see it... He knew your survival chances were zero and that the result would be a CRASH!
Learning machine code may not be as dangerous as learning to fly, but the same principles apply. You may buy a book on how to learn machine code, read all about the different commands and their effects, then try them out entering the mnemonics, assembling and running them by entering the famous last words: RAND USR... CRASH!
A long wait... Nothing. A sigh and a reach for the Spectrum power plug. You may not die, only your pride is hurt and you do get another chance... after loading the assembler again. The trouble is you don’t know what went wrong and begin to have doubts about your ability to learn machine code. Worst of all you will only enter the examples following the book word by word, for safety reasons, but without really knowing what you are doing. You won’t stray and experiment, because you could CRASH again...
Well, why risk life and limb, when you can earn your wings in a flight simulator. No danger here, your approach is recorded, all the instrument readouts monitored and if something goes wrong, such as forgetting to lower the landing gear, you just step out, get told off by the instructor and have another go. Wait a minute, why not develop a simulator for machine code tuition?
Well, Malcolm Evans has done just that. Stick the L-plate on your Spectrum and follow the leader:
The first aid kit comes in a plastic enclosure and consists of two cassettes and, oh no, the dreaded manual.
The assembler/simulator program is recorded on each cassette followed by groups of lessons which you are asked to load from within the program. You can also select not to load any lessons and proceed to experiment on your own using the assembler and simulator as a general purpose training ground, but if you are a newcomer, you’d best stick to the lessons to start with.
The Complete Machine Code Tutor (TCMCT) covers in 35 lessons all the instructions on the Z80 microprocessor. Each lesson consists of a detailed description of the instructions with all their effects registers and flags, followed in most cases by an example program. This example shows an application of the instruction and forms the basis of the exercises. The example is displayed as an assembler listing with memory address, object code and source code. To see the effect of the commands, the program may be ‘run’. The simulator takes charge and lets you single step through the program, displaying after every step the latest register, flag and stack contents on the lower part of the screen. The example may be rerun several times and when understood there is the option of editing the existing source code of the example and experimenting with the commands to hearts delight. The code is reassembled and the simulator activated. It is here that you will notice that the simulator is highly intelligent, avoiding any program crashes and displaying your lapses with English error messages.
It is this feature which can endear the TCMCT even to experienced machine code programmers, as it allows you to experiment without ever getting into serious trouble. It eliminates the reluctance to risk daring manoeuvres and gives you the necessary confidence to learn machine code.
The manual need only be read at the beginning. A list is given of the assembler instructions recognised. These pseudo-ops are commands to the assembler instead of to the processor and consist in this case of DEFB N (Define byte), DEFW NN (Define word) and BIN N (same as DEFB N, but the simulator will display the memory contents in binary rather than hex or dec code).
Next to this list thirteen error messages are listed, which the assembler will display upon aborting the assembly. These include error trappings such as unknown instructions, missing spaces, brackets or numbers, too large or labels too long or not found etc, are very comprehensive and should pinpoint the offending item quite clearly. There are also six different error messages listed which will appear when the simulator tries to run runaway assembled code. These include useful items such as:
PROGRAM COUNTER HAS JUMPED TO NON VALID ADDRESS: PC jump to an address which is not the beginning of an instruction line.
YOU ARE TRYING TO RUN CODE IN ALLOCATED STORAGE AREA: PC jump to a storage area.
YOU ARE ABOUT TO AFFECT MEMORY AREA NOT ALLOCATED TO YOU: You are trying to load a memory location not allocated to the work area (16384 to 23295 and 32000 to 32192 allocated).
YOU ARE ABOUT TO WRITE MEMORY WHICH WILL AFFECT YOUR PROGRAM: You are trying to load a memory location within your program instructions.
THE STACK POINTER IS OUTSIDE ALLOCATED MEMORY AREA: SP outside 32193 to 32255.
THERE ARE TOO MANY REGISTERS CALLED UP: Too many registers are used, but the simulator will run displaying only part of these registers.
A list of all keys used at various stages of the assembler/simulator with a full description of their functions is given, but the layout is so logical that after two minutes of use you will feel at home and be able to concentrate on the lessons.
Of beneficial use is the list of all the lesson headings together with a summary of the Z80 instructions, so that at any time the appropriate lesson may be recalled for further study of a particular instruction. The appendix contains tables for the effect of instructions on flags and the obligatory pictorial description of the shift and rotate functions. A very useful idea is the glossary, which should help the beginners understand the necessary computer jargon which separates the men from the boys...
The TCMCT is the first of its kind of program which gets the Spectrum owner on to a good footing with machine code and eliminates all the usual anxieties and long recovery procedures (from CRASHES) associated with machine code experimenting. The lessons include all the Z80 commands. These are explained in detail on screen, but for the total beginner it may be necessary to read a more general description of a microprocessor system with explanations of the various function blocks and the general modus operandi. It is highly recommended to purchase the Zilog Technical Manual, which not only gives a short and precise description of the Z80 CPU architecture, but also provides a reference manual for all the commands in the practical Group Table form together with the necessary execution timings. It must be understood that TCMCT is only intended for exercising machine code, so no provision is made for relocating the assembler/simulator or for positioning the object code at a specific memory start address. TCMCT is not a full blown assembler/editor/monitor with which complete commercial programs may be written. It is however the best machine code tutor and no serious Spectrum programmer should learn machine code without it.