ZXAD: Assembler is full-featured, easy to use

Author(s): Allan C. de Frates
Publication: Timex Sinclair User
Pub Details: Timex Sinclair User n7 (Volume 1, Issue 7)
Date: December 1983
Pages: 6-7

ZXAD, Version 2 / Scientific Software, 16K

Cartoon figures pushing giant ZXAD letters
Cartoon figures pushing giant ZXAD letters

ZXAD is an assembler program that includes basic debugging/editing capabilities. It allows the use of eight pseudo-ops (ORG, REL, END, DEFB, DEFW, DEFC, DEFS and EQU) and six-character symbols/labels, something few available assemblers permit.

For those who are unfamiliar with the term, an assembler is a program which aids the user in writing machine code programs. It does this by taking a listing written in assembly mnemonics, called the source code, and translating it into machine code. For example, an assembler takes the source statement “LD A,B” and translates it into the number 78hex, which the Z-80 microprocessor can understand. Using labels, an assembler can automatically calculate addresses, freeing the user from that tedious and error prone task. Programs can be written using statements like “CALL NEXT” or “LS HL, (COUNT)” without worrying about the exact addresses of NEXT and COUNT. Labels make it simple to shift a program about in memory, making it a snap to insert or delete instructions to correct a bug.

A pseudo-op is an instruction included in the source code that tells the assembler what to do, but does not get translated into machine code. The ORG pseudo-op instructs the assembler where in memory to store the machine code as it is being assembled. REL tells where in memory the machine code will be executed. (This is not necessarily the same place that the machine code is stored. The code may get moved.) END signals the end of the source code. DEFB and DEFW indicate that the numbers immediately following them are to be directly included in the machine code. DEFB assumes the numbers are single bytes and DEFW assumes the numbers are two-byte words. These two pseudo-ops are useful in setting up data tables.DEFC causes the character codes of the immediately following string to be stored in the machine code. For example, DEFC “ABC” causes the bytes 26, 27 and 28 (all in hexadecimal) to be included. DEFS leaves open a certain number of bytes which can then be used for temporary storage. EQU assigns a numerical value to a symbol or label.

Symbols are strings of up to six characters used in the source code to represent constant numbers. For example, the symbol LINES can be used in place of the number 16hex in the instruction LD A,LINES. Symbols make the source code easier to understand while also providing a way to change the value of a constant throughout the program (by changing one EQU statement).

The number of symbols/labels that can be used in the source code is only limited by the size of free memory.

The first line of ZXAD is a REM statement that contains the machine code that actually handles the conversion from source code to machine code and the debugging/editing. The 102 remaining lines of BASIC create the display and gather input from the user. Including the display file, ZXAD occupies just over 8K bytes of memory.

The user’s source code statements are stored in REM statements above ZXAD’s 103 lines. One source statement plus a comment are allowed per REM. ZXAD has a line renumber function which makes it simple to insert new lines of source code.

ZXAD offers three assembly options. One simply assembles the code and displays any error messages; the others, assemble the code and either display or print out addresses, machine code, source code, and error messages (see Figure 1).

Figure 1. Sample of assemble and print option.

570  53F8 115D40   INPUT LD DE,$
405D
600 53FB D5 INPLP PUSH DE
610 53FC CD3B54 CALL KEY
620 53FF D1 POP DE
625 5400 E1 POP HL
630 5401 FEE3 CP $E3
640 5403 CABF53 JP Z,MENDIS
650 5406 E5 PUSH HL
660 5407 FE77 CP $77
670 5409 281A JR Z,DEL
680 540B FE76 CP $76
690 540D 2829 JR Z,ENT
700 540F FE40 CP $40
710 5411 30E8 JR NC,INPLP
720 5413 EB EX DE,HL
730 5414 77 LD (HL),A
740 5415 23 INC HL
750 5416 117B40 LD DE,$407B
760 5419 B7 OR A
770 541A ED52 SBC HL,DE
780 541C 2817 JR Z,WSFULL

ZXAD provides simple debugging features. Memory can be examined and edited in hex. Also a breakpoint address can be selected. When this address is reached during a run of the machine code, a branch is made to a routine that displays the values of all the registers. The machine code program does not stop after the breakpoint — it continues on leaving a snapshot of the Z-80’s state at that address. ZXAD does not provide the single-step or disassembly capabilities found in other debugging programs such as Sinware‘s HOT Z.

ZXAD is very easy to use. Source code is standard Z-80 mnemonics, but uses only hexadecimal numbers. Functions are selected from a menu (see Figure 2). The instruction booklet is very well written, though it assumes a familiarity with machine language programming. It includes tips about the most common programming mistakes and contains a list of all the mnemonics in the form that ZXAD recognizes.

Figure 2. Function menu.
Figure 2. Function menu.

My only complaint about ZXAD concerns the five error messages: they are not specific enough. “BAD OP-CODE” can mean everything from a missing space to an incorrect number. This vagueness can be frustrating until you become familiar with ZXAD’s syntax.

Overall, the ZXAD assembler is very useful, full-featured, and easy to use. Its instructions are clear and complete. It has some debugging/editing capabilities, but it is not a complete debugger/disassembler.

For more information, circle 8 on reader service card.