ZX Computing


The Code Machine

Author: Carol Brooksband
Publisher: Discovery
Machine: Spectrum 48K/128K/+2/+3

 
Published in ZX Computing #28

Carol Brooksband gets into The Code Machine and finds it a good vehicle for machine code programmers

The Code Machine

This Editor/Assembler, Monitor/Disassembler suite, first marketed as two separate programs by Picturesque, is now sold by Gremlin as a single package for £4 less than the old combined price.

The two can be used separately - both are fully relocatable - or can reside together in memory, providing a complete environment for developing and testing machine code with room to assemble 6K-7K of code. Longer programs can be developed in modules and assembled in sequence automatically to produce one block of code.

For some extraordinary reason, the Editor/Assembler accepts decimal or hex entries, defaulting to decimal, so you must put 'H' after hex numbers, while the Monitor/Disassembler only accepts hex numbers, rejected any with the 'H'. This is infuriating when you use the programs together! I found myself accidentally entering decimal numbers instead of hex every time I went from Monitor to Editor because I forgot that I had to switch back to adding 'H' to the numbers.

All listing can be sent to screen or printer, and both programs will drive the ZX printer, Interface 1 RS232 port, or one of seven popular centronics interfaces - but look before you buy. There are some equally popular interfaces it does not support, notably Kempston 'S'. After customizing, you can save a backup copy to either tape or Microdrive, and listings and code can be saved and loaded with either storage system. Backup copies can be made on Wafadrive, but the Editor source text and object code save and load routines are machine code driven from within the program, so it is not possible to use Wafadrive there.

The Monitor allows you to examine memory locations; change the contents of RAM addresses; Insert or delete code; fill blocks of memory with a single byte; copy blocks of code to other locations; and search for a sequence of up to five bytes. Text strings can be entered direct. A hex dump of any section of memory can be sent to either screen or printer.

Passing The Test

The testing facilities are very good. Breakpoints are available, and a display of registers and flags can be called up at any time. In trace mode, the program will single step through a sequence of instructions. The screen display, updated after each step, shows a disassembly of the last and next instructions; the contents of all the registers - which can be changed - and the first five bytes at the addresses to which they point; the state of the flags; and the top five entries on the stack. If you use a previously tested subroutine you can speed up the operation by fast running to RET. It is virtually impossible for the program to crash in trace mode. The Monitor has its own stack, and if your operations corrupt the normal one, you can correct the Stack Pointer simply by going into Basic and then re-entering the Monitor.

The Disassembler will oerate on any part of the ROM or RAM, except that it coyly refuses to disassemble itself. It has no objection, however, if you copy the code to somewhere else in memory where it will happily disassemble it.

The Editor/Assembler has a 40-column screen display divided into fields for line number, label, operator and operand. You must use the correct fields. If you put 'DJNZ' into the label field, it will be taken to be a label, not an operator. Line numbers, which can be generated automatically, work like Basic line numbers but there can only be one instruction per line. All or part of your listing can be renumbered.

Notes can only be entered in separate lines, rather like Basic REM statements. This seems a pity. It is often helpful to make notes on the individual instructions, and the listing is clearer if these can go on the same line as the instruction they explain. Labels can have up to six characters, can be permanent or redefinable, and their high and low bytes can be used separately. LD A, LOOP for example, will put the value of the high byte of the label address into the A register. The table can be carried forward after assembly, so that later modules of a program can refer to labels used in previous ones.

The program accepts all the standard Z80 instructions, and the normal pseudo-opcodes like DEFB and ORG. JR and DJNZ instructions are accepted with arithmetical displacements or label addresses. Addition and subtraction are permitted in operands, so you could use instructions like LD HL,LOOP+42H. A very useful feature is that the program will accept the unofficial instructions - the ones which work on all Z80 chips, but which Zilog do not list or describe. They include SLL and a group of instructions which operate on the high and low bytes of IX and IY individually.

The handbook is excellent, clear and straightforward, with lucid explanations of technical terms and plenty of well documented examples. this makes The Code Machine a particularly good package for someone fairly new to machine code programming. It will not tell you how to program, but at least you will have a test and development environment that you can understand and use easily. It probably does not have the sort of exciting features which would make someone already using a similar package rush to change to this one, but it is a good workmanlike program and well worth considering if you are still using a hex loader and the crash-and-try-again method of testing.

Carol Brooksband