                      Z80 & CP/M 2.2 Emulator v2.1 10/30/85

                            Written by Joan Riff for:

                        Computerwise Consulting Services
                                  P.O. Box 813
                                McLean, VA 22101


                     Placed in the public domain, cause it's
                       just too good to keep to ourselves.


                  Enter 'HELP' or '?' for command help screen.
                   Complete HELP follows, stops with keypress
AUTOEXEC.Z80
================================================================================
Notation:

'n' is entered as follows (with optional leading +/-):

FFFF               Hex number
.99999             Decimal number
%1111111111111111  Binary number
'c                 ASCII char c
'\c                Escape char c (\r, \n, etc)
'\xFF              Hex byte FF
xxxxxx             Label name xxxxxx (as defined by LABEL command)
n[+/-n]            Expression with 2 or more n's joined by + or -

================================================================================
!xxxxxx

        Pass command xxxxxx to PC-DOS for processing.


        Example:  !chkdsk B:
        Example:  !cd z80source

================================================================================
                   Ŀ
                    CP/M Builtin commands that are emulated 
                   

d:      Change default drive to d.

        Example:  B:

================================================================================

DELete  <filename_pattern>
ERAse   <filename_pattern>

        Removes file(s) matching the given pattern from the disk.
        Invokes PC-DOS 'DEL' command (q.v.).


        Example: DELETE b:\bin\z80mu.exe
        Example: DEL *.*

        Example: ERASE b:z80mu.*
        Example: ERA c:\z80\test\*.*

================================================================================
DIR
STAT

        Displays disk filenames matching the given pattern.
        Use instead of CP/M STAT.COM, which cannot be emulated.
        Invokes PC-DOS 'DIR' command (q.v.).


        Example: DIR b:
        Example: STAT ..\*.?q?

================================================================================
TYpe <filename.typ>

        Type the contents of the specified file on the screen.
        Invokes PC-DOS 'TYPE' command (q.v.).


        Example: TY z80mu.ini

================================================================================

         Ŀ
          Emulator Builtin commands that are similar to CP/M builtins 
         

REName  <oldpattern> <newpattern>

        Renames files whose names match <oldpattern> to <newpattern>.
        Invokes PC-DOS 'RENAME' command (q.v.).


        Example: REN FOO.ASM FOO.MAC

================================================================================
SAve    n <filename.typ>

        Saves n 256-byte pages of Z80 memory (starting at 0100h) to the
        specified file. Save WILL NOT write a proper .HEX file. It simply
        writes a memory image (per .COM files).

        NOTE:  Default radix for n is HEX!


        Example: SA 5 driver.com
        Example: SAVE .30 newddt.com

================================================================================
COpy    <filename_pattern> <destination>

        Copies file(s) matching the given pattern to the destination.
        Invokes PC-DOS 'COPY' command (q.v.).


        Example: COPY b:z80mu.* a:\z80
        Example: CO *.* NUL

================================================================================
                          Ŀ
                           General Emulator commands 
                          

HELP [<keyword>]
?    [<keyword>]

        Obtain HELP for all commands (keyword absent) or for specific keyword
        (keyword present).

        Example: HELP help
        Example: ? B:

================================================================================
Illop   [ FAULT | NOP ]

        Tells Emulator whether Illegal Opcodes should cause a fault,
        or should be handled as if they were NOP's.


        Example: ILLOP FAULT

                 Illegal opcodes will FAULT

        Example: ILLOP NOP

                 Illegal opcodes will act as NOP's

================================================================================
Exit
E

        Exits Emulator, back to PC-DOS.


        Example: Exit

================================================================================
HOWFAST?
SPEED?

        Computes the effective speed of the imaginary Z80, and reports it.  THIS
        COMMAND COLDBOOTS THE CP/M SEGMENT, wiping out  anything  that  you  may
        have in it.


        Example: SPEED?

           Beginning Z80 timing test. Please wait...
           Effective Z80 clock speed is %ld Hz

================================================================================
                           Ŀ
                            Emulator DEBUG commands 
                           

BTrace  [ SOME | ALL ]

        Displays trace of current BDOS TRACE circular buffer. Buffer is  cleared
        with each .COM file  load,  and  at  other  times  when  needed.  'SOME'
        excludes console character functions. 'ALL' includes them.

        Example: BTRACE
        Example: BT ALL

================================================================================
Break
        Displays current breakpoint addresses.

Break   CLEAR

        Clears all current breakpoint addresses.


Break   CLEAR n [n...]

        Clears specific breakpoint addresses.


Break   SET n [n...]

        Sets specific breakpoint addresses.


        Example: B CLEAR 0100
        Example: B SET driver_start 0d00 0d03 driver_ret-1

================================================================================
Dump    [n1 [n2]]

        Dumps Z80 memory to the screen in hex and ASCII, beginning at address n1
        and ending at address n2 (if given).


        Example: D .256
        Example: D driver_start driver_end-1

    ADDR  00 01 02 03 04 05 06 07  08 09 0A 0B 0C 0D 0E 0F  01234567 89ABCDEF
    ----  -- -- -- -- -- -- -- --  -- -- -- -- -- -- -- --  -------- --------
    0000: 00 01 02 03 04 05 06 07  08 09 0A 0B 0C 0D 0E 0F  ........ ........
    0010: 10 11 12 13 14 15 16 17  18 19 1A 1B 1C 1D 1E 1F  ........ ........
    0020: 20 21 22 23 24 25 26 27  28 29 2A 2B 2C 2D 2E 2F   !"#$%&' ()*+,-./
    0030: 30 31 32 33 34 35 36 37  38 39 3A 3B 3C 3D 3E 3F  01234567 89:;<=>?
    0040: 40 41 42 43 44 45 46 47  48 49 4A 4B 4C 4D 4E 4F  @ABCDEFG HIJKLMNO
    0050: 50 51 52 53 54 55 56 57  58 59 5A 5B 5C 5D 5E 5F  PQRSTUVW XYZ[\]^_
    0060: 60 61 62 63 64 65 66 67  68 69 6A 6B 6C 6D 6E 6F  `abcdefg hijklmno
    0070: 70 71 72 73 74 75 76 77  78 79 7A 7B 7C 7D 7E 7F  pqrstuvw xyz{|}~.
    0080: 80 81 82 83 84 85 86 87  88 89 8A 8B 8C 8D 8E 8F  ........ ........
    0090: 90 91 92 93 94 95 96 97  98 99 9A 9B 9C 9D 9E 9F  ........ ........
    00A0: A0 A1 A2 A3 A4 A5 A6 A7  A8 A9 AA AB AC AD AE AF  ........ ........
    00B0: B0 B1 B2 B3 B4 B5 B6 B7  B8 B9 BA BB BC BD BE BF  ........ ........
    00C0: C0 C1 C2 C3 C4 C5 C6 C7  C8 C9 CA CB CC CD CE CF  ........ ........
    00D0: D0 D1 D2 D3 D4 D5 D6 D7  D8 D9 DA DB DC DD DE DF  ........ ........
    00E0: E0 E1 E2 E3 E4 E5 E6 E7  E8 E9 EA EB EC ED EE EF  ........ ........
    00F0: F0 F1 F2 F3 F4 F5 F6 F7  F8 F9 FA FB FC FD FE FF  ........ ........
    ----  -- -- -- -- -- -- -- --  -- -- -- -- -- -- -- --  -------- --------

================================================================================
Find    n "text"

        Searches CP/M Segment (starting at address n) for "text",  and  displays
        addresses of matches. The "text"  string  may  contain  imbedded  escape
        sequences.


        Example: F 100 "Copyright"
        Example: F output_handler "\xcd\x05\x00"

================================================================================
Go      [n]

        Begins execution of the Z80 at address n (default if n not given is  the
        current Z80 PC). This is the usual way to run a program  that  was  read
        manually from disk. Note that .COM programs that  are  invoked  by  name
        (per standard CP/M) do not need this  command.  They  are  automatically
        executed.


        Example: GO 113
        Example: GO
        Example: GO driver_start

================================================================================
Patch   [n [string]]

        Begins interactive patching at location n. Enter '?' at patch prompt for
        specific help. If string arg is  present,  then  string  is  applied  to
        memory and interactive mode is not entered.


        Example: P table_start+3f
        Example: P 5C+filename_offset
        Example: P 5C "\0FOO    ASM"

Patch entries:

        n               Standard numeric expression (8- or 16-bit)
        "xxxxx"         String xxxxx (may include imbedded '\' escapes)
        <space><return> No change, move to next loc
        <return>        Back to main Emulator prompt
        ?<return>       Get this help display
        ;xxxx           Comment (line ignored)

================================================================================
Xreg    [rr n]

        If no args are present, then current Z80 regs/flags  are  displayed.  If
        args are present, then Z80 reg/flag rr is set to the value n.

        rr = reg/flag to be set, one of following:

                regs:  A    F    B    C    D    E    H    L
                       A'   F'   B'   C'   D'   E'   H'   L'
                       AF   BC   DE   HL   AF'  BC'  DE'  HL'

                       IX   IY   SP   PC   IFF1 IFF2 IMF  I R

                flags: SF   ZF   HF   P/V  NF   CF
                       SF'  ZF'  HF'  P/V' NF'  CF'


        Example: X BC .63000   (sets 16-bit BC)

        Example: X B 'X        (sets 8-bit B)

        Example: X ZF 1                (sets ZERO flag true)

        Example: X CF 0                (sets CARRY flag false)

================================================================================
Trace   [n]

        Executes n (default = 1) Z80 instructions, beginning at the current  Z80
        PC. The Z80 regs/flags are displayed after each execution.

        Example: T .10

================================================================================
Notrace [n]

        Executes n (default = 1) Z80 instructions, beginning at the current  Z80
        PC. The Z80 regs/flags ARE  NOT  displayed  during  execution,  but  ARE
        DISPLAYED after the final instruction.

        Example: N .200

================================================================================
PCtrace? [FIRST | LAST   n  [FULL | BRIEF]]

        Displays Z80 PC's as captured during  last  TRACE  or  NOTRACE.  Display
        proceeds from oldest PC toward newest (FIRST n) or in opposite direction
        (LAST n). Shows just PC's (BRIEF) or disassembled source  lines  (FULL).
        Default is LAST 512 FULL.

        Example: PC? FIRST .100 BRIEF
        Example: PCTRACE? LAST .256 FULL

================================================================================
Move    nlo nhi ndest

        Moves chunk of memory (nlo to nhi  inclusive)  to  address  ndest.  Uses
        either left-to-right or right-to-left copy, as needed.


        Example: M driver_start driver_end-1 f000

================================================================================
MAth    <expression>

        Displays 16-bit  results  of  given  expression,  in  HEX  and  decimal.
        <expression> is composed of 1 or more numeric args connected with '+' or
        '-' operators.


        Example: MATH table_end-table_start
        Example: MA 'A-40+'a
        Example: MA 0-.4096

================================================================================
                 Ŀ
                  CP/M Environment and file control commands 
                 
ARgs    <command_tail>

        Formats FCB's at 05Ch and 06Ch as  well  as  default  DMA  at  080h  per
        command tail, exactly as CP/M's CCP would.


        Example: ARGS foo.asm foo.hex
        Example: AR   foo.c -b -n -v

================================================================================
COLDboot!
COLD!
        COLD BOOTs CP/M segment by reformatting all  64K,  rebuilding  BIOS  and
        BDOS hooks, etc.


        Example: COLDBOOT!
                         *** CP/M Segment COLDBOOTED ***

================================================================================
TERMinal [ ON | OFF ]

        If ON, then BIOS console goes through builtin terminal emulator. If OFF,
        then BIOS console calls are routed to PCDOS. If  no  arg,  then  current
        state is reported.


        Example: TERM ON

                 Terminal Emulation is ON (via CP/M BIOS)

        Example: TERM OFF

                 Terminal Emulation is OFF (CP/M BIOS console goes to PCDOS)

================================================================================
Read    [n] <filename.typ>

        Reads filename.typ into location n (default =  0100h).  Note  that  .HEX
        files are handled properly, overriding n with actual addresses from .HEX
        records. This is the usual way to load a file for debugging purposes.


        Example: READ driver.hex
        Example: R d000 newddt.com

================================================================================
Write   nlo nhi <filename.typ>

        Writes Z80 memory from nlo thru nhi (inclusive) to the given file.  This
        is a raw binary write, unless you specify a .HEX filetype (in which case
        INTEL HEX records will be written).


        Example: WRITE driver_start driver_end-1 driver.hex
        Example: W 0 ffff model100.mem

================================================================================

SUBmit  <filename.typ>

        Switches  input  (for  emulator  commands  only)  to  the  given   file.
        Application input does not get switched. Input reverts to  the  keyboard
        at EOF on the given file. SUBMITs do not nest.


        Example: SUBMIT ddt.fix
        Example: SUB patcher.sub

================================================================================
                             Ŀ
                              Re-Source commands 
                             

List [n1 [n2]] [>outfile | >>outfile]

        Disassembles Z80 instructions beginning at address  n1,  and  ending  at
        address n2 (if given). If '>' or '>>' is present,  then  the  output  is
        redirected to the indicated file instead of the screen.

List PROLOGUE n1 n2 [>outfile | >>outfile]

        Generates assembler prologue for code residing between n1 and n2. Labels
        outside of this range are EQUated. Normally  used  prior  to  a  regular
        disassembly to a file.

List INCLUDE   [A][O][F]

        Specifies level of detail to be included in disassembled instructions:
           A[ddresses]: include Z80 addresses on left
             O[pcodes]: include raw Z80 opcode bytes on left
               F[lags]: include description of instruction's affect on flags
                        (as comment)


        Example: LIST 0100
        Example: L INCLUDE FLAGS
        Example: LIST INCLUDE A O
        Example: LIST PROLOGUE 0100 cpu_end >cpu.asm
        Example: L 0100 cpu_end >>cpu.asm

================================================================================
Control LIST [n]

        Lists  all  current  disassembly  control  breaks   (including   labels,
        comments, and true control  breaks),  starting  with  controls  for  Z80
        address n (default = 0).

Control CLEAR

        Clears (wipes out) all current  disassembly  control  breaks  (including
        labels, comments, and true control breaks).

Control READ <filepath>

        Clears (wipes  out)  current  control  breaks  and  replaces  them  with
        controls (including labels and comments) from <filepath>.

Control WRITE <filepath>

        Writes current control breaks to the specified file, for later  use  via
        the READ control command above.

Control n   | I | B | W | T | S | C |

        Assigns control break type to Z80 address n, so that  later  disassembly
        will switch to the indicated mode when address n is encountered. Control
        break types are as follows:


          I[nstructions] : switch to Z80 instructions
                 B[ytes] : switch to DB pseudo-ops
                 W[ords] : switch to multi DW pseudo-ops per line
                 T[able] : switch to single DW pseudo-op per line
               S[torage] : switch to DS (to next control break)
                 C[lear] : clear current control break for address n


        Example: CONTROL LIST
        Example: C LIST d00
        Example: C CLEAR
        Example: C READ ddt.ctl
        Example: C WRITE b:\z80\pip.ctl
        Example: C 0100 Instructions
        Example: C driver_table Bytes
        Example: C driver_table+1f I
        Example: C jump_table Table
        Example: C 0f31 Clear

================================================================================
LABEL   n labelname
=       n labelname

        Associates text 'labelname'  with  Z80  address  n.  If  'labelname'  is
        absent, then existing  labelname  is  simply  deleted.  Labels  must  be
        alphanumeric or '_'.

LABEL   AUTOGEN n1 n2
=       AUTOGEN n1 n2

        Automatically generates labels (of form 'AUTOxxxx')  for  all  addresses
        that are referenced by code that resides from n1 to n2. Existing  labels
        are not overwritten.

        Can't have NULL label.


        Example: LABEL 5 bdos
        Example: = 05c fcb1
        Example: LABEL AUTOGEN 100 de3

================================================================================
COMMENT n "text"
;       n "text"

        Associates  comment  string  with  Z80  address  n,   so   that   future
        disassemblies  will  display  "text"  when  the  associated  address  is
        disassembled. If "text" is  absent,  then  existing  comment  is  simply
        deleted. If text contains whitespace characters (blanks  etc),  then  it
        must be enclosed in quotes. You may imbed standard UNIX escape sequences
        (\n, \t, etc) for formatting.  A  ';'  char  is  automatically  inserted
        before the comment and after every '\n'.

        An INSTRUCTION comment is displayed on the line before  the  instruction
        if it starts with '\n', else on the same line. Can't have NULL comment.


        Example: COMMENT  07f2 "Try to open file"
        Example: COMMENT  driver_start "\n--- Main Entry ---\n"

================================================================================
=======================   *** END OF COMPLETE HELP ***   =======================
================================================================================
Z80PATH
                                 System CALL'S
System Reset (WARM BOOT)
Console Input to A-reg
Console Output from E-reg =
READER Input to A-reg
PUNCH Output from E-reg   =
LIST Output from E-reg    =
Direct Console I/O from E or to A
Get IOBYTE to A-reg
Set IOBYTE from E-reg
Print String (at (DE) terminated by $)
Read Console Buffer to (DE)
Get Console Status to A-reg
Return CP/M Version Number to HL
Reset Disk System
Select Default Disk Drive E-reg
Open File, FCB at (DE)
Close File, FCB at (DE)
Search for First, FCB at (DE)
Search for Next
Delete File, FCB at (DE)
Read File (Sequential), FCB at (DE)
Write File (Sequential), FCB at (DE)
Make File, FCB at (DE)
Rename File, double FCB at (DE)
Return Disk Login Vector to HL
Return Current Disk to A-reg
Set DMA Address to (DE)
Get Addr(Allocation Vector) to HL
Write-Protect Disk
Get R/O Vector to HL
Set file attributes, FCB at (DE)
Get Addr(Disk Parms) to HL
Set/Get User Code
Read File (Random), FCB at (DE)
Write File (Random), FCB at (DE)
Compute File Size, FCB at (DE)
Set Random Record, FCB at (DE)
Reset Drive
(unsupported)
Write Random Zero Fill, FCB at (DE)
================================================================================
BDOS TRACE TABLE:

SEQ#    Z80PC  Z80DE Z80DMA FUNCTION

-----   -----  ----- ------ ----------------
 001    FFFF   FFFF    01   Instructions
 002    FFFF   FFFF    0F   Bytes
 003    FFFF   FFFF    05   Words
 004    FFFF   FFFF    DE   Table
 005    FFFF   FFFF    BC   Clear
 006    FFFF   FFFF    BC   Storage
        (not in table)
-- END OF BDOS TRACE TABLE --

================================================================================
        .Z80            ;This source is for M80.COM!
        ORG     0DC3AH
;
;       Equates for ASCII control chars
;
LAB7    EQU     1AFH
;
;       External ref equates
;
METKA
L4FD5
        EQU     0FFFFH
;
;       End of external equates
;

Control Chains starting with address 0FFFFH:

0FFFFH Mode Change:
Begin INSTRUCTIONS
Begin BYTES (DB)
Begin WORDS (multi DW per line)
Begin TABLE of WORDS (one DW per line)
Begin STORAGE (DS to next control)

*** Unknown mode: 0FFFH

0FFFFH Label: FORA
0FFFFH Comment: My Comment

*** End of Control Chain Listing

