MaxZ80 - Chapter 5

I mentioned in a previous Chapter that you could type either SUBMIT
CMD or CMD.SUB to run the command contained in the file CMD.SUB. This
remark will be our opening to a few of the many powerful features of

One of the modules in Z-System is the CCP, the Console Command
Processor. "ZCPR 3.4" stands for "Z80 Command Processor Replacement
version 3.4" and is the CCP we are using. The Z80 microprocessor chip
differs from the 8080 chip in that it implements some operation codes
that the 8080 leaves undefined. This allowed people like Richard Conn
to rewrite the command processor part of CP/M and make it more
powerful but still compatible with CP/M and still small enough to fit
in a 2K package. The main thing a command processor does is gather
what you type at the prompt and, if there is a file in user area 0 on
the logged drive with the same name as what you typed (but with a .COM
on its end), it copies the machine code contents of this .COM into
memory starting at hexadecimal location 100 and then executes the
instruction at hexadecimal location 100. If no such .COM is found and
what you type is not a resident command, like DIR, some error message
is issued.

Under Z-System, a more powerful algorithm for resolving what to do
after you hit the Enter key takes place. One of the steps is this: if
there is no .COM file and there is something called an "Extended
Command Processor" installed, this processor runs. The one we use here
is CMDRUN.COM, which is actually ARUNZ.COM, renamed. Here's what ARUNZ
displays when you run it on its own.

8:35 A1:COMS>CMDRUN //
 ARUNZ, Version 1.1   (Type 3 at 8000H)
  Runs alias script NAME from text file ALIAS.CMD

So, we need to look at the text file ALIAS.CMD. The lines in it that
are important right now are

>sub zex $tn0 $*
>zex zex $tn0 $*

ARUNZ pays attention to the filetype of the command and if there is a
line in ALIAS.CMD that starts with > followed by this filetype it will
run the command that follows. It replaces any clauses that start with
$ with something which depends on what follows the $. In our case,
$tn0 means "the filename of the 0th command token." There is only one
token in our case and since programmers often count things starting
with 0, "the filename of the 0th command token" would be CMD.

So, typing CMD.SUB will cause the command


to run. $* gets replaced by an empty string because it means "the rest
of the command you issued" and in our case there was nothing following

ZEX.COM is another transient command. It's like SUBMIT.COM, the job
control processor of CP/M. ZEX will look for a .SUB file (or a .ZEX
file) with a filename of CMD.

Now you know why SUBMIT CMD and CMD.SUB both do the same thing!