Page Index
Z80Asm – A TRS-80 Assembler for Microsoft Windows
Z80Asm is a TRS-80 assembler for the twenty-first century. It assembles TRS-80 assembly language programs and creates /CMD files that will run on a real or emulated TRS-80, but it runs on the command line of your Windows PC. That means you can use your favorite Windows text editor to create and edit your assembly language source files and that your source files will be stored on your Windows hard drive (and can easily be backed up onto CD’s, DVD’s, thumb drives, and so on). Z80Asm is the modern, easy way to do assembly language development for your TRS-80 Models I, III, and 4.
Note: Windows PC’s and TRS-80’s handle their filenames and extensions differently. On a Windows PC, the filename and extension are separated by a period (FILENAME.EXT); on the TRS-80 they are separated by a slash (FILENAME/EXT). Since most of the files handled by Z80Asm will actually reside on a Windows PC, this instruction manual uses the Windows style of naming (except in a few cases where the files reside on a TRS-80 virtual disk).
Installation
The Z80Asm assembler is a single executable file that runs from the command line. It does not have (or need) an installation program; just copy it into the directory where you want to use it, or copy it into a binaries directory and use a PATH statement to make it visible to the system.
Usage
Invoking Z80Asm is simple and follows the conventions of most of the popular TRS-80 assemblers. The command line looks like this:
Any options are (as the name implies) optional; if you don’t supply any, Z80Asm will assemble the source file named FILE and will generate a TRS-80 program file named FILE.CMD. FILE.CMD can then be copied to a real or emulated TRS-80 for testing. By default Z80Asm will also create the file named FILE.LST, which is a listing of the assembled program.
Please note that because different people use different extensions for their assembly language source files (ASM, SRC, etc.), Z80Asm does not add a default file extension. If you want to assemble FILE.ASM, you need to type FILE.ASM on the command line; if you want to assemble FILE.SRC, you need to type FILE.SRC.
This default behavior will probably be enough in most circumstances, but Z80Asm features the following list of options to serve your needs.
Assembly Options
Here are some examples of possible Z80Asm command lines. To load in the SAMPLE.SRC source file, assemble it, and write out the SAMPLE.CMD program file and SAMPLE.LST program listing:
To load and assemble the same source file, write out the SAMPLE.CMD program file, but skip the generation of the SAMPLE.LST program listing:
To load the PROGRAM/ASM source file from the TRS-80 virtual disk DSKIMAGE.DSK, assemble it, disable the display of macro expansions, and write the program file PROGRAM/CMD and program listing PROGRAM/LST to the same virtual disk:
To load the XLR8.ASM source file, assemble it with support for the Hitachi HD64180 instructions, generate an equate listing of non-alphanumeric equates, and write out the XLR8.CMD program file and XLR8.LST program listing:
Format for the Assembly Language Program
The format for the assembly language programs Z80Asm accepts follows the same rules as earlier TRS-80 (and most other) assemblers. If you are familiar with assemblers like MRAS, Zeus, or M-ZAL, or MASM or TASM, you will be completely at ease with Z80Asm and its requirements.
Each line of the program looks something like this, but keep in mind that each of the four fields is optional:
Each field is separated by at least one space or tab, but aside from that there are no restrictions about how a program is formatted. You can make each field line up in columns or not; your programming style is completely up to you. Z80Asm treats upper and lower case letters as identical (except inside character strings), so you can decide whether to program in upper or lower case.
Field 1: The label is a symbolic name for a memory address. The label can be from two to fifteen characters long. Labels may be terminated by a colon, a space, a tab, or any combination of the three. The first character of a label must be a letter, an underline, a dollar sign, or an at sign. The subsequent characters of a label may be any of these characters as well as a digit (0 through 9) or a question mark.
Fields 2 and 3: The opcode and operands are standard Z-80 assembly language opcodes and operands as described in the Series I Editor/Assembler manual and other similar publications.
Field 4: The comment always begins with a semi-colon and ends with the end of the line.
Expressions
As can most other assemblers, Z80Asm can evaluate expressions as part of the source code. The expressions can include simple arithmetic:
- Addition (the plus sign, as in number1+number2)
- Subtraction (the minus sign, as in number1-number2)
- Multiplication (the asterisk, as in number1*number2)
- Division (the slash, as in number1/number2)
- Modulo division (the word .MOD., as in number1.MOD.number 2)
… and logical comparisons:
- Logical (bitwise) AND (the word .AND. or an ampersand, as in number1.AND.number2 or number1&number2)
- Logical (bitwise) OR (the word .OR. or an exclamation point, as in number1.OR.number2 or number1!number2)
- Logical (bitwise) exclusive OR (the word .XOR., as in number1.XOR.number2)
- Logical one’s complement (the word .NOT., as in LABEL EQU .NOT.number1)
- Logical (binary) not equal (the word .NE., as in IF number1.NE.number2)
- Logical (binary) equal (the word .EQ., as in IF number1.EQ.number2)
- Logical (binary) greater than (the word .GT., as in IF number1.GT.number2)
- Logical (binary) greater than or equal (the word .GE., as in IF number1.GE.number2)
- Logical (binary) less than (the word .LT., as in IF number1.LT.number2)
- Logical (binary) less than or equal (the word .LE., as in IF number1.LE.number2)
… and bit manipulation:
- Shift left (less than sign, as in number1<number2)
- Shift right (less than sign and a negative number, as in number1<-number2)
- Shift number1 left (the word .SHL., as in number1.SHL.number2)
- Shift number1 right (the word .SHR., as in number1.SHR.number2)
- Get the high order byte (the word .HIGH., as in .HIGH.number1)
- Get the low order byte (the word .LOW., as in .LOW.number1)
Pseudo-Ops
Pseudo-ops look like Z-80 assembly language instructions but are actually commands to the assembler. Z80Asm handles all of the familiar pseudo-ops, including (but not limited to):
Example: ORG 3000H.
Examples: END or END START or END 3000H.
Examples: LABEL1 EQU 3200H or LABEL2 EQU LABEL1+256.
Examples: DB 13, DB ‘This is a message’, DB 1,2,3,4,5.
Examples: DW 1024 or DW 1200H,0400H,5213H.
Example: DS 200H.
Examples: DC 64,’-‘ or DC 25,0.
Assembler Directives
Assembler directives are commands embedded in the program that tell the assembler to do something different. Z80Asm supports several directives:
Macros
Z80Asm’s macro definitions are simple and match the style of most other assemblers. The basic format to start a macro is NAME MACRO #parameter1, #parameter2, #parameter3…
The macro name follows the same rules as a program label. Parameters are not required but there may be as many parameters as will fit on a line. Each parameter should be preceeded by a number sign or #.
Macro definitions end with “ENDM” on a line by itself. If macros have been nested (placed one inside another), each macro must end with an “ENDM.” If you want to exit a macro definition prematurely (as in some kind of an error condition), use “EXITM” on a line by itself.
Conditional statements can be used inside macros to make them a little more flexible.
Z80Asm also supports the three standard built-in macros. The first is REPT number, which will repeat the macro definition a specified number of times. The second is IRP symbol,<1,2,3,4,5…>, which will repeat the macro definition once for each of the items in the argument list. The third is IRPC symbol,<string>, which will repeat the macro definition once for each character in the string.