|
|
ZSM4 Z80/Z180/Z280 Macro-AssemblerThere are no Z80-hosted Z280 assemblers (or Z280-hosted, for that matter) that I know of. Only a PRE280 pre-processor is available for CP/M that can be used to expand Z280 mnemonics into a series of DB statements for use with a Z80 assembler. It does the job rather well, but being a pre-processor means it suffers from certain deficiencies:
In addition, the source code for PRE280 is not to be found anywhere. Here is my version of a Z280 assembler; the goal was to make it compatible with the de-facto standard M80 and RMAC, and that means producing relocatable output, supporting conditional assembly, MACROs, and the established set of pseudo-operators. In order to avoid starting from scratch, I looked around for the source code of a free Z80 assembler that could be used as starting point. After considering the available options out there (there are actually very few), I decided to use ZSM from the CP/M UK Users Group. ZSM was originally known as Z80ASM and written by Michael G. Lehman back in 1977, and later modified by Ray Halls in 1982 and Neil Harrison in 1983. The last released version was 2.8. After releasing the first beta version, I learned that Ian Waters, Chris Maxfields and Miguel Garcia had made further changes to ZSM 2.8; the latest version being 3.2 and available available via GitHub.
There were some interesting modifications:
All other modifications were rather minor, mostly attempts to correct the know bugs and/or deficiencies of the assembler, and in some cases changed the syntax of expressions in an unacceptable way. After reviewing the changes, I decided to incorporate the idea of the LESS operator and the inclusion of the assembly date and time in the listing (but using a different format, and so it works under MP/M too). The ASSERT pseudo-operator can be easily implemented with a MACRO and therefore was not added (as the assembler has already become considerably large, is better to limit the number of extra bells-and-whistles to a minimum.) Below is a summary of my modifications:
You can consult the full documentation here (PDF file.) Operation under CP/MThe assembler is initiated by typing: ZSM [command] where command is optional and has the following format: [relfile],[prnfile]=srcfile[/option][/option...] If no command is specified, the assembler will enter an interactive mode and prompt for the next command to be executed. relfile, prnfile and srcfile are valid file specifications and may contain a drive specification and extension. The default extensions are as follows:
The following device names can be used as well in place of a file specification (normally to redirect the output of the listing):
Options are a single char preceded by a slash. Some options require an argument. If several options are specified, each one needs to be preceded by a slash. The available options are:
For example, assembling the file TEST.MAC: ZSM4 =TEST/L This expects the file TEST.MAC on the current drive, will write the object code file TEST.REL and the listing file TEST.PRN both to current drive. ZSM4 b:ldiskio,tty:=diskio.280/Dloader=1/U This expects the file DISKIO.280 on the current drive, will define the LOADER symbol as 1, all undefined symbols will be declared External, will write the object code file LDISKIO.REL to drive B:, and will output the listing to the console. Operation under RSX180ZSM4 is built with a default task name of ...MAC. If desided, a different name can be specified in the INStall command, for example: INS ZSM4/TASK=...ZSM The task is also built with a default memory increment of 8000 bytes, which is enough for assembling small to medium-sized files. However, for large files specifying a larger memory increment via the INStall command is not necessary, since the assembler can request automatically more memory from the system if/as it becomes necessary. If the request is not granted, and error will be displayed. File specifications follow the standard RSX180 convention: dev:[directory]filename.ext;vers Note that the square brackets above are part of the syntax and therefore required when specifying a directory. Only filename is required, all other fields are optional and default to the following values:
If the task has been installed, it can be invoked by entering its installed task name: MAC [command] where command is optional and has the following format: [objfile],[lstfile]=srcfile[/option][/option...] If no command is specified, the assembler will enter an interactive mode and prompt for the next command to be executed. objfile, lstfile and srcfile are valid file specifications and may contain device and directory specifications, extension and version. The default extensions are as follows:
Options are a single char preceded by a slash. Some options require an argument. If several options are specified, each one needs to be preceded by a slash. The available options are:
For example, assembling the latest version of the file TEST.MAC: MAC =TEST/L This expects the file TEST.MAC on the current directory of the user's login device, will write the object code file TEST.OBJ and the listing file TEST.LST both to the current directory. MAC du2:[output]ldiskio,ti:=diskio.280;5/Dloader=1/U This expects the file DISKIO.280;5 on the current directory of SY:, will define the LOADER symbol as 1, all undefined symbols will be declared External, will write the object code file LDISKIO.OBJ to the directory OUTPUT on device DU2:, and will output the listing to the user's terminal. When not installed, the task can be invoked by using the RUN command. For example, assuming the task is named ZSM4.TSK and is located on the LB:[SYSTEM] directory: RUN $ZSM4 If no command line is present, the assembler will enter interactive mode and prompt for a command line: MAC> ZSM4 also supports indirect command files under RSX180 in the standard way: MAC @filespec where filespec is a valid command file specification. If no extension is specified, CMD is assumed. The command file simply contains a list of commands to be executed by ZSM4, one per line, and can in turn invoke additional command files up to a nesting level of 3. Operation under Linux or WindowsThe CP/M version of ZSM4 can be used as a cross-assembler on a Linux or Windows system by using John Elliott's zxcc program. Zxcc emulates both a Z80 and a CP/M environment in a way such that a regular CP/M application can be run from the Linux or Windows command prompt as if it was a native application. Since ZSM accepts source files with both CP/M and Unix end-line conventions, no conversion to the CP/M format is necessary. DownloadsYou can find the binary and sources in the downloads page. The sources are also on GitHub. Last modified 29-Apr-2019. |