



                i       t       l
                        t       l
                i n   ttttt     l
                i nnnn  t  eeee l
                i n  n  t  e  e l
                i n  n  t  eeee l
                           e     
                           eeee
        
                zzzz cccc oooo n 
                  z  c    o  o nnnn
                 z   c    o  o n  n
                zzzz cccc oooo n  n
                                  Software Conversion Tools


                Z80 TO 8086 SOURCE CONVERTER    VERSION 1.3

                OPERATIONS MANUAL
                               









                  Z80 TO 8086 SOURCE CONVERTER (ZCON)

                              VERSION 1.3

                           OPERATIONS MANUAL


COPYRIGHT 1979 MOSTEK CORP.
ALL RIGHTS RESERVED










































                                                                   i






                           TABLE OF CONTENTS

PARAGRAPH                                                          PAGE
NUMBER    TITLE                                                   NUMBER

1         GENERAL INFORMATION
1.1           INTRODUCTION                                          1-1 
1.2           CONVENTIONS USED IN THIS MANUAL                       1-1 
1.3           HOW TO USE ZCON                                       1-1 
1.4           OPTIONS                                               1-3 
1.5           OUTPUT OF THE CONVERTER                               1-5 
1.6           ERROR INDICATIONS AND WARNINGS                        1-8 

2         EDITING THE CONVERTED MODULE
2.1           INTRODUCTION                                          2-1 

3         TECHNICAL INFORMATION
3.1           INTRODUCTION                                          3-1 
3.2           CONVENTIONS USED IN THIS MANUAL                       3-1 
3.3           TECHNICAL APPROACH                                    3-1 

4         MAPPING
4.1           REGISTERS                                             4-1 
4.2           FLAG CONVERSION                                       4-2 
4.3           INSTRUCTION SET MAPPING                               4-2 
4.4           CONVERSION OF OPERAND EXPRESSIONS IN CONTEXT          4-15
4.5           ASSEMBLER PSEUDO-OP MAPPING                           4-17
4.6           RESERVED WORD HANDLING                                4-17
4.7           GLOBAL SYMBOLS                                        4-17

A         ERROR DICTIONARY

B         RESERVED WORDS FLAGGED BY THE CONVERTER

C         REDUCING CONVERTED CODE SIZE AND EXECUTION TIME














                                                                   ii







                            LIST OF FIGURES

FIGURE      DESCRIPTION                                            PAGE
NUMBER                                                            NUMBER

1-1       SAMPLE 8086 SOURCE OUTPUT                                 1-6 
1-2       SAMPLE TRANSLATOR LISTING OUTPUT                          1-7 









































                                                                   iii






                             LIST OF TABLES

TABLE       DESCRIPTION                                            PAGE
NUMBER                                                            NUMBER

1-1       SOURCE CONVERTER OPTIONS                                  1-5 





                                                                   1-1


                               SECTION 1

                          GENERAL INFORMATION


1.1 INTRODUCTION
________________

The Z80 TO 8086 SOURCE CONVERTER is a stand-alone program whose purpose
is  to  convert  a  source  program written  in  standard  Z80
assembly language into 8086 source language  as defined by Version  1.0
of Intel's 8086 Cross Assembler.   The Converter runs under ISIS-II, 
RMX-86, and MSDOS Version 2.0 or higher.  The generated output will run 
on all 8086 family microprocessors (8086/8, 80186/8, 80286, and 80386).

This   manual   describes  how  to  use  the  Converter  and  what  its
capabilities are.   A  technical discussion  of  how  instructions  are
converted is included.

1.2 CONVENTIONS USED IN THIS MANUAL
___________________________________

All  user  input  is underlined.   Information  which must  be  entered
exactly as shown is  in upper case.   Variable information is in  lower
case.  The symbol <CR> stands for carriage return.

1.3 HOW TO USE ZCON
___________________

Before the Converter is used, the following requirements must be met.

The  Z80  source  file to  be  converted  should be  capable  of  being
assembled without errors.   The conversion is done based upon (Mostek) Z-80
standards.

Maximum size  of source lines  is 132 characters not including carriage
return and line feed.

The  maximum number  of  symbols in a  program to  be converted is 1250
6-character  symbols.    The number  is  larger  if  symbols  of  fewer
characters are used.

To use the converter, enter the following command from the Monitor:

        ZCON source dataset [option-list]<CR>
        -------------------------------------
                -where source dataset is the name of the file to
                 be converted.
                -the option list is optional and is specified below.

The Converter reads the source dataset which is a Z80 assembly language
source program.  The  output of the Converter  is directed to the  same
unit and filename as the  source  dataset with an extension  of  'A86'.
This dataset contains the resultant 8086 source program.  The Converter
also outputs  a printed listing of the source and converted output with
warnings  to the user.  This is  directed to the same unit and filename
as the source  dataset with an extension of 'LST'.   The printed output
can be directed to a different dataset via an option.  A set of options
can be specified in  the option-list  for controlling  the operation of
the Converter.  These are discussed below.


                                                                   1-2


EXAMPLE
        Convert the source file MYPROG.SRC to produce an 8086
        equivalent source program called MYPROG.A86.

                ZCON MYPROG.SRC<CR>
                -------------------



                                                                   1-3


1.4 OPTIONS
___________

The  options  to  the  Converter  are specified  by  the  user  in  the
option-list which is entered on the  command line.  The options may  be
specified in any order.   Each option is separated from  the  others by
one or  more spaces.  The defaults for the options are specified below.
Table 1-1 summarizes the options and their defaults.

ABS  - specifies  that the converted module  is to  be absolute and not
relocatable.  This means  that the program cannot be linked to a PLM-86
module.  If ABS and NOTINCLUDED  are both  specified (NOTINCLUDED  is a
default), then a prologue is generated at the start of the  8086 source
program  which  is  compatible with  other 8086  assemblers but  is NOT
compatible with PLM-86 modules.   The  opposite of  this option  is REL
which is the default.  The prologue which is generated is shown below:

                ASSUME  DS:ABS_0,CS:ABS_0,SS:ABS_0,ES:ABS_0
        ABS_0   SEGMENT BYTE AT 0
        M       LABEL   BYTE

INCLUDED - specifies that this module is included in another module for
assembly.    This control suppresses  generation of  a prologue for the
8086.  The  opposite  of  this  option is  NOTINCLUDED,  which  is  the
default.

MAIN  -  specifies  that a set of  statements is to be generated in the
8086  module  to initialize  the  8086  segment  registers.    It  also
allocates memory  storage  for  the  equivalent  of the  Z80  alternate
registers.   These statements are the first executable statements after
any prologue generated  by  the Converter.   They are  required for the
main module in a set of modules to be linked together.  The opposite of
this option is NOTMAIN, which is the default.  The statements generated
are shown below:

        PUBLIC ??AFPRIM,??BCPRIM,??DEPRIM,??HLPRIM
        CLI             ;FIRST INSTRUCTION TO BE EXECUTED IN MAIN PROGRAM
                        ;(DISABLE INTERRUPTS)
        MOV AX,CS       ;USE CS REGISTER TO INITIALIZE SEGMENT REGISTERS
        MOV DS,AX
        MOV ES,AX
        MOV SS,AX
        STI             ;ENABLE INTERRUPTS
        JMP L0001_
??AFPRIM DW 0
??BCPRIM DW 0
??DEPRIM DW 0
??HLPRIM DW 0
L0001_  LABEL NEAR


                                                                   1-4


PRINT(dataset) - specifies a dataset for  the printed  output from  the
Converter.   The dataset specification  is optional.  The printed outpt
consists  of a listing of the Z80  source module and the resultant 8086
source module.   Normally, the printed output is sent  to the same unit
and filename as the  source file with an  extension of 'LST'.  This  is
the default option.  The opposite of this option is NOPRINT.

REL - specifies that this  module  will be assembled as  a  relocatable
module  and/or  linked  to  one or more  PLM-86  modules.   If REL  and
NOTINCLUDED  are  both specified (NOTINCLUDED  is  the default), then a
prologue is generated for the resultant 8086  program.  The prologue is
compatible with PLM-86.    This option  is the  default.   The prologue
which is generated is shown below:

        CGROUP  GROUP   ABS_0,CODE,CONST,DATA,STACK,MEMORY
        DGROUP  GROUP   ABS_0,CODE,CONST,DATA,STACK,MEMORY
                ASSUME  DS:DGROUP,CS:CGROUP,SS:DGROUP
        CODE    SEGMENT WORD PUBLIC 'CODE'
        CODE    ENDS
        CONST   SEGMENT WORD PUBLIC 'CONST'
        CONST   ENDS
        DATA    SEGMENT WORD PUBLIC 'DATA'
        DATA    ENDS
        STACK   SEGMENT WORD STACK 'STACK'
                DB      100 DUP(?)
        STACK_BASE LABEL BYTE
        STACK   ENDS
        MEMORY  SEGMENT WORD MEMORY 'MEMORY'
        MEMORY_ LABEL   BYTE
        MEMORY  ENDS
        ABS_0   SEGMENT BYTE AT 0
        M       LABEL   BYTE

NOOUTPUT - is the opposite of OUTPUT, which is the default.

NOPRINT - is the opposite  of PRINT, which is the  default.   When this
option is  selected, all warnings with associated statements are output
to the console device.

NOTINCLUDED  - is the opposite of INCLUDED.  This option specifies that
the converted module  is not included in  another module  for assembly.
Consequently, the Converter generates a prologue for the resultant 8086
program.  This option is the default.

NOTMAIN - is the opposite of MAIN.  This option specifies that a set of
initialization statements for the  8086 segment registers is  NOT to be
generated.  This option is used  for all modules to be linked  together
except the first, or main, module.  This option is the default.


                                                                   1-5


                  TABLE 1-1 SOURCE CONVERTER OPTIONS

OPTION PAIR                     DEFAULT
-----------                     -------
ABS/REL                         REL
INCLUDED/NOTINCLUDED            NOTINCLUDED
MAIN/NOTMAIN                    NOTMAIN
NOOUTPUT                        OUTPUT ON file.A86
PRINT(dataset)/NOPRINT          PRINT ON file.LST


1.5 OUTPUT OF THE CONVERTER
___________________________

Figure 1-1 shows the output of the Converter which is  directed  to the
'.A86' file.  This file  is ready to be edited by the user.  Editing could
include resolving the warning signals and global code reduction (see
Appendix C).

Figure  1-2  shows a sample printed output of the Converter.  Note that
the output is 132 columns wide.  For this benchmark (block move) the
converted 8086/8 code executes about 50% faster on a 8Mhz 8086/8
than on a 4Mhz Z-80.







































                                                                   1-6


                 FIGURE 1-1 SAMPLE 8086 SOURCE OUTPUT


CGROUP  GROUP   ABS_0,CODE,CONST,DATA,STACK,MEMORY
DGROUP  GROUP   ABS_0,CODE,CONST,DATA,STACK,MEMORY
        ASSUME  DS:DGROUP,CS:CGROUP,SS:DGROUP
CODE    SEGMENT WORD PUBLIC 'CODE'
CODE    ENDS
CONST   SEGMENT WORD PUBLIC 'CONST'
CONST   ENDS
DATA    SEGMENT WORD PUBLIC 'DATA'
DATA    ENDS
STACK   SEGMENT WORD STACK 'STACK'
        DB      100 DUP (?)     ;SET SIZE OF STACK PER YOUR APPLICATION
STACK_BASE      LABEL   BYTE
STACK   ENDS
MEMORY  SEGMENT WORD MEMORY 'MEMORY'
MEMORY  _LABEL  BYTE
MEMORY  ENDS
ABS_0   SEGMENT BYTE AT 0
M       LABEL   BYTE
        NAME    EXAMPLE
        ORG     0
;
DDATA   EQU     1000H
BUFFER  EQU     2000H
;
START:  MOV     BX,DDATA
        MOV     DX,BUFFER
        MOV     CX,737
        XCHG    DI,DX   ; MOVE THE BUFFER
        XCHG    SI,BX
        CLD
        REP     MOVSB
        XCHG    DI,DX
        XCHG    SI,BX
        AND     AH,NOT( 10H OR 4H OR 2H )
ABS_0   ENDS
        END



                                                                   1-7


              FIGURE 1-2 SAMPLE TRANSLATOR LISTING OUTPUT


 Z80 TO 8086 SOURCE TRANSLATOR V1.1

ST # Z80 SOURCE                                    ST # 8086 SOURCE

                                                   0001 CGROUP  GROUP   ABS_0,CODE,CONST,DATA,STACK,MEMORY
                                                   0002 DGROUP  GROUP   ABS_0,CODE,CONST,DATA,STACK,MEMORY
                                                   0003         ASSUME  DS:DGROUP,CS:CGROUP,SS:DGROUP
                                                   0004 CODE    SEGMENT WORD PUBLIC 'CODE'
                                                   0005 CODE    ENDS
                                                   0006 CONST   SEGMENT WORD PUBLIC 'CONST'
                                                   0007 CONST   ENDS
                                                   0008 DATA    SEGMENT WORD PUBLIC 'DATA'
                                                   0009 DATA    ENDS
                                                   0010 STACK   SEGMENT WORD STACK 'STACK'
                                                   0011         DB      100 DUP (?)     ;SET SIZE OF STACK PER YOUR APPLICATION
                                                   0012 STACK_BASE      LABEL   BYTE
                                                   0013 STACK   ENDS
                                                   0014 MEMORY  SEGMENT WORD MEMORY 'MEMORY'
                                                   0015 MEMORY_ LABEL   BYTE
                                                   0016 MEMORY  ENDS
                                                   0017 ABS_0   SEGMENT BYTE AT 0
                                                   0018 M       LABEL   BYTE
0001         NAME    EXAMPLE                      >0019         NAME    EXAMPLE
0002                                              >0020 ;
0003         ORG     0                            >0021         ORG     0
0004                                              >0022 ;
0005 DDATA   EQU     1000H                        >0023 DDATA   EQU     1000H
0006 BUFFER  EQU     2000H                        >0024 BUFFER  EQU     2000H
0007                                              >0025 ;
0008 START:  LD      HL,DDATA                     >0026 START:  MOV     BX,DDATA
0009         LD      DE,BUFFER                    >0027         MOV     DX,BUFFER
0010         LD      BC,737                       >0028         MOV     CX,737
0011         LDIR                                 >0029         XCHG    DI,DX   ; MOVE THE BUFFER
                                                   0030         XCHG    SI,BX
                                                   0031         CLD
                                                   0032         REP     MOVSB
                                                   0033         XCHG    DI,DX
                                                   0034         XCHG    SI,BX
                                                   0035         AND     AH,NOT( 10H OR 4H OR 2H )
0012         END                                  >0036 ABS_0   ENDS
                                                   0037         END     

0000 WARNINGS 




                                                                   1-8


1.6 ERROR INDICATIONS AND WARNINGS
__________________________________

There are two types  of error indications output by the Converter.  The
first is an error related to  I/O errors  in the  system.    These  are
output to the system console device in the form of a warning message:

        ***** WARNING nnnn I/O ERROR
                - where nnnn is the error number for the given system.

The appropriate  operations manual for  the system being used should be
consulted for an explanation of I/O errors.

The  second type of error indication is  a warning message which points
out those Z80  statements which could not be properly converted to 8086
source statements.  Warning messages are output to the PRINT dataset if
that option is in effect.  If the NOPRINT option is selected, then each
warning message and the statement to which it refers  are output to the
console device.  Each  warning message has a  number associated with it
and follows the 8086 source statement(s) to which it refers.

Warning messages should be examined  by  the user to determine  if  the
resultant  8086  statements are correct in meaning.  In most instances,
the problem can  be  corrected by manually  editing the  resultant 8086
source module.  This is  discussed  later in  this manual.    In  other
cases, the  warning message points out a feature which is not supported
in the 8086 assembly language (as defined by Intel's Version 1.0 of the
ASM86 8086 Cross Assembler).

Appendix A explains all warning messages output by the Converter.  Each
message has the form:

        *****WARNING nnnn description
                - where nnnn is a decimal number and description
                  is a brief description of the meaning of the warning.























                                                                   2-1


                               SECTION 2

                     EDITING THE CONVERTED MODULE


2.1 INTRODUCTION
________________

After  a Z80 program is converted to  8086 source statements, a certain
amount of user  modification (editing) of the 8086 source module may be
required.

Editing is usually required if any warning messages were  output by the
Converter.  Warning messages are output to the PRINT dataset.  They are
output to the console  device with associated statements if the NOPRINT
option is specified.  Warning messages should be studied by the user to
determine what editing is required.

There are several other areas which should be checked by the user after
the Z80 source module is converted  to 8086  source.   These areas  may
require additional editing and they are discussed below.

ABSOLUTE  ADDRESSING.    Absolute  addresses   should  be  checked  for
correctness.    In  general,  usage of  absolute  addresses  should  be
minimized by the user as a consequence of good programming practice.

RELATIVE ADDRESSING.  Relative addressing  should be checked because of
the  difference  in instruction lengths between the  Z80 and 8086.  The
Converter generates labels  for 8086 relative branches, so no  problems
should occur  in those  areas.    The use  of self-relative  addressing
(e.g.,  JR +4  or  JR $+4)  should  be  eliminated  by  the user  as  a
consequence of good programming practice.   However, displacements used
in  a  program (such as DEFB LABEL-$)  should be scrutinized for proper
meaning.

INTERRUPTS.  Interrupts  are  handled differently in the  Z80  and 8086
processors.  Therefore, interrupt code may have to be modified.

In the 8086 hardware, the interrupt vector type (0-255) is
placed on the bus by external devices (usually an 8259 interrupt
controller).  Next the 8086 pushes flags, CS, and IP, then jumps through 
the interrupt table to the interrupt service routine.

The Z80 supports three types(modes), of interrupts.
Mode 0 is compatible with the 8085.
    During the interrupt acknowledge phase an opcode (usually CALL 
    or RST) is placed on the bus for execution.
Mode 1 interrupts cause the Z80 to call to 0038h, similar to NMI.
Mode 2 interrupts assume an external device is going to present the
    handler vector number during acknowledge, which is then called to 
    from a predefined table.  This is similar to 8086 interrupt table 
    but can be anywhere in memory.

RESTARTS.  Z80 RST n instructions cause a call to one of eight 
locations in low memory (00h,08h,10h,18h,20h,28h,30h,38h).  Because
of the small space between vectors (8 bytes) and possible translated 
code expansion, the 8086 RST equivalent may not call to the correct
location.



                                                                   2-2



REGISTERS.  The Z80 also has 2 special purpose registers: I and R. 
These two registers cannot automatically be translated.  The I (interrupt) 
register points to the interrupt vector table for Mode 2 interrupt 
processing.  The R register contains the current RAM refresh address.  
These two registers are accessible to software only with the load 
instructions.  Loads to or from these registers are marked as errors 
during conversion.  The R register may be emulated on 80188/80186 
machines by setting up one of the internal timers.  Then Load instructions 
accessing R can be changed to use In/Out from this timer.

EXTERNAL AND PUBLIC SYMBOLS.  Matching of types should be checked among
a set of modules  to be linked together  by  the user.   The  Converter
assigns type 'NEAR' to all external symbols.

EQUATED SYMBOLS.  Symbols which are  equated are converted according to
a  set  of rules which  may not  always be correct  in  a given program
context.  When  the  converted program is assembled, typing  errors may
occur.  In these cases, the  user should  evaluate the  meaning of  the
program  and  correct the operand  expressions which use the symbols in
question.

INCORRECT SYMBOL TYPES.    Assembly of  a  converted  program  may show
additional  symbol  typing  errors  which   were  not  checked  by  the
Converter.    The  user should evaluate the  meaning of the program and
correct the operand expressions which use the symbols in question.




                                                                   3-1


                               SECTION 3

                         TECHNICAL INFORMATION


3.1 INTRODUCTION
________________

This specification describes the mapping of Z80 source language to 8086 
source language.  The basic  capabilities of the  Converter are similar 
to Intel's CONV86 program  which is an 8080 to 8086 source converter.  

3.2 CONVENTIONS USED IN THIS MANUAL
___________________________________

All user input  is  underlined.   Information  which  must  be  entered
exactly as  shown is in  upper case.  Variable information is  in lower
case.  The symbol <CR> stands for carriage return.

The following abbreviations are used throughout the manual:

        ib = byte immediate
        iw = word immediate
        mb = byte memory
        mw = word memory
        mn = near memory
        rb = byte register
        rw = word register
        rx = index register

3.3 TECHNICAL APPROACH
______________________

The Converter is written in PL/M-86.  Its I/O functions are modularized
for  easy  conversion  to  other  systems.    All  I/O  is  done  on  a
byte-by-byte basis.

The  Converter runs in two passes.   The first pass defines symbols and
symbol types and checks for certain errors.  The second pass checks the
syntax and semantics of the Z80 program and generates the corresponding
8086 program.   The output listing is generated during the second pass.













                                                                   4-1


                               SECTION 4

                                MAPPING


4.1 REGISTERS
_____________

The Z80 registers are  mapped to  the 8086  registers  according to the
following rules:

        Z80     8086
        ---     ----
        rb      rb'
        A       AL      SINGLE BYTE REGISTERS
        B       CH
        C       CL
        D       DH
        E       DL
        H       BH
        L       BL

        rw      rw'
        AF      AX      DOUBLE BYTE REGISTERS
        BC      CX
        DE      DX
        HL      BX
        SP      SP

        rx      rx'
        IX      SI      INDEX REGISTERS
        IY      DI

        --      BP      WORK REGISTER USED TO COMPLETE CONVERSION

        flags   AH

The  alternate  register set of  the Z80 is mapped to  a  set of memory
locations as follows:

        alternate register      memory location name
        ------------------      --------------------
        AF'                     ??AFPRIM
        BC'                     ??BCPRIM
        DE'                     ??DEPRIM
        HL'                     ??HLPRIM

Memory is allocated for these registers by  use of the option MAIN when
the Converter is  invoked.   These locations should appear  only in the
main, or first, module of  a  set of  modules to  be  linked  together.
These locations are globalized by the Converter in any Z80 module which
uses the instructions EXX and/or EX AF,AF'.




                                                                   4-2


4.2 FLAG CONVERSION
___________________

Z80 flags are mapped to 8086 register AH (in the same bit positions) as 
shown below:

BIT#:  7  6  5  4  3  2  1  0      REGISTER
       ----------------------      --------
       S  Z  _  H  _  PV N  C      Z80 flag register
       S  Z  _  A  _  P  _  C      8086 flag register (lower 8 bits)
       S  Z  _  H  _  PV N  C      8086 AH register (used as the 
                                   converted Z80 flag register)

where Z80 flag mnemonics are
    S   sign
    Z   zero
    H   half carry (nibble carry)
    PV  parity/overflow
    N   subtract (used in DAA instruction, set if last ALU operation
        was subtract)
    C   carry

and 8086 flag mnemonics are the same but for
    A   auxiliary carry (nibble carry)
    P   parity (only)


4.3 INSTRUCTION SET MAPPING
___________________________

The mapping from the  Z80 to the 8086  instruction  set is shown below.
Mapping  of   operands  is  described   in   another  section  of  this
specification.  Operand designations for the Z80 are as follows:

        ib = byte immediate
        iw = word immediate
        mb = byte memory
        mw = word memory
        mn = near memory
        rb = byte register
        rw = word register
        rx = index register

Similarly,  operand designations  for  the 8086 are  followed  with  an
apostrophe  (').   Constructs of  the  form  'Ln' are labels  generated
automatically by the Converter for certain mappings.















                                                                   4-3



Z80             8086                            REMARKS
---             ----                            -------

LD rb,rb        MOV rb',rb'
LD rb,ib        MOV rb',ib'
LD rb,(HL)      MOV rb',DS:[BX]
LD rb,(rx+ib)   MOV rb',[rx'+ib']
LD (HL),rb      MOV DS:[BX],rb'
LD (rx+ib),rb   MOV DS:[rx'+ib'],rb'
LD (HL),ib      MOV BYTE PTR DS:[BX],ib'
LD (rx+ib),ib   MOV BYTE PTR DS:[rx'+ib'],ib'
LD A,(BC)       MOV BP,CX
                MOV AL,DS:[BP]
LD A,(DE)       MOV BP,DX
                MOV AL,DS:[BP]
LD A,(mb)       MOV AL,mb'
LD (BC),A       MOV BP,CX
                MOV DS:[BP],AL
LD (DE),A       MOV BP,DX
                MOV DS:[BP],AL
LD (mb),A       MOV mb',AL
LD A,I          error
LD A,R          error
LD I,A          error
LD R,A          error

LD rw,iw        MOV rw',iw'
LD rx,iw        MOV rx',iw'
LD rw,(mw)      MOV rw',mw'
LD rx,(mw)      MOV rx',mw'
LD (mw),rw      MOV mw',rw'
LD (mw),rx      MOV mw',rx'

LD SP,HL        MOV SP,BX
LD SP,rx        MOV SP,rx'

PUSH AF         XCHG AL,AH
                PUSH AX
                XCHG AL,AH

PUSH rw         PUSH rw'
PUSH rx         PUSH rx'

POP AF          POP AX
                XCHG AL,AH

POP rw          POP rw'
POP rx          POP rx'

EX DE,HL        XCHG BX,DX
EX AF,AF'       XCHG AX,??AFPRIM

EXX             XCHG BX,??HLPRIM
                XCHG DX,??DEPRIM
                XCHG CX,??BCPRIM

EX (SP),HL      MOV BP,SP
                XCHG BX,[BP]
EX (SP) rx      MOV BP,SP
                XCHG [BP],rx'

                                                                   4-4


LDI             SAHF
                MOV AH,[BX]
                MOV BP,DX
                MOV [BP],AH
                LAHF
                AND AH,080H OR 040H OR 01H
                INC BX
                INC DX
                DEC CX
                JZ Ln
                OR AH,04H
        Ln      

LDIR            XCHG DI,DX
                XCHG SI,BX
                CLD
                REP MOVSB
                XCHG DI,DX
                XCHG SI,BX
                AND AH,NOT( 010H OR 04H OR 02H )

LDD             SAHF
                MOV AH,[BX]
                MOV BP,DX
                MOV [BP],AH
                LAHF
                AND AH,NOT( 010H OR 02H OR 04H )
                DEC BX
                DEC DX
                DEC CX
                JZ Ln
                OR AH,04H
        Ln

LDDR            XCHG DI,DX
                XCHG SI,BX
                STD
                REP MOVSB
                XCHG DI,DX
                XCHG SI,BX
                AND AH,NOT( 010H OR 04H OR 02H )

CPI             CMP AL,[BX]
                ROR AH,01
                LAHF
                AND AH,NOT( 04H )
                INC BX
                DEC CX
                JZ Ln
                OR AH,04H
        Ln

                                                                   4-5


CPIR            SHR AH,01
                RCL BP,01
                XCHG DI,BX
                CLD
                REPNE SCASB
                XCHG DI,BX
                ROR BP,01
                LAHF
                AND AH,NOT( 04H )
                JCXZ Ln
                OR AH,04H
        Ln

CPD             CMP AL,[BX]
                ROR AH,01
                LAHF
                AND AH,NOT( 04H )
                DEC BX
                DEC CX
                JZ Ln
                OR AH,04H
        Ln

CPDR            SHR AH,01
                RCL BP,01
                XCHG DI,BX
                STD
                REPNE SCASB
                XCHG DI,BX
                ROR BP,01
                LAHF
                AND AH,NOT( 04H )
                JCXZ Ln
                OR AH,04H
        Ln

ADD A,rb        ADD AL,rb'
                LAHF
                JO L1
                AND AH,NOT( 04H OR 02H )
                JMP L2
        L1      OR AH,04H
                AND AH,NOT( 02H )
        L2  
ADD A,ib        ADD AL,ib'
                above
ADD A,(HL)      ADD AL,DS:[BX]
                above
ADD A,(rx+ib)   ADD AL,DS:[rx'+ib']
                above

Same for ADC, SUB, SBC, AND, OR, XOR, CP


                                                                   4-6


INC rb          SHR AH,01
                INC rb'
                LAHF
                JO L1
                AND AH,NOT( 04H OR 02H )
                JMP L2
        L1      OR AH,04H
                AND AH,NOT( 02H )
        L2  

INC (HL)        INC BYTE PTR [BX]
                above

INC (rx+ib)     INC BYTE PTR [ix+ib]
                above

DEC rb          SHR AH,01
                INC rb'
                LAHF
                JO L1
                AND AH,NOT( 04H )
                JMP L2
        L1      OR AH,04H
                AND AH,NOT( 04H )
        L2  

Similar for other DEC(S).

DAA             TEST AH,02H
                JZ L1
                SAHF
                DAS
                LAHF
                JMP L2
        L1      SAHF
                DAA
                LAHF
                AND AH,NOT( 02H )
        L2  
CPL             NOT AL
NEG             NEG AL
CCF             CMC
SCF             STC
NOP             NOP
HALT            HLT
DI              CLI
EI              STI
IM              error


ADD HL,rw       AND AH,NOT( 02H )
                SHR AH,01
                ADD BX,rw'
                RCL AH,01

Similar for ADC and SBC

                                                                   4-7


ADD IX,IX       AND AH,NOT( 02H )
                SHR AH,01
                ADD si,si
                RCL AH,01

Similar for ADD IY,IY and ADD rx,rw

INC rw          INC rw'

INC rx          INC rx'

Similar for DEC.

RLCA            SHR AH,01
                ROL AL,01
                RCL AH,01
                AND AH,NOT( 02H OR 010H )

RLA             SHR AH,01
                RCL AL,01
                RCL AH,01
                AND AH,NOT( 02H OR 010H )

RRCA            SHR AH,01
                ROR AL,01
                RCL AH,01
                AND AH,NOT( 02H OR 010H )

RRA             SHR AH,01
                RCR AL,01
                RCL AH,01
                AND AH,NOT( 02H OR 010H )

RLC rb          SHR AH,01
                ROL AL,01
                RCL AH,01
                AND AH,NOT( 02H OR 010H )

RLC (HL)        MOV AH,[BX]
                ROL AH,01
                MOV [BX],AH
                RCL BP,01
                OR AH,AH
                ROR BP,01
                LAHF
                AND AH,NOT( 02H OR 010H )
RLC (rx+ib)     MOV AH,[rx'+ib']
                ROL AH,01
                MOV [rx'+ib'],AH
                RCL BP,01
                OR AH,AH
                ROR BP,01
                LAHF
                AND AH,NOT( 02H OR 010H )

Similar for RL -> RCL
        RRC -> ROR
        RR -> RCR
        SLA -> SAL
        SRA -> SAR
        SRL -> SHR

                                                                   4-8


RLD             MOV BP,AX
                AND BP,001F0H
                MOV AH,AL
                SHL AH,01
                SHL AH,01
                SHL AH,01
                SHL AH,01
                MOV AL,[BX]
                ROL AX,01
                ROL AX,01
                ROL AX,01
                ROL AX,01
                MOV [BX],AL
                MOV AL,AH
                SHL AH,01
                OR AX,BP
                OR AL,AL
                ROR AH,01
                LAHF
                AND AH,NOT( 010H OR 02H )

RRD             MOV BP,AX
                AND BP,001F0H
                MOV AH,AL
                MOV AL,[BX]
                ROR AX,01
                ROR AX,01
                ROR AX,01
                ROR AX,01
                MOV [BX],AL
                MOV AL,AH
                SHR AL,01
                SHR AL,01
                SHR AL,01
                SHR AL,01
                SHL AH,01
                OR AX,BP
                OR AL,AL
                ROR AH,01
                LAHF
                AND AH,NOT( 010H OR 02H )

BIT ib,rb       TEST rb',ib'(converted to a mask)
                ROR AH,01
                LAHF
                OR AH,010H
                AND AH,NOT( 02H )

SET ib,rb       OR rb',ib'(converted to a mask)

RES ib,rb       AND rb',ib'(converted to a mask)

Similar for (HL) and (rx+ib).

                                                                   4-9


JP mn           JMP mn'
JP NZ,mn        JZ Ln
                JMP mn'
        Ln      LABEL NEAR
JP Z,mn         JNZ Ln
                JMP mn'
        Ln      LABEL NEAR
JP NC,mn        JB Ln
                JMP mn'
        Ln      LABEL NEAR

JP C,mn         JAE Ln
                JMP mn'
        Ln      LABEL NEAR
JP PO,mn        JPE Ln
                JMP mn'
        Ln      LABEL NEAR
JP PE,mn        JPO Ln
                JMP mn'
        Ln      LABEL NEAR
JP P,mn         JS Ln
                JMP mn'
        Ln      LABEL NEAR
JP M,mn         JNS Ln
                JMP mn'
        Ln      LABEL NEAR

JR mn           JMP mn'         warning generated

JR C,mn         JAE Ln          warning generated
                JMP mn'
        Ln
JR NC,mn        JC Ln           warning generated
                JMP mn'
        Ln
JR Z,mn         JNZ Ln          warning generated
                JMP mn'
        Ln
JR NZ,mn        JZ Ln           warning generated
                JMP mn'
        Ln
                
JP (HL)         JMP BX
JP (rx)         JMP rx'

DJNZ mn         DEC CH
 or DJNZ mn-$   JNZ mn'

                                                                   4-10


CALL mn         CALL mn'
CALL NZ,mn      JZ Ln
                CALL mn'
        Ln      LABEL NEAR
CALL Z,mn       JNZ Ln
                CALL mn'
        Ln      LABEL NEAR
CALL NC,mn      JB Ln
                CALL mn'
        Ln      LABEL NEAR
CALL C,mn       JAE Ln
                CALL mn'
        Ln      LABEL NEAR
CALL PO,mn      JPE Ln
                CALL mn'
        Ln      LABEL NEAR
CALL PE,mn      JPO Ln
                CALL mn'
        Ln      LABEL NEAR
CALL P,mn       JS Ln
                CALL mn'
        Ln      LABEL NEAR
CALL M,mn       JNS Ln
                CALL mn'
        Ln      LABEL NEAR

RET             RET


RET NZ          JZ Ln
                RET
        Ln      LABEL NEAR

Similar for RET Z, NC,C,PO,PE,P,M.

RETI            IRET                    warning generated

RETN            IRET                    warning generated

RST p           CALL p*8                warning generated

IN A,(ib)       IN AL,ib'
IN A,(C)        MOV BP,DX
                MOV DL,CL
                XOR DH,DH
                IN AL,DX
                SHR AH,01
                INC AL
                DEC AL
                LAHF
                MOV DX,BP

                                                                   4-11


IN F,(C)        MOV BP,DX
                MOV DL,CL
                XOR DH,DH
                MOV CL,AL
                IN AL,DX
                SHR AH,01
                INC AL
                DEC AL
                LAHF
                MOV AL,CL
                MOV CL,DL
                MOV DX,BP

IN rb,(C)       MOV BP,DX
                MOV rb',AL
                MOV DL,CL
                XOR DH,DH
                IN AL,DX
                SHR AH,01
                INC AL
                DEC AL
                LAHF
                XCHG rb',AL
                MOV DX,BP

INI             SAHF
                MOV AH,AL
                MOV BP,DX
                MOV DH,00
                MOV DL,CL
                IN AL,DX
                MOV [BX],AL
                MOV DX,BP
                MOV AL,AH
                LAHF
                AND AH,02H OR 01H
                INC BX
                DEC CH
                JNZ Ln
                OR AH,040H
        Ln

INIR            SAHF
                MOV AH,AL
                MOV BP,DX
                MOV DH,00
                MOV DL,CL
        Ln      IN AL,DX
                MOV [BX],AL
                INC BX
                DEC CH
                JNZ Ln
                MOV DX,BP
                MOV AL,AH
                LAHF
                OR AH,040H OR 02H

                                                                   4-12


IND             SAHF
                MOV AH,AL
                MOV BP,DX
                MOV DH,00
                MOV DL,CL
                IN AL,DX
                MOV [BX],AL
                MOV DX,BP
                MOV AL,AH
                LAHF
                AND AH,02H OR 01H
                DEC BX
                DEC CH
                JNZ Ln
                OR AH,040H
        Ln

INDR            SAHF
                MOV AH,AL
                MOV BP,DX
                MOV DH,00
                MOV DL,CL
        Ln      IN AL,DX
                MOV [BX],AL
                DEC BX
                DEC CH
                JNZ Ln
                MOV DX,BP
                MOV AL,AH
                LAHF
                OR AH,040H OR 02H

OUT (ib),A      OUT ib',AL

OUT (C),A       MOV BP,DX
                MOV DL,CL
                XOR DH,DH
                OUT DX,AL
                MOV DX,BP

OUT (C),rb      MOV BP,DX
                XCHG AL,rb'
                MOV DL,CL
                XOR DH,DH
                OUT DX,AL
                XCHG AL,rb'
                MOV DX,BP

                                                                   4-13


OUTI            SAHF
                MOV AH,AL
                MOV BP,DX
                MOV DL,CL
                MOV DH,00
                MOV AL,[BX]
                OUT DX,AL
                MOV DX,BP
                MOV AL,AH
                LAHF
                AND AH,02H OR 01H
                INC BX
                DEC CH
                JNZ Ln
                OR AH,040H
        Ln

OTIR            SAHF
                MOV AH,AL
                MOV BP,DX
                MOV DL,CL
                MOV DH,00
        Ln      MOV AL,[BX]
                OUT DX,AL
                INC BX
                DEC CH
                JNZ Ln
                MOV DX,BP
                MOV AL,AH
                LAHF
                OR AH,040H OR 02H

OUTD            SAHF
                MOV AH,AL
                MOV BP,DX
                MOV DL,CL
                MOV DH,00
                MOV AL,[BX]
                OUT DX,AL
                MOV DX,BP
                MOV AL,AH
                LAHF
                AND AH,02H OR 01H
                DEC BX
                DEC CH
                JNZ Ln
                OR AH,040H
        Ln

                                                                   4-14


OTDR            SAHF
                MOV AH,AL
                MOV BP,DX
                MOV DL,CL
                MOV DH,00
        Ln      MOV AL,[BX]
                OUT DX,AL
                DEC BX
                DEC CH
                JNZ Ln
                MOV DX,BP
                MOV AL,AH
                LAHF
                OR AH,040H OR 02H

                                                                   4-15


4.4 CONVERSION OF OPERAND EXPRESSIONS IN CONTEXT
________________________________________________

Expressions from a  Z80  source program are converted to  corresponding
expressions  for  the 8086.   Because  the  8086  assembly language  is
strongly typed, the  context of each operand must be  determined during
conversion.

The type of each symbol used in the Z80 program is determined according
to the following rules:

Z80 CONTEXT                     CORRESPONDING SYMBOL TYPE
-----------                     -------------------------

symbol opcode                   mn
symbol<CR>                      mn
symbol EQU $                    mn
symbol EQU number               ib if number < 256
                                iw if number >= 256
symbol EQU symbol2              same type as symbol2
symbol EQU expression           type determined by form of expression

symbol DEFB expr                mb
symbol DEFW expr                mw
symbol DEFM expr                mb
symbol DEFS expr                mb
symbol DEFL expr                same as for EQU pseudo-op
       GLOBAL symbol            If symbol is external, then type is mn
                                If the symbol is internal, then type is
                                determined by the other rules.

The type of an  expression  is  determined according  to the  following
algorithm.

    Each  item  in  an expression is checked  and the type is obtained.
    Numbers are evaluated to determine if they are byte or word values.
    Symbols are accessed in  the symbol table and  their  type obtained
    from the type byte in the table.  ASCII strings are evaluated based
    on  the  number  of characters  and  are  of either  byte  or  word
    immediate type.  The  symbol '$' is always evaluated as label type.

    Each time an operator is encountered, the two  items on either side
    of it are processed according to  the following table to produce an
    overall type for the expression.   In this table, the  type  of the
    first  operand  is  shown across the top.   The  type of the second
    operand is shown down  the left  side.   The resulting type of  the
    expression  is  shown  in the  matrix.   Some of  the  combinations
    produce a warning message.  The number of the message is shown next
    to the resulting type.  The following codes are used:

        ib - immediate byte type
        iw - immediate word type
        mb - memory byte variable type
        mw - memory word variable type
        mn - label type

        73 - expression is assumed to be type label

                                                                   4-16


        74 - expression is assumed to be type variable
        75 - expression is assumed to be type number

                type of first operand
                -----------------------------------------------
type of 2nd
operand         ib      iw      mb      mw      mn
---------       -----------------------------------------------
   ib           ib      iw      mb 74   mw 74   mn

   iw           iw      iw      mb 74   mw 74   mn

   mb           mb 74   mb 74   iw 75   iw 75   iw 75

   mw           mw 74   mw 74   iw 75   iw 75   iw 75

   mn           mn      mn      iw 75   iw 75   iw 75
---------       -----------------------------------------------

The same algorithm is  used for  determining symbol  types for  EQU and
DEFL statements and for determining operand types in an instruction.

The following table explains how  Z80 expressions are converted to 8086
expressions  according  to  the  8086 context in  which the  expression
occurs.  The operand type is determined from the rules discussed above.

8086 CONTEXT    Z80 TYPE                RESULTANT 8086 EXPRESSION
------------    --------                -------------------------
ib              ib:expr                 expr'
                iw:expr                 LOW(expr')
                mb or mw or mn:expr     LOW DGROUP:(expr') (if REL option)
                                        OFFSET(expr')      (if ABS option)

iw              ib or iw:expr           expr'
                mb or mw or mn:expr     OFFSET DGROUP:(expr') (if REL option)
                                        OFFSET(expr')         (if ABS option)

mb              mb:expr                 expr'
                mn or mw:expr           BYTE PTR (expr')
                ib or iw:expr           DS:[expr']

mn              mn:expr                 expr'
                mb or mw:expr           NEAR PTR (expr')
                ib or iw:expr           NEAR PTR DS:[expr']

mw              mw:expr                 expr'
                mb or mn:expr           WORD PTR(expr')
                ib or iw:expr           WORD PTR DS:[expr']

rb              rb                      rb'
                mb:M                    [BX]

rw              rw                      rw'
                rx                      rx'

Note that DGROUP refers to the group of data segments as defined in the

                                                                   4-17


prologue generated by the Converter.

4.5 ASSEMBLER PSEUDO-OP MAPPING
_______________________________

The mapping of Z80 pseudo-ops to 8086 directives is shown below.

Z80                     8086

ORG mn                  ORG mn
label EQU $             label LABEL NEAR
label EQU expr          label EQU expr
label DEFL expr         PURGE label
                        label EQU expr
DEFB expr-list          DB expr-list
DEFM 'aa'               DB 'aa'
DEFW expr-list          DW expr-list
DEFS expr               DB expr DUP (?)
END expr                prev-seg ENDS
                        END expr
GLOBAL symbol-list      For internal symbols:
                        PUBLIC symbol-list
                        For external symbols:
                        EXTRN symbol:NEAR
NAME symbol             NAME symbol
IF or COND              %IF (expr') THEN (      warning generated
ENDIF or ENDC           )FI             warning generated
EJECT                   $EJECT
TITLE title             $TITLE (title)
LIST expr               $LIST                   warning generated
NLIST                   $NOLIST
a MACRO b,c,... %*DEFINE(a(b,c,...)) (  warning generated if parameters
MEND                    )
MEXIT                   %EXIT
ELIST                   $GEN
INCLUDE file            $INCLUDE file           warning generated

macro call:
 OP a,b,...     %OP a,b,...             warning generated if arguments

All other directives are flagged as warnings.

4.6 RESERVED WORD HANDLING
__________________________

All 8086 reserved words encountered as labels or  external symbols in a
Z80  source  module are flagged  with  warnings.  The keywords  CGROUP,
CODE, CONST, DATA, DGROUP, M, ?, and  ??SEG are also be treated in this
manner.

4.7 GLOBAL SYMBOLS
__________________

Internal  symbols  are  typed  by  the  rules shown  for  Z80  symbols.
External symbols are  typed as 'NEAR'.   This means that the type of an
external reference  may not  match  the  corresponding internal  symbol
type.   Modules  which  use external  symbols  may  require  additional
editing by the user after conversion.  A warning is  output  after such
declarations in the PRINT file.

                                                                   A-1










                              APPENDIX A

                           ERROR DICTIONARY














































                                                                   A-2


71 - INSTRUCTION NOT CONVERTIBLE
    The  Z80  instruction has no  architectural equivalent or assembler
    equivalent in the  8086.  The user  should evaluate  the meaning of
    the program being converted  to determine how to handle the problem
    area for the 8086.

72 - CONVERSION MAY NOT BE CORRECT
    The conversion  of the Z80  instruction  may not  produce the  same
    results during execution on the 8086.  The user should evaluate the
    meaning  of the program being converted to  determine how to handle
    the problem area for the 8086.

73 - EXPRESSION ASSUMED TO BE TYPE LABEL
    An expression, after  conversion, was assumed to be of  type label.
    The user should evaluate  what  the  meaning of  the expression  is
    after conversion and adjust the 8086 statement accordingly.

74 - EXPRESSION ASSUMED TO BE TYPE VARIABLE
    An  expression,  after  conversion,  was  assumed  to  be  of  type
    variable.    The  user  should evaluate  what  the  meaning  of the
    expression  is  after  conversion  and  adjust the  8086  statement
    accordingly.

75 - EXPRESSION ASSUMED TO BE TYPE NUMBER
    An expression, after conversion, was assumed  to be of type number.
    The  user  should evaluate what  the meaning  of the expression  is
    after conversion and adjust the 8086 statement accordingly.

76 - ADDRESS EXPRESSION MAY BE INVALID
    The converted expression  may  not be  correct in  its  form.  This
    warning occurs for Z80 relative jump instructions.  The user should
    adjust the  operand of the  converted output to be compatible  with
    8086 rules.

77 - OUTPUT LINE TOO LONG - TRUNCATED
    The  output line on the printed listing  was too long to fit on 132
    column paper; some  of  the line may be missing.   No truncation is
    done on the source output file.

78 - LABEL ASSUMED TO BE NEAR
    The type of the label in the statement is assumed to be NEAR.   For
    those programs which required expansion to  more than  one 64K byte
    segment after conversion, the user should review the typing of  all
    labels.

79 - not implemented in V1.1.

80 - EXTERNAL SYMBOLS ARE ASSUMED TO BY TYPE NEAR
    All external symbols are assumed  to be labels of type near.   This
    may  not  be  correct in the final  8086 context.   The user should
    evaluate the meaning of  the program  being converted  to determine
    how to handle the problem area for the 8086.

81 - not implemented in V1.1.

                                                                   A-3


82 - FLAG(S) MAY HAVE DIFFERENT MEANING
    The flags in the final 8086 program have a different  meaning  than
    those  in  the Z80 program.   This  warning should not occur with ZCON 
    version 1.3 or later.

83 - INVALID Z80 OPCODE
    An  invalid  Z80   opcode  was  encountered  in  the  source  file.
    Translation is not done for this statement.

84 - INVALID Z80 OPERAND COMBINATION
    The operands used in the Z80 statement are not  valid for the given
    opcode.  Conversion is not done for this statement.

85 - 8086 RESERVED WORD USED AS A SYMBOL
    The label in the  source statement is an  8086 reserved word.   The
    Converter makes no attempt to  correct  these symbols, so the  user
    must edit his final source module to change the symbol.

86 - SYMBOL TABLE FULL
    The symbol table became full during the course of conversion.  This
    means  that  the  Z80 source file has  too many symbols in it.  The
    program should  be broken  up  before  conversion.   The  Converter
    allows  over 1400 6-character symbols to occur in one module.  This
    error aborts the  Converter  and returns control  to the  Operating
    System.

87 - INPUT IN PASS 2 DOES NOT MATCH PASS 1
    This error indicates either a program error or  an I/O error in the
    source file being converted.  The  user should either try  again or
    check his disk integrity.

88 - SYNTAX ERROR IN COMMAND LINE
    An   error   in   either  the   dataset  specification   or  option
    specification in the command  line was detected.  The  Converter is
    aborted.  The user should retype  his command  line in  the correct
    format.

89 INCLUDE FILE SPEC MAY NOT BE CORRECT
    The  specification  of  an  included  file should  be  checked  for
    correctness by the user before assembling the converted 8086 source
    file.

90 - I/O ERROR - CONSULT OPERATING SYSTEM MANUAL FOR EXPLANATION
    An unrecoverable I/O error occurred on the system.  This message is
    output  to  the  console  device  and  the  conversion is  aborted.
    Consult  the  appropriate operations manual  for  the system  being
    used.

91 - INVALID CHARACTER IN SYMBOL
    An invalid character  was  found in  a  symbol.    The  user should
    correct  all  occurrences  of the  symbol in  the converted  source
    module before assembling the program.

92 - MACRO PARAMETERS MAY REQUIRE EDITING
    The parameters used in  a macro definition or  macro call should be

                                                                   A-4


    reviewed  for  correctness  by the  user  prior  to assembling  the
    program.

93 - MACRO PSEUDO-OP REQUIRES EDITING
    The usage of a  Z80  macro  pseudo-op (MLOCAL,  MNEXT, MIF,  MGOTO,
    MNOP,   or   MERROR)  should  be  inspected  by   the  user.    The
    corresponding 8086 output  should  then be  edited to  produce  the
    correct macro definition.

94 - OPERATOR NOT CONVERTIBLE
    The Z80  operator in an  expression could not be converted.    This
    warning applies specifically to the operators .RES.  and .DEF.  The
    user should modify his program to take this into account.












































                                                                   B-1










                              APPENDIX B

                RESERVED WORDS FLAGGED BY THE CONVERTER














































                                                                   B-2


The following reserved words are flagged with warnings.

?
??SEG           AAA             AAD             AAM             AAS         
ABS             ADC             ADD             AH              AL
AND             ASSUME          AT              AX              BH
BL              BP              BX              BYTE            CALL
CBW             CGROUP          CH              CL              CLC
CLD             CLI             CMC             CMP             CMPS
CMPSB           CMPSW           CODE            CODEMACRO       COMMON
CONST           CS              CWD             CX              DAA
DAS             DATA            DB              DD              DEC
DGROUP          DH              DH              DI              DIV
DL              DS              DUP             DW              DWORD
DX              ELSE            ELSEIF          END             ENDIF
ENDM            ENDP            ENDS            EQ              EQS
EQU             ES              ESC             EVAL            EVEN
EXIT            EXTRN           FAC             FALC            FAR
FI              GE              GES             GROUP           GT
GTS             HIGH            HLT             IDIV            IMUL
IN              INC             INCHAR          INPAGE          INT
INTO            IRET            JA              JAE             JB
JBCZ            JBE             JC              JCXZ            JE
JG              JGE             JL              JLE             JMP
JNA             JNAE            JNB             JNBE            JNC
JNE             JNG             JNGE            JNL             JNLE
JNO             JNP             JNS             JNZ             JO
JP              JPE             JPO             JS              JZ
LABEL           LAHF            LDS             LE              LEA
LEN             LENGTH          LES             LOCK            LODS
LODSB           LODSW           LOOP            LOOPE           LOOPNE
LOOPNZ          LOOPZ           LOW             LT              M
MASK            MATCH           MEMORY          METACHAR        MOD
MODRM           MOV             MOVS            MOVSB           MOVSW
MUL             NAME            NE              NEAR            NEG
NOP             NOSEGFIX        NOT             NOTHING         OFFSET
OR              ORG             OUT             PAGE            PARA
POP             POPF            PREFX           PROC            PROCLEN
PTR             PUBLIC          PURGE           PUSH            PUSHF
RCL             RCR             RECORD          RELB            RELW
REP             REPE            REPEAT          REPNE           REPNZ
REPZ            RET             ROL             ROR             SAHF
SAL             SAR             SBB             SCAS            SCASB
SCASW           SEG             SEGFIX          SEGMENT         SET
SHL             SHORT           SHR             SI              SIZE
SP              SS              STACK           STC             STD
STI             STOS            STOSB           STOSW           STRUC
SUB             SUBSTR          TEST            THIS            TYPE
WAIT            WHILE           WIDTH           WORD            XCHG
XLAT            XLATB           XOR












                                                                   C-1










                              APPENDIX C

            REDUCING CONVERTED CODE SIZE AND EXECUTION TIME














































                                                                   C-2


ZCON emulates all Z80 flags, whether used subsequently or not, to minimize
editing required to achieve a fully functional program.  If speed and memory
size are important, this converted 8086 source code can be modified to reduce
code space.  This section describes how to remove uneeded code.

The main cause of code expansion is as a result of emulating the following 
Z80 flags:
    PV  (parity/overflow) when it behaves as overflow, and
    N   (subtract)
The PV flag acts both as Parity and as Overflow; and the N flag has 
no corresponding 8086 flag.  This is why the 8086 AH register is used as 
the Z80 flag register.  When these flags are not used the emulation 
code may be removed.

As an example, look at the Z80 instruction
        ADD     A,B
which adds register B to register A.  The S, Z, H, PV and C flag are 
set according to the result; the PV flag behaves as Overflow; and 
the N flag becomes 0 (because this is not a subtract operation).

With the 8086 equivalent opcode
        ADD     AL,CH
all flag changes correspond direct to Z80 flags except the P and N flags.  
The P flag acts only as Parity, and the N flag doesnt exist at all.  
To resolve these descrepancies the converter will generate
        ADD     AL,CH
        LAHF                            ; AH= flags
        JO      L1                      ; add produced overflow?
        AND     AH,NOT( 06h )           ; clear N, and PV acting as overflow
        JMP     L2
L1:     OR      AH,04H                  ; set PV acting as overflow
        AND     AH,NOT( 02H )           ; clear N
L2:
which emulates Z80 flag changes exactly.  If following opcodes produce these
flags again before any opcode uses them, this code may be reduced.  If, for
instance, the next instruction is also an ADD, none of the code which
emulates the PV and N flags is necassary.  This opcode could be
modified to the following:
        ADD     AL,CH
        LAHF                            ; AH= flags

The opcodes to focus upon for code removal are:
        ADD     byte,byte
        ADC     byte,byte
        SUB     byte,byte
        SBC     byte,byte
        CP      byte,byte
        INC     byte
        DEC     byte
        RR      byte
        RCR     byte
        RL      byte
        RCL     byte
