home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / asmutl / zm3p.lbr / ZM3P.DZC / ZM3P.DOC
Encoding:
Text File  |  1987-07-29  |  68.6 KB  |  1,710 lines

  1. .pl 88
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                       ZZZZZZZZZZZ    MMMM          MMMM
  9.                               ZZ     MM MM        MM MM
  10.                              ZZ      MM  MM      MM  MM
  11.                             ZZ       MM   MM    MM   MM
  12.                            ZZ        MM    MM  MM    MM
  13.                           ZZ         MM     MMMM     MM
  14.                          ZZ          MM      MM      MM
  15.                         ZZ           MM              MM
  16.                        ZZ            MM              MM
  17.                       ZZZZZZZZZZZ    MM              MM
  18.  
  19.  
  20.  
  21.  
  22.  
  23.                                Copyright  (c) 1983
  24.                                  Roger E. Donais
  25.  
  26.  
  27.  
  28.  
  29.                   If you have ant questions concerning ZM,
  30.                   contact the author:
  31.  
  32.                             Roger E. Donais, USA Ret
  33.                              7506 Republic Ct. #201
  34.                               Alexandria, VA 22306
  35.                                  (703) 765-0615
  36.  
  37.  
  38.  
  39.  
  40.  
  41.                              C  O  N  T  E  N  T  S
  42.              
  43.              INTRODUCTION ....................................   1
  44.              STATEMENT SYNTAX ................................   4
  45.              OPCODES .........................................   5
  46.              OPERANDS ........................................   5
  47.              OPERATORS .......................................   7
  48.              DIRECTIVES ......................................   9
  49.              PREDEFINED USER SYMBOLS .........................  13
  50.              TERMINAL ERRORS .................................  14
  51.              FATAL ERRORS ....................................  16
  52.              WARNING MESSAGES ................................  18
  53.              RUNTIME REQUIREMENTS ............................  19
  54.              RESERVED SYMBOLS ................................  20
  55.              Z80 SYNTAX SUMMARY ..............................  21
  56.              ALTERATION ......................................  23
  57.              INDEX ...........................................  27
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.                              I N T R O D U C T I O N
  66.  
  67.              ZM translates symbolic language source files into machine 
  68.         executable code in either (.COM) or Intel loader (.HEX) format.  
  69.         It has been designed to be easily used by the novice, yet provide 
  70.         a variety of capabilities powerful enough for the expert.  ZM can 
  71.         be used to assemble large files on relatively small systems.
  72.  
  73.         TO USE:   Enter    ZM  drive:filename.type  options
  74.  
  75.              Where "drive" is the CP/M drive which will receive the 
  76.              assembled  object file, "filename.type" is any valid CP/M 
  77.              file, and "options" are one or more of the following:
  78.  
  79.                   L         to get an assembled Listing
  80.                   H         to get a .HEX type object file
  81.                   C         to get a .COM type object file
  82.                   1         for printer setup #1 (see alteration notes)
  83.                   2         for printer setup #2 (see alteration notes)
  84.                   =         to enter subject text (see listing)
  85.  
  86.              All options, except "=", may be entered in any order.  When 
  87.         used, the "=" option must always be entered last.  Default     
  88.         settings are NO listing, NO object file and a blank subject line.  
  89.         ZM uses the same resources to produce both a .HEX and .COM Object 
  90.         file, therefore only one or the other may be requested.
  91.  
  92.  
  93.         NOTE:   ^C may be used to abort assembly from the keyboard.
  94.                 ^S may be used to pause and restart assembly.
  95.  
  96.  
  97.                   EXAMPLE:      C>ZM  B:JUNK.PDQ C
  98.  
  99.                        Will cause ZM to create the object file B:JUNK.COM 
  100.                        using the first JUNK.PDQ found on the designated 
  101.                        drive, default drive, an internally defined drive 
  102.                        or drive A:.  If JUNK.PDQ cannot be found on any 
  103.                        of these drives, ZM will prompt with the message:  
  104.  
  105.                        --Insert disk with JUNK.PDQ and press  <RETURN>
  106.  
  107.                        The disk may then be inserted in any of the 
  108.                        previously mentioned drives, EXCEPT the drive 
  109.                        destined to receive the object file (in this 
  110.                        example B:).  The process will repeat until 
  111.                        JUNK.PDQ is found, or a ^C is entered in response 
  112.                        to the prompt.
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.                                     PAGE 1
  123.  
  124.  
  125.  
  126.  
  127.         LISTING:  A two line heading is printed on each page:
  128.  
  129.              SUBJECT:     __________________________________________
  130.              SOURCE FILE: _______     PAGE - nn      DATE:  yy/mm/dd
  131.  
  132.              The source file is the name of the file currently being 
  133.         assembled (see INCL directive).  The subject will contain the 
  134.         text immediately following an equal sign.   Control characters 
  135.         may be entered to initialize specific printer options.  Maximum 
  136.         text length is 63 characters.
  137.  
  138.              An assembly listing is printed only when the "L" option has 
  139.         been selected.  The actual listing may then be disabled/enabled 
  140.         by LIST directive.  A partial listing, consisting of all source 
  141.         statements containing warning and fatal assembly error messages, 
  142.         will be displayed whenever the "L" option has not been selected. 
  143.  
  144.              The console is the default list device.  Use options 1 or 2 
  145.         to obtain printer output.  Used by themselves, they will direct 
  146.         the error and warning messages to the printer.  Used with the "L" 
  147.         option, they direct the entire assembly listing to the printer.  
  148.         If the printer is NOT ready when ZM begins to print, output will 
  149.         automatically be set to the console.  ZM will wait indefinately 
  150.         if the printer goes off line, or otherwise becomes unavailable, 
  151.         once printer output has started.
  152.  
  153.              EXAMPLES:
  154.  
  155.                        ZM JUNK        error messages will be sent to 
  156.                                       the console.
  157.  
  158.                        ZM JUNK 1      error messages will be sent to 
  159.                                       the printer using printer setup 
  160.                                       string #1.  If the printer is 
  161.                                       not ready, messages will be 
  162.                                       sent to the console.
  163.  
  164.                        ZM JUNK L      listing will be sent to the 
  165.                                       console.
  166.  
  167.                        ZM JUNK L2     listing will be sent to the 
  168.                                       printer using printer setup 
  169.                                       string #2.  If the printer is 
  170.                                       not ready, listing will be sent 
  171.                                       to the console.
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.                                     PAGE 2
  184.  
  185.  
  186.  
  187.         END OF ASSEMBLY:    The following will be displayed:
  188.  
  189.                                 NEXT ADDRESS  nnnnH
  190.                                 NEXT DATA     nnnnH
  191.                                 FREE MEMORY   nnnnH
  192.                                 STACK SPACE   nnnn
  193.                                 ERROR COUNT   nnnn/nnnn
  194.  
  195.         NEXT ADDRESS is the first hexadecimal address following the last 
  196.              item of assembled code.
  197.              
  198.         NEXT DATA is the hexadecimal value currently assigned to the 
  199.              predefined symbol DATA. (see directives and predefined 
  200.              symbols).  Depending upon how the DATA directive/symbol was 
  201.              used, NEXT ADDRESS or NEXT DATA could be used as the origin 
  202.              for a co-resident or chained program or program overlay.
  203.              
  204.         FREE MEMORY is the hexadecimal amount of memory available for 
  205.              symbols and object file buffer (see RUNTIME requirements).
  206.              
  207.         STACK SPACE is the decimal amount of unused buffer/stack memory 
  208.              which is available for expression evaluation and source file 
  209.              inclusion (see RUNTIME requirements).
  210.              
  211.         ERROR COUNT is a two part decimal number corresponding to the 
  212.              number of statements tagged with fatal/warning messages.  
  213.              The sum of these numbers reflect the total number of 
  214.              statements, not the total number of error messages.
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.                                     PAGE 3
  245.  
  246.  
  247.  
  248.         _ _ _ _ _ _ _ _ S T A T E M E N T     S Y N T A X _ _ _ _ _ _ _ _
  249.  
  250.         The general format of an assembly statement is:
  251.  
  252.              LABEL     OPCODE    OPERAND(s)     COMMENT
  253.              
  254.         UNDERSCORE and COLON characters are ignored, except when used 
  255.              between quotes.  An exaggerated example is _L_D_: and LD 
  256.              being equivalent.
  257.              
  258.         SPACES are used only to identify an item boundary, otherwise they 
  259.              may be used without restriction between any element, 
  260.              including parts of an expression.
  261.              
  262.         TABS (ascii 09h or ^I) are treated as spaces during assembly and 
  263.              expanded to every eighth print position within the listing.
  264.              
  265.         LINE FEED (ascii 0Ah or ^J) and CARRIAGE RETURN (ascii 0Dh or ^M) 
  266.              are always recognized as the end of a source statement and 
  267.              may NOT be embedded within a statement.
  268.              
  269.         FORM FEED (ascii 0Ch or ^L) will assemble when embedded in quotes,
  270.              however, always cause the list driver to perform a page eject.
  271.  
  272.         CONTROL CHARACTERS (ascii 00h through 1Fh) are similiar to spaces 
  273.              in that they mark the boundary of an item, otherwise they may 
  274.              appear at any point within a statement. They are not processed 
  275.              during assembly, but sent to the printer "as is".  Note that 
  276.              this applies to all control characters except tabs (ascii 
  277.              09h or ^I), line feed (ascii 0Ah or ^J) and carriage returns 
  278.              (0Dh or ^M) which are explained above. 
  279.              
  280.         BIT-7 is removed from all characters in the source file before 
  281.              processing.  This eliminates the need to preprocess files 
  282.              that have been edited as a WordStar document.
  283.              
  284.         DECIMAL POINTS, entered as the first character in a statement, 
  285.              are assumed to be WordStar DOT COMMANDS.  The statement is 
  286.              ignored and will not appear on the listing.  
  287.              
  288.         LABELS or SYMBOLS are items, 1 to 31 character long whose first 
  289.              character is a letter (A thru Z) and subsequent characters
  290.              are the letters A thru Z and numbers 0 thru 9.  They used 
  291.              to represent an address or value.  Embedded underscores and 
  292.              colons are ignored and do NOT count toward the 31 character 
  293.              limit.  Upper and lower case may be used interchangeably.  
  294.              SYMBOL  and S_y_m_b_o_l: are the same.  Labels are optional 
  295.              for all statements except MARK an d DATA.  When omited from 
  296.              an EQU statement, the value of the resolved expression wiil
  297.              be printed, but will not be retained.  Labels on a line by 
  298.              themselves are assigned the value of the current assembly 
  299.              address.  NO reserved word (opcode, directive, operand or 
  300.              condition code) may be used as a label.  Labels do not have 
  301.              to begin in the first character position, but must be the 
  302.              first item in a statement.
  303.              
  304.  
  305.                                     PAGE 4
  306.  
  307.  
  308.  
  309.         OPCODES are Z80 instruction mnemonics or assembler directives.  
  310.              (See Z80 instruction syntax for additional details)
  311.  
  312.         OPERANDS are numeric constants, reserved symbols, user defined 
  313.              labels or expressions.  Their use is strictly dependent upon 
  314.              the OPCODE used in the source statement.  ZM recognizes two 
  315.              special symbols in the operand field.
  316.  
  317.              $    The dollar sign is used in an expression to represent 
  318.                   the current assembly address. It may be used alone or 
  319.                   as part of an arithmetic expression.
  320.  
  321.              \    The backslash is used in place of any 8 or 16-bit 
  322.                   immediate operand to "cut" the instruction.  This 
  323.                   allows a formal means of representing and documenting 
  324.                   an advanced assembly language technique where the 
  325.                   immediate operand for one instruction is itself an 
  326.                   instruction.  The practice is often used to create a 
  327.                   one or two byte relative jump by using an 8 or 16 bit 
  328.                   register to load the in-line code, or to flag the entry 
  329.                   of a single routine that must later continue with 
  330.                   separate procedures.
  331.  
  332.                   EXAMPLE:
  333.  
  334.                        ENTRY_1   OR   \         ;OR 0AFh  makes NZ
  335.                        ENTRY_2   XOR  A         ;Makes Z True
  336.                                  PUSH AF        ;Save entry flag
  337.  
  338.                                  (procedure common to both)
  339.  
  340.                                  POP  AF        ;Retrieve entry flag
  341.                                  JP   Z,PROC_2  ;
  342.  
  343.                                  (procedure unique to Entry_1)
  344.                                  RET
  345.  
  346.                        PROC_2    (procedure unique to Entry_2)
  347.                                  RET
  348.  
  349.                   EXAMPLE:
  350.  
  351.                        ERROR_1   LD A,0
  352.                                  LD BC,\   ;Skip-2
  353.                        ERROR_2   LD A,2
  354.                                  LD BC,\   ;Skip-2
  355.                        ERROR_3   LD A,4
  356.  
  357.                                  (Continue with common routine)
  358.              
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.                                     PAGE 5
  367.  
  368.  
  369.  
  370.         NUMERIC CONSTANTS are literal values 1 to 31 characters long 
  371.              whose first character is always a number (0 thru 9).  
  372.              Embedded underscores and colons are ignored and do NOT count 
  373.              toward the 31 character limit.  Both upper and lower case 
  374.              may be used interchangeably.  A suffix is used to indicate 
  375.              the desired base.  Any overflow while evaluating a number is 
  376.              IGNORED, with only the lower 2 bytes being retained.
  377.  
  378.              BINARY CONSTANTS are a sequence of 0's and 1's followed by 
  379.              the letter B.
  380.  
  381.              OCTAL CONSTANTS are a sequence of the digits 0 through 7 
  382.              followed by the letter O or the letter Q.
  383.  
  384.              DECIMAL CONSTANTS are a sequence of the digits 0 through 9 
  385.              with no base designation suffix. ( 0d is NOT decimal zero, 
  386.              but an illegal number! ) 
  387.  
  388.              HEXADECIMAL CONSTANTS are a sequence of the digits 0 through 
  389.              9 and the letters A through F followed by the letter H.
  390.                
  391.         STRING CONSTANTS are a sequence of ANY ascii characters, except 
  392.              line feeds (ascii 0Ah) and carriage returns (ascii 0Dh), 
  393.              enclosed between apostrophes (').  Lower case letters are 
  394.              not converted to uppercase, nor are tab characters (ascii 
  395.              09h) expanded within the assembled code.  Tabs are, however, 
  396.              expanded on the printed listing.  An apostrophe may be 
  397.              included within a string by immediately following it with a 
  398.              second one.  To include an apostrophe at the end of a string 
  399.              requires three in a row (one to indicate end of string).  A 
  400.              string constant containing a carriage return (ascii 0Dh) or 
  401.              line feed (ascii 0Ah) will generate a fatal error for that 
  402.              statement.  String constants may NOT be used in an 
  403.              arithmetic expression.
  404.              
  405.         CHARACTER CONSTANTS are a SINGLE ascii character, except line 
  406.              feed and carriage return, enclosed between apostrophes (').  
  407.              Lower case letters are not converted to upper case.  An 
  408.              apostrophe may also be quoted (''').  Character constants 
  409.              may be used in an arithmetic expression (the assembler 
  410.              assigns a zero value to the most significant byte).
  411.              
  412.         EXPRESSIONS are a sequence of constants and user defined labels 
  413.              separated by arithmetic or logical operators.  During 
  414.              assembly each expression is evaluated in a strict left to 
  415.              right sequence and reduced to a single word (two byte) 
  416.              value.  Any overflow during evaluation is ignored.
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.                                     PAGE 6
  428.  
  429.  
  430.  
  431.         OPERATORS:
  432.  
  433.              [  ] Brackets are used in an expression to control the 
  434.                   strict left to right evaluation process, or to make the 
  435.                   expression easier to read.  Remember that Z80 syntax 
  436.                   uses parentheses "( )" to denote memory addressing and 
  437.                   are therefore not an integral part of an expression.  
  438.                   An expression contained in brackets is treated as a 
  439.                   single item.
  440.  
  441.              +    ADDS the next item to the current value (may also be 
  442.                   used as a unary operator).
  443.  
  444.              -    SUBTRACTS the next item from the current value (may 
  445.                   also be used as a unary operator).  
  446.  
  447.              *    MULTIPLIES the current value by the next item.
  448.  
  449.              &    Logically ANDs the current value with the next item.
  450.  
  451.              #    Logically XORs the current value with the next item.
  452.  
  453.              <    SHIFTS the current value left the amount of the next 
  454.                   item.  High order bits are discarded and low order bits 
  455.                   are replaced with zeros.
  456.  
  457.              >    SHIFTS the current value right the amount of the next 
  458.                   item.  Low order bits are discarded and high order bits 
  459.                   are replaced with zeros.
  460.  
  461.              !    Compares the current value with the next item and keeps 
  462.                   the LARGER of the two.
  463.  
  464.              =    Sets the current value TRUE (-1, all bits set) if the 
  465.                   current item and next item are equal, otherwise sets 
  466.                   the current value equal to zero.
  467.  
  468.              ^    Is a unary operator used to create an ascii control 
  469.                   character.  It must exactly precede (no spaces) the 
  470.                   unquoted character. (e.g. ^Z or ^z give a control Z)
  471.  
  472.              @    Is a unary operator designed to return the integer 
  473.                   value from a memory location at assembly time.  Its use 
  474.                   should be restricted to very special occasions since 
  475.                   the resulting code will function properly only if the 
  476.                   same values exist at runtime.  Its primary use is to 
  477.                   create system specific extensions, or overlays.
  478.  
  479.                   EXAMPLE:   
  480.                              LD  HL,(06)    ; Runtime BDOS entry
  481.                              LD  DE,@6      ; Assembly Time BDOS entry
  482.                              OR  A
  483.                              SBC HL,DE      ; test runtime compatibility
  484.                              JP  NZ,IMPROPER
  485.  
  486.  
  487.  
  488.                                     PAGE 7
  489.  
  490.  
  491.  
  492.  
  493.              ?    Is a kludged operator for use with MARK and IF 
  494.                   directives to provide a primitive library capability 
  495.                   that assembles only required functions.
  496.  
  497.                   MARK symbol = ?
  498.                        will create symbol if it does not exist, otherwise 
  499.                        it does nothing.
  500.  
  501.                   IF? symbol
  502.                        is TRUE only if symbol has been previously 
  503.                        defined.
  504.  
  505.                   EXAMPLE:
  506.                      (main program)  MARK CON_INP = ?, PRINT = ?, ...etc
  507.                                      INCL B:LIBRARY.C13
  508.  
  509.                      (library source) IF? PRINT
  510.                                       PRINT  MARK CON_OUT = ?
  511.                                         (code for print subroutine)
  512.                                       ENDIF       ; PRINT subroutine
  513.  
  514.                                       IF? CON_OUT
  515.                                       CON_OUT
  516.                                         (code for con_out subroutine)
  517.                                       ENDIF       ; CON_OUT subroutine
  518.  
  519.  
  520.         ADDRESSING involves the Z80 registers, memory references and 
  521.              expressions used in the operand field of a assembly source 
  522.              statement and are covered in greater detail in the many 
  523.              books on Z80 assembly language programming.  The main 
  524.              inconsistency amongst these texts is the form used to 
  525.              address 8-bit Z80 arithmetic and logic instructions.  Some 
  526.              use only a single operand, omitting the A-register from 
  527.              the source statement entirely.  Another uses two operands 
  528.              only for those instructions having a 16-bit counterpart and 
  529.              one operand for the remaining instructions.  A third method
  530.              requires two operands for all 8-bit arithmetic and logic 
  531.              instructions.  Since chosing one of these technique depends 
  532.              upon personal preference, ZM will recognize and process both 
  533.              the first and third.  This means you may chose to use two
  534.              operands, or a single operand for all 8-bit arithmetic and 
  535.              logic instructions.  A record is kept on the particular 
  536.              method used, and if not consistent, will generate a single 
  537.              warning message.
  538.              
  539.              NOTE: ZM also recognizes INTEL style port i/o instructions 
  540.                   ( IN nn and OUT nn ) as well as their ZILOG counter 
  541.                   parts ( IN A,(nn) and OUT (nn),A ) and includes their 
  542.                   use when generating the 8-Bit mixed address warning.
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.                                     PAGE 8
  550.  
  551.  
  552.  
  553.         DIRECTIVES are commands to direct the assembler during the 
  554.              assembly process and have no meaning to the Z80 processor.  
  555.  
  556.              EQU  assigns the value of an expression to a label.  If 
  557.                   there is no label, the value will appear on the listing 
  558.                   without error, but the value is not retained. 
  559.  
  560.                   label     EQU       expression
  561.                             EQU       expression
  562.  
  563.              DEFS and DS define storage by reserving the the number of 
  564.                   bytes for storage represented by the expression.  If 
  565.                   the expression is not resolved, ZM will display an 
  566.                   appropriate message and terminate assembly after 
  567.                   completing the first pass.  
  568.  
  569.                             DS        expression
  570.                             DEFS      expression
  571.  
  572.              DEFB and DB assemble an expression a byte at a time.  The 
  573.                   expression may be arithmetic or string.  Supports 
  574.                   multiple expressions seperated by comas.
  575.  
  576.                             DB        expression, expression
  577.                             DEFB      expression, expression
  578.  
  579.              DEFW and DW assemble an expression a word at a time (Z80 
  580.                   fashion with LSB first).  Supports multiple expressions 
  581.                   separated by comas.
  582.                 
  583.                             DW        expression, expression
  584.                             DEFW      expression, expression
  585.  
  586.              DEFM and DM assemble one or more expressions a byte at a 
  587.                   time.  The expressions may be arithmetic or string, or 
  588.                   a combination of both.  The length of the assembled 
  589.                   code is placed at the current assembly address followed 
  590.                   by the code itself.
  591.  
  592.                             DM        expression,expression
  593.                             DEFM      expression,expression
  594.  
  595.              ORG  initializes the assembly address to the value of the 
  596.                   expression.  A label on this line will be assigned 
  597.                   this value.  If the expression is not resolved, ZM 
  598.                   will display an appropriate message and terminate 
  599.                   assembly after completing the first pass.  
  600.  
  601.                             ORG  expression
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.                                     PAGE 9
  611.  
  612.  
  613.  
  614.              RUN accepts the value of an expression as the logical 
  615.                   execution address.  An offset is then determined and 
  616.                   used to define all subsequent labels and in evaluating 
  617.                   the assembly operand "$".  This allows assembling code 
  618.                   that will be moved from the current physical address to 
  619.                   be executed at a different address.  Uses include ROM 
  620.                   resident code and bank switching requirements.  A label 
  621.                   on this line will be assigned the assembly address 
  622.                   before the RUN evaluation.  If the expression is not 
  623.                   resolved, ZM will display an appropriate message and 
  624.                   terminate assembly after completing the first pass.  
  625.  
  626.                             RUN  expression  ;execute at expression
  627.                             RUN  $           ;execute at physical
  628.  
  629.                   EXAMPLE:
  630.                                  ORG 100h
  631.                                  LD HL,LoMem
  632.                                  LD DE,HiMem
  633.                                  LD BC,CodeLength
  634.                                  LDIR
  635.                                  JP HiMem
  636.                        LoMem     RUN 8000h
  637.                        HiMem     ( code to execute
  638.                                   at address 8000h)
  639.                        CodeLength equ $-HiMem
  640.  
  641.              INCL merges another source file with the current one.  The 
  642.                   file name can contain only the letters A to Z and 
  643.                   numbers 0 to 9.  An optional drive identifier may be 
  644.                   given.  If no file type is specified, a null type is 
  645.                   assumed.  Once the end of file or END directive is 
  646.                   reached, assembly will resume with the statement 
  647.                   following the INCL.  The included file may also 
  648.                   contain INCL directives.  ZM will search for the 
  649.                   included file on the designated drive, default drive, 
  650.                   drive A: and internally defined drive.  You will be 
  651.                   allowed to change disks if the file cannot be found.  
  652.                   Do NOT change the disk that is to receive the .COM or 
  653.                   .HEX file as it will cause a CP/M disk write error 
  654.                   when ZM attempts to write the file to disk.  Prompting 
  655.                   continues until the file is found, or a ^C is entered.
  656.  
  657.                             INCL      <drive:><filename><.type>
  658.  
  659.              END  marks the logical end of a source file.  Assembly will 
  660.                   NOT proceed beyond that point.  The END statement is 
  661.                   optional.  If not used, assembly will continue to the 
  662.                   physical end of the file.
  663.  
  664.                             END
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.                                     PAGE 10
  672.  
  673.  
  674.  
  675.              LIST turns the listing ON or OFF only if the "L" option was 
  676.                   requested.  A non-zero expression enables the listing, 
  677.                   and a zero disables the listing.  Statements containing 
  678.                   errors are always listed with their associated messages 
  679.                   regardless of the LIST setting or "L" option.
  680.  
  681.                             LIST      expression
  682.  
  683.              IF, ELSE, and ENDIF provide conditional assembly.  When the 
  684.                   evaluated expression is NOT zero, all statements will 
  685.                   be assembled until the corresponding ELSE or ENDIF is 
  686.                   reached.  The ELSE directive is optional.  IF's may be 
  687.                   nested seven deep.  
  688.  
  689.                   EXAMPLE:
  690.                             IF   expression1
  691.                                  (following statements will assemble
  692.                                  only if the expression1 is NOT zero)
  693.                                IF expression2
  694.                                     (following statements assemble
  695.                                      only if expression1 is NOT zero
  696.                                      AND expression2 is NOT zero)
  697.                                ENDIF
  698.                                     (following statements assemble
  699.                                      only if expression1 is NOT zero)
  700.                             ELSE
  701.                                   (following statements assemble 
  702.                                    only if expression1 is ZERO)
  703.                                IF expression3
  704.                                   (following statements assemble
  705.                                    only if expression1 is ZERO
  706.                                    AND expression3 is NOT zero)
  707.                                ELSE
  708.                                   (following statements assemble
  709.                                    only if expression1 is ZERO
  710.                                    AND expression3 is ZERO)
  711.                                ENDIF
  712.                                   (following statements assemble 
  713.                                    only if expression1 is ZERO)
  714.                             ENDIF
  715.                             (assembly resumes in a normal manner)
  716.  
  717.              MARK sets a label to the current assembly address or to the 
  718.                   value of an expression following an equal sign "=".  
  719.                   If the label has been previously defined and not 
  720.                   marked, an error will occur.  MARK supports multiple 
  721.                   labels seperated by commas.  MARK'd labels may be used 
  722.                   in any desired manner.  They differ from normal labels 
  723.                   in that they may be reused.  The most recently defined 
  724.                   value is used when a marked label appears in an 
  725.                   expression (see ? operator).
  726.  
  727.                             MARK      label1,label2 = expression, ...etc
  728.  
  729.  
  730.  
  731.  
  732.                                     PAGE 11
  733.  
  734.  
  735.  
  736.              DATA exists both as a directive and as a predefined label.  
  737.                   The directive assigns the current value of DATA to a 
  738.                   label, then reassigns DATA = DATA + expression  This 
  739.                   allows defining internal data overlays or data areas 
  740.                   outside the physical program.  Using DATA without a 
  741.                   label will cause a fatal error (missing data).  (See
  742.                   user defined sysbols for additional information).
  743.  
  744.                             label     DATA      expression
  745.  
  746.              MSG  evaluates an expression similar to a DEFB and displays 
  747.                   it on the console.  The expression used must contain 
  748.                   all necessary screen control characters, including
  749.                   carriage return and line feed.  A dollar sign ($) is 
  750.                   the only character that may not appear in the evaluated 
  751.                   text.  No text will appear afterward, and no error will 
  752.                   be generated.
  753.  
  754.              GET  Accepts 1 to 80 characters from the console and 
  755.                   appends them to the end of the current statement. The 
  756.                   statement is then assembled as usual.  Remember to 
  757.                   leave any necessary spaces or puntuation at the end of 
  758.                   the incomplete statement.  Use MSG to provide the 
  759.                   necessary prompting.
  760.  
  761.                             MSG 'ENTER PRINTER SELECTION:', cr, lf, lf
  762.                             MSG '1. Epson mx-80/100', cr, lf
  763.                             MSG '2. Okidata 82a', cr, lf
  764.                             MSG '3. Anderson Jacobson', tab
  765.                             GET  MARK PRINTER = 
  766.  
  767.                             IF Printer =1
  768.                                  (epson code assembles here)
  769.                             ENDIF
  770.                             IF Printer =2
  771.                                  (okidata code assembles here)
  772.                             ENDIF
  773.                             IF Printer =3
  774.                                  (anderson code assembles here)
  775.                             ENDIF
  776.                                  (normal program code continues here)
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.                                     PAGE 12
  794.  
  795.  
  796.  
  797.         PREDEFINED USER SYMBOLS
  798.  
  799.              DATA is a progressive counter used with the DATA directive. 
  800.                   It is NOT altered between passes, therefore it MUST be 
  801.                   initialized with the MARK directive before it is used.
  802.  
  803.                   EXAMPLE:
  804.                             ORG       100H
  805.                             MARK      DATA, LOOP
  806.                             CALL      INITIALIZE
  807.                             DB  'Initial Program signon message$'
  808.                             DB  'Additional text for "TYPE .COM"', 1AH
  809.                   FCB2      DATA      33
  810.                   COUNT     DATA       2
  811.                             ORG  DATA ! $
  812.                 
  813.                   FCB2 overlays the beginning of the program at 100h and 
  814.                   COUNT is assigned 121h.  The assembly address is then 
  815.                   adjusted to the larger value of "$" or "DATA".
  816.  
  817.              IX and IY are used to evaluate memory references using 
  818.                   their respective index registers. They must always be 
  819.                   defined using a negative value.
  820.  
  821.                   EXAMPLE:
  822.  
  823.                           FLAGS     DEFB   0    ;One byte flag variable
  824.                           IX        EQU   -$    ;<--<< IX BASE ADDRESS <--<<
  825.                           TEMP      DEFW   0
  826.  
  827.                   IX has been defined as the current assembly address. 
  828.                   SET 0,(IX+FLAGS) will assemble correctly and is the
  829.                   same as SET 0,(IX+FLAGS-BASEX) used with the following:
  830.  
  831.                   EXAMPLE:
  832.  
  833.                        FLAGS     DEFB  0    ;One byte flag variable
  834.                        BASEX     EQU   $    ;<--<< IX BASE ADDRESS <--<<
  835.                        TEMP      DEFW  0
  836.  
  837.                   NOTE: Loading the index register must use the 
  838.                   negative of these symbols. 
  839.  
  840.                         LD IX,-IX       ;Initialize IX base position
  841.  
  842.              NOTE:  Since the predefined symbols IX and IY are initially 
  843.              zero, NOT using them will cause assembly to take place in 
  844.              the usual manner.  If you do use them, remember they are 
  845.              redefinable and affect only those expressions FORWARD of 
  846.              themselves.  Also realize that the beginning of the file is 
  847.              AFTER its END during the second pass.  If you plan on using 
  848.              ANY redefinable symbol, but expect them to be zero at the 
  849.              beginning, MARK THEM BEFORE YOU SET THE ORIGIN or EQUATE 
  850.              THEM TO ZERO !
  851.  
  852.  
  853.  
  854.                                     PAGE 13
  855.  
  856.  
  857.  
  858.  
  859.         _ _ _ _ _ _ _ _ _ _ _ _ _ E R R O R S _ _ _ _ _ _ _ _ _ _ _ _ _
  860.  
  861.         There are three types of errors:  Terminal, Fatal and Warning:
  862.  
  863.              TERMINAL errors terminate the program!  All Terminal errors 
  864.              are displayed on the console and control is immediately 
  865.              returned to CP/M.  
  866.  
  867.              Fatal errors result in the offending source statement not 
  868.              being processed. NO CODE IS GENERATED!
  869.  
  870.              WARNINGS are provided when the integrity of the assembled 
  871.              code is questionable.  In other words, what you got, might 
  872.              not be what you wanted!
  873.  
  874.              Warning and Fatal error messages are always displayed with 
  875.         the offending source statement, even if the "L" option was not 
  876.         selected.  The format includes the current file name if it has 
  877.         not yet been displayed.  The offending statement is then printed, 
  878.         followed by a line of carats (^) to indicate those points that 
  879.         caused ZM to choke.  The appropriate warning and fatal error 
  880.         messages are then lsited. Finally, the current statement number, 
  881.         which matches WordStar's FL number, or ED.COM's line number, is 
  882.         printed.  Any relationship between the carats and the ordering of 
  883.         error messages is purely coincidental. 
  884.  
  885.         EXAMPLE:
  886.  
  887.              SOURCE FILE: JUNK.PDQ
  888.  
  889.                              db tab,'LINE OF TEXT',0D,0Ah,
  890.                                   ^                 ^    ^
  891.              -- WARNING --   17: BAD NUMBER
  892.                              15: UNDEFINED LABEL
  893.              *** FATAL ***    1: MISSING INFORMATION
  894.              - Line No 1263 -
  895.  
  896.         _______________________________________________________________
  897.         TERMINAL ERRORS:  Assembly stops and control is returned to CP/M.
  898.  
  899.              USE: ZM <file> <option>
  900.  
  901.                   WHERE <option> is one or more of the following:
  902.  
  903.                        L  = Listing
  904.                        H  = Hex object file
  905.                        C  = Com object file
  906.                        1  = 10 lpi x 10 cpi
  907.                        2  =  8 lpi x 17 cpi
  908.  
  909.         Cause:    No file was provided, or an unrecognized option was 
  910.                   given.
  911.         Solution: Examine and reenter the command line. Remember the the 
  912.                   "=" must be the last option.
  913.  
  914.  
  915.                                     PAGE 14
  916.  
  917.  
  918.  
  919.  
  920.  
  921.         ** CANNOT HAVE BOTH ".HEX" & ".COM" OUTPUTS **
  922.         Cause:    Both the H and C options were requested.
  923.         Solution: Reenter the command line with an H option, then use 
  924.                   CP/M's LOAD.COM utility to provide the .COM file.
  925.  
  926.  
  927.         ** CANNOT CREATE/OPEN OBJECT FILE **
  928.         Cause:    This will most likely result from a FULL Directory.
  929.         Solution: Erase a few files to make room.
  930.  
  931.  
  932.         ** DISK or DIRECTORY FULL **
  933.         Cause:    The system reported it could NOT write the object file.
  934.         Solution: Erase a few file to make room.
  935.  
  936.  
  937.         ** SYMBOL TABLE OVERFLOW **
  938.         Cause:    Symbol and GET storage have collided!
  939.         Solution: Shorten  Symbol  names,  use more  MARK'd  symbols,  or 
  940.                   separate the source file into two or more smaller  ones 
  941.                   and assemble them separately.
  942.         NOTE:     See RUNTIME requirements for additional information.
  943.  
  944.  
  945.         ** STACK OVERFLOW **
  946.         Cause:    The hardware stack and source statements have collided.
  947.         Solution: Reduce the INCL nest level, simplify complex 
  948.                   expressions, use shorter source statements.
  949.         NOTE:     See RUNTIME requirements for additional information.
  950.  
  951.  
  952.         ** CANNOT CLOSE OBJECT FILE **
  953.         Cause:    Something prevented CP/M from closing the output file.
  954.         Solution: Read the CP/M manual for causes and solutions.
  955.  
  956.  
  957.         **   INVALID  OBJECT (.COM) FILE ABANDONED   **
  958.         Cause:    The initial ORG was not 100h, or was less than the 
  959.                   current assembly address. 
  960.         Solution: Reorganize or Rewrite the assembly source file.  
  961.         NOTE:     This error is not terminal.  Assembly will continue, 
  962.                   providing a listing and/or additional error messages.
  963.  
  964.  
  965.         ** NESTING TOO DEEP **
  966.         Cause:    The current statement brings the IF/ELSE/ENDIF to more 
  967.                   than 7-levels. 
  968.         Solution: Rewrite the file using fewer IF/ELSE/ENDIF levels.
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.                                     PAGE 15
  977.  
  978.  
  979.  
  980.         ________________________________________________________________
  981.         FATAL ERRORS:  No code is generated for the statement containing 
  982.              the error.  Assembly continues with the next statement. 
  983.  
  984.  
  985.         0: BAD/UNRESOLVED EXPRESSION
  986.         Cause:    An INCL statement contained a bad filename, or an ORG 
  987.                   RUN, or DS/DEFS statement contained an unresolved 
  988.                   expression
  989.         NOTE:     Assembly will terminate at the end of the first pass.
  990.  
  991.  
  992.         1: MISSING INFORMATION
  993.         Cause:    The expression was missing an operand, a comma, or a 
  994.                   parenthesis;  or a statement ended with a comma.
  995.  
  996.  
  997.         2: ILLEGAL ADDRESSING
  998.         Cause:    The operand(s) violate Z80 addressing options for the 
  999.                   opcode used.
  1000.  
  1001.  
  1002.         4: ILLEGAL OPCODE
  1003.         Cause:    The item being processed was not a recognized opcode or 
  1004.                   assembler directive. (This relates to the second item, 
  1005.                   the first was processed as a symbol).  This usually 
  1006.                   occurs when a reserved symbol (opcode, register, 
  1007.                   condition code or directive) was used as a label, or an 
  1008.                   opcode or directive was misspelled.
  1009.  
  1010.  
  1011.         5: EXPRESSION TOO LONG
  1012.         Cause:    A statement generated more than 82 bytes of code.
  1013.  
  1014.  
  1015.         6: ITEM TOO LONG
  1016.         Cause:    A single item (symbol or number) exceeded 31 
  1017.                   characters.
  1018.  
  1019.  
  1020.         7: EXPRESSION ERROR
  1021.         Cause:    An expression had two successive operators, two 
  1022.                   successive items, a missing operator, a missing item, 
  1023.                   a missing right parentheses, included extraneous 
  1024.                   characters, or contained unbalanced braces.
  1025.                   
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.                                     PAGE 16
  1038.  
  1039.  
  1040.  
  1041.         _______________________________________________________________
  1042.         WARNINGS: The assembled code may NOT be what was intended.
  1043.  
  1044.  
  1045.          8: MIXED 8-Bit ADDRESSING MODES
  1046.         Cause:    The source file contains a mixture of one and two 
  1047.                   operand address for 8-bit arithmetic or logic 
  1048.                   instructions.
  1049.         Result:   Since ZM handles both methods, the code was properly 
  1050.                   assembled.  However, had the intention been to use 
  1051.                   only one of the two addressing methods, then one or 
  1052.                   more statements are not what was intended.
  1053.  
  1054.  
  1055.         10: ORIGIN NOT IN SEQUENCE
  1056.         Cause:    The expression for an ORG resolved to an address 
  1057.                   smaller than the current assembly address.
  1058.         Result:   Any .COM file is abandoned, but assembly resumes.
  1059.  
  1060.  
  1061.         11: BRANCH (origin - target) OUT OF RANGE
  1062.         Cause:    The target for a relative jump (JR or DJNZ) was not in 
  1063.                   the range -128 to +127
  1064.         Result:   The target for the jump becomes the instruction itself.
  1065.  
  1066.  
  1067.         12: ILLEGAL LABEL
  1068.         Cause:    The symbol being defined is a reserved operand. (See #4)
  1069.         Result:   The symbol is ignored.
  1070.  
  1071.  
  1072.         13: LABEL NOT MARKED
  1073.         Cause:    The symbol has been defined more than once.
  1074.         Result:   The first assigned value is used.
  1075.         Hint:     Use the MARK directive to define symbols you wish to 
  1076.                   use more than once. 
  1077.  
  1078.  
  1079.         14: UNPROCESSED CHARACTERS
  1080.         Cause:    After the statement was assembled the end of the line 
  1081.                   had not been reached.
  1082.         Result:   The assembled code may/may not be appropriate.
  1083.  
  1084.  
  1085.         15: UNDEFINED LABEL
  1086.         Cause:    An expression contains a symbol that has not been 
  1087.                   defined.
  1088.         Result:   The symbol defaults to a value of zero.
  1089.  
  1090.  
  1091.         16: MULTIPLY DEFINED
  1092.         Cause:    An expression contains a symbol that was defined more 
  1093.                   than once.
  1094.         Result:   The original symbol's value is used.
  1095.  
  1096.  
  1097.  
  1098.                                     PAGE 17
  1099.  
  1100.  
  1101.  
  1102.         17: BAD NUMBER
  1103.         Cause:    A item beginning with 0 thru 9 contained a character 
  1104.                   not appropriate for the assigned base.
  1105.         Result:   The number defaults to a value of zero.
  1106.  
  1107.  
  1108.         20: UNBALANCED IF/ENDIF
  1109.         Cause:    An END directive, or the end of a file was reached 
  1110.                   without enough ENDIF's to complete all IF directives.
  1111.         Result:   If the unbalance occurred while processing an included 
  1112.                   file, the previous file's IF/ENDIF stack was restored.  
  1113.                   Assembly will terminate at the end of the first pass.
  1114.  
  1115.  
  1116.         22: NO ASSOCIATED "IF" STATEMENT
  1117.         Cause:    An ENDIF statement was processed without first having 
  1118.                   processed an "IF" statement.
  1119.         Result:   The statement was ignored.  Assembly will terminate at 
  1120.                   the end of the first pass.
  1121.  
  1122.  
  1123.         23: STATEMENT TRUNCATED
  1124.         Cause:    A source statement was longer than 215 characters.
  1125.         Result:   The excess was discarded.  May cause additional errors 
  1126.                   if the discarded portion was not a comment.
  1127.  
  1128.         24: INVERTED ORIGIN
  1129.         Cause:    Source file contained no ORG statement or an ORG 
  1130.                   has an expression that is less than 100H
  1131.         Result:   A .COM file will be abandoned, but assembly continues.
  1132.  
  1133.  
  1134.         25: LABEL ADDRESS CHANGES
  1135.         Cause:    The Label had a different address on the second pass 
  1136.                   than it had on the first pass.
  1137.         Result:   Very dubious code!
  1138.         Hint:     Look for a previous statement that adjusts the assembly 
  1139.                   address using a MARK'd symbol that is later redefined, 
  1140.                   or a previous IF/ENDIF that generated code on one pass, 
  1141.                   but was FALSE on the other pass. 
  1142.  
  1143.  
  1144.         26: FIELD OVERFLOW
  1145.         Cause:    The evaluated expression exceeded the size limits for 
  1146.                   the opcode. (Example. IM n where 'n' is not 0, 1 or 2).
  1147.         Result:   A "mask" is used to force a legal value. 
  1148.  
  1149.  
  1150.         27: BYTE VALUE OVERFLOW
  1151.         Cause:    All expressions are reduced to an unsigned 16-bit 
  1152.                   integer.  The least significant byte is used for 
  1153.                   instructions requiring an 8-bit value, however, the 
  1154.                   original value was neither 0 to 255 nor -128 to +127 
  1155.         Result:   The least significant byte was used, "as is".
  1156.  
  1157.  
  1158.  
  1159.  
  1160.                                     PAGE 18
  1161.  
  1162.  
  1163.  
  1164.         ------------------------------------------------------------
  1165.                      R U N T I M E   R E Q U I R E M E N T S 
  1166.  
  1167.         PROGRAM MEMORY MAP
  1168.  
  1169.         100h ______________________________________________________ BDOS
  1170.         |        |           |         |         < ? >            |
  1171.         | fixed  | src   stk | program | get    wrk  obj   symbol |
  1172.         Pass1 => | 216   100 |         | >>-->  31   xxx   <---<< |
  1173.         Pass2 => | 216   100 |         | ?????  31   128   ?????? | 
  1174.  
  1175.              A substantial portion of the program (initialization 
  1176.         section) is reclaimed and used for runtime data storage.  All 
  1177.         memory beyond ZM's original size, is used for symbol table and 
  1178.         output file buffer.
  1179.  
  1180.              A fixed 216 byte buffer is allocated for the source 
  1181.         statement. No statement may exceed 215 characters.
  1182.  
  1183.              A 100 byte (50 level) stack is provided. The stack, however, 
  1184.         is not rigid.  It is allowed to wander into the unused portion of 
  1185.         the source statement buffer, but is NOT allowed to overwrite a 
  1186.         statement.  Should the program attempt to overwrite a statement, 
  1187.         ** STACK OVERFLOW ** occurs and control is imediately returuned 
  1188.         to CP/M. Minimum runtime requirement is approximately 15 levels.  
  1189.         Each recurssive INCL consumes 22 bytes.  Evaluation recursion 
  1190.         (brackets) consumes 6 bytes.  A typical source file containing 80 
  1191.         character lines can contain 8-Levels of INCL nesting and 5-Levels 
  1192.         of brackets.  STACK SPACE reported at the end of assembly is the 
  1193.         minimum distance reached between any source statement and the 
  1194.         stack.  In other words, a stack crash barometer!
  1195.  
  1196.              GET responses begin at the end of the program and expand 
  1197.         toward high memory and are stored as entered, with a byte count 
  1198.         preceding each entry.
  1199.  
  1200.              Symbols are stored just below BDOS and expand toward low 
  1201.         memory.  Each symbol requires three bytes in addition to the 
  1202.         actual symbol length.  
  1203.  
  1204.              A 31 byte work space continually relocates at the end of the 
  1205.         GET storage area during pass1.  During pass2, all tables are 
  1206.         fixed and this work space becomes stationary.
  1207.  
  1208.              All remaining space between the end of the 31 byte work 
  1209.         space and the bottom of the symbol table is used to buffer the 
  1210.         object file output.  More space means less disk access, providing 
  1211.         faster assembly.  If at any time this space should become less 
  1212.         than 128 bytes (one file sector) ** TABLE OVERFLOW ** occurs and 
  1213.         assembly ceases.  FREE MEMORY displayed at the end of assembly is 
  1214.         the amount of memory available to expand the object file buffer 
  1215.         beyond a single 128 byte sector.  When less than 128, the object 
  1216.         file buffering is limited to this one sector.  Assembly may be 
  1217.         slow, but still running.  Less than zero, and it's dead.
  1218.  
  1219.  
  1220.  
  1221.                                     PAGE 19
  1222.  
  1223.  
  1224.  
  1225.         ____________________________________________________________
  1226.                         R E S E R V E D     S Y M B O L S
  1227.  
  1228.         ________________________Z80 Opcodes_________________________
  1229.         EXX     LDI     LDIR    LDD     LDDR    CPI     CPIR    CPD
  1230.         CPDR    DAA     CPL     NEG     CCF     SCF     NOP     HALT
  1231.         DI      EI      IM      RLCA    RLA     RRCA    RRA     RETI
  1232.         RETN    INI     INIR    IND     INDR    OUTI    OTIR    OUTD
  1233.         OTDR    LD      RLC     RL      RRC     RR      SLA     SRA
  1234.         SRL     RLD     RRD     PUSH    POP     EX      ADD     ADC
  1235.         SBC     SUB     AND     OR      XOR     CP      INC     DEC
  1236.         BIT     SET     RES     JP      CALL    JR      DJNZ    RET
  1237.         RST     IN      OUT
  1238.  
  1239.  
  1240.  
  1241.         __________________Assembler Directives______________________
  1242.         DS      DEFS    DB      DEFB    DW      DEFW    DM      DEFM
  1243.         ORG     RUN     END     INCL    MARK    EQU     DATA    LIST
  1244.         IF      ELSE    ENDIF   MSG     GET
  1245.  
  1246.  
  1247.  
  1248.  
  1249.         _________________________Operands________________________
  1250.         Z       NZ      C       NC      PO      PE      P       M
  1251.         A       B       C       D       E       H       L
  1252.         BC      DE      HL      IX      IY      SP      AF
  1253.         I       R       $       \       ?
  1254.  
  1255.  
  1256.  
  1257.         _______________Predefined User Symbols_______________________
  1258.         DATA    IX      IY
  1259.  
  1260.  
  1261.  
  1262.         _____________________Operators___________________________________
  1263.         +       -       *       &       #       <       >       !
  1264.         ?       @       =       [       ]       ^
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.                                     PAGE 20
  1283.  
  1284.  
  1285.  
  1286.         _________________________________________________________________
  1287.         _______________________ Z80 SYNTAX SUMMARY ______________________
  1288.  
  1289.         _ _ _ _ _ _ _ _ _ _ D A T A     T R A N S F E R _ _ _ _ _ _ _ _ _
  1290.         8 Bit Transfers         16 bit transfers        Block Transfers
  1291.  
  1292.         LD r,r'                 LD ss,nnnn              LDI
  1293.         LD r,nn                 LD ss,(nnnn)            LDIR
  1294.                                 LD (nnnn),ss
  1295.         LD r,(m)                                        LDD
  1296.         LD (m),r                LD SP,HL                LDDR
  1297.         LD (m),nn               LD SP,IX
  1298.                                 LD SP,IY
  1299.         LD A,(BC)
  1300.         LD A,(DE)               PUSH qq
  1301.         LD A,(nnnn)             POP  qq
  1302.         LD (nnnn),A
  1303.         LD (DE),A               EX DE,HL        NOTE: ZM is NOT sensitive
  1304.         LD (BC),A               EX (SP),HL            to the sequence of
  1305.                                 EX (SP),IX            exchange operands.
  1306.         LD A,I                  EX (SP),IY                 EX HL,DE
  1307.         LD I,A                  EX AF,AF'               is equivilent to
  1308.         LD A,R                  EXX                        EX DE,HL
  1309.         LD R,A
  1310.         _ _ _ _ _ _ _ _ _ _ _ _ A R I T H M E T I C _ _ _ _ _ _ _ _ _ _ _ 
  1311.         8 Bit Arithmetic        16 Bit Arithmetic       Misc
  1312.  
  1313.         ADD r     ADD A,r       ADD HL,ss               DAA
  1314.         ADD (m)   ADD A,(m)     ADD IX,xx               CPL
  1315.         ADD nn    ADD A,nn      ADD IY,yy               NEG
  1316.                                                         SCF
  1317.         ADC r     ADC A,r       ADC HL,ss               CCF
  1318.         ADC (m)   ADC A,(m)
  1319.         ADC nn    ADC A,nn
  1320.  
  1321.         SUB r     SUB A,r
  1322.         SUB (m)   SUB A,(m)
  1323.         SUB nn    SUB A,nn
  1324.  
  1325.         SBC r     SBC A,r       SBC HL,ss
  1326.         SBC (m)   SBC A,(m)
  1327.         SBC nn    SBC A,nn
  1328.  
  1329.         INC r                   INC pp
  1330.         INC (m)
  1331.  
  1332.         DEC r                   DEC pp
  1333.         DEC (m)
  1334.  
  1335.         r    = A, B, C, D, E, H, d          ss = BC, DE, HL, IX, IY or SP 
  1336.         nn   = any 8-Bit expression         qq = AF, BC, DE, HL, IX or IY 
  1337.         nnnn = any 16-Bit expression        xx = BC, DE, SP, IX           
  1338.         (m)  = (HL), (IX+d) or (IY+d)       yy = BC, DE, SP, IY           
  1339.         d    = displacement (-128 to +127)
  1340.  
  1341.  
  1342.  
  1343.                                     PAGE 21
  1344.  
  1345.  
  1346.  
  1347.         _________________________________________________________________
  1348.         _ _ _ _ _ _ _ _ _ _ _ _ L O G I C _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1349.         8-Bit Logic                             Block Operations
  1350.  
  1351.         AND r     AND A,r                       CPI
  1352.         AND (m)   AND A,(m)                     CPIR
  1353.         AND nn    AND nn
  1354.  
  1355.         OR  r     OR  A,r                       CPD
  1356.         OR  (m)   OR  A,(m)                     CPDR
  1357.         OR  nn    OR  A,nn
  1358.  
  1359.         XOR r     XOR A,r
  1360.         XOR (m)   XOR A,(m)
  1361.         XOR nn    XOR A,nn
  1362.  
  1363.         CP  r     CP  A,r
  1364.         CP (m)    CP  A,(m)
  1365.         CP  nn    CP  A,nn
  1366.  
  1367.         _ _ _ _ _ _ _ SHIFT, ROTATE and BIT INSTRUCTIONS _ _ _ _ _ _ _ _
  1368.  
  1369.         RLCA            RLC r           RLC (m)         BIT n,r
  1370.         RLA             RL  r           RL  (m)         BIT n,(m)
  1371.         RRCA            RRC r           RRC (m)
  1372.         RRA             RR  r           RR  (m)         SET n,r
  1373.                         SLA r           SLA (m)         SET n,(m)
  1374.                         SRA r           SRA (m)
  1375.         RLD             SRL r           SRL (m)         RES n,r
  1376.         RRD                                             RES n,(m)
  1377.  
  1378.         _ _ _ _ _ _ _ _ I/O     I N S T R U C T I O N S _ _ _ _ _ _ _ _
  1379.  
  1380.         IN nn           OUT nn          INI             OUTI
  1381.         IN A,(nn)       OUT (nn),A      INIR            OTIR
  1382.         IN r,(C)        OUT (C),A       IND             OUTD
  1383.                                         INDR            OTDR
  1384.  
  1385.         _ _ _ _ _ _ _ _ _ G E N E R A L     P U R P O S E _ _ _ _ _ _ _ _
  1386.  
  1387.         DAA             CCF             NOP             DI
  1388.         CPL             SCF             HALT            EI
  1389.         NEG             IM 0            IM 1            IM 2
  1390.  
  1391.         _ _ _ _ _ _ _ _ _ _ _ _ C O N T R O L _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1392.  
  1393.         JR e            JP nnnn         JP (HL)         CALL nnnn
  1394.         JR c,e          JP cc,nnnn      JP (IX)         CALL cc,nnnn
  1395.         DJNZ e                          JP (IY)
  1396.  
  1397.         r    = A, B, C, D, E, H, d      c  = NC, C, NZ, Z 
  1398.         nn   = any 8-Bit expression     e  = Relative Addree (-128 to +127)
  1399.         nnnn = any 16-Bit expression    cc = NC, C, NZ, Z, M, P, PO, PE 
  1400.         (m)  = (HL), (IX+d) or (IY+d)           
  1401.         d    = displacement (-128 to +127)
  1402.  
  1403.  
  1404.                                     PAGE 22
  1405.  
  1406.  
  1407.  
  1408.  
  1409.                               A L T E R A T I O N S 
  1410.  
  1411.              ZM does not require special installation to run on a CP/M
  1412.         system.  It may, however, be modified to take advantage of 
  1413.         special system features.  The method is to create the necessary 
  1414.         source file, then use DDT to overlay ZM with the assembled .HEX 
  1415.         file.  This may seem a little too much to install an assembler, 
  1416.         but the rewards are that ZM will not only setup and restore your 
  1417.         printer, but automatically search for files on a drive of your 
  1418.         choice, and date program listings.
  1419.  
  1420.              Using the following source listing as a guide, create a 
  1421.         source file containing the assembly instructions necessary to 
  1422.         alter ZM to meet your printer requirements.  Then use ZM to 
  1423.         assemble the file into an Intel hex format and  DDT to overlay 
  1424.         ZM.  The following dialog assumes the source is B:ZM/SETUP.Z80 
  1425.         and that a copies of ZM and DDT reside on drive A:
  1426.  
  1427.  
  1428.                             A>B:
  1429.                             B>A:ZM3P  ZM-SETUP.Z80  H
  1430.                             ZM v 1.3p - Z80 Assembler (c) 1984
  1431.  
  1432.                             NEXT ADDRESS xxxx
  1433.                             NEXT DATA    xxxx
  1434.                             FREE MEMORY  xxxx
  1435.                             STACK SPACE  xxxx
  1436.                             ERROR COUNT  None/None
  1437.  
  1438.                             B>A:DDT A:ZM3P.COM
  1439.                             DDT VERS 2.2
  1440.                             NEXT  PC
  1441.                             xxxx  0100
  1442.                             -IZM-SETUP.HEX
  1443.                             -R
  1444.                             NEXT  PC
  1445.                             xxxx  0000
  1446.                             -G0
  1447.  
  1448.                             B>SAVE xx B:ZM.COM
  1449.                             B>
  1450.                        
  1451.         et viola, ZM has been configured for your printer.
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.                                     PAGE 23
  1466.  
  1467.  
  1468.  
  1469.              The INCL directive is programmed to search the specified 
  1470.         drive (if given), the default drive, an internally defined drive, 
  1471.         and finally drive A:.  This four step search is repeated until 
  1472.         the file is found or a ^C is entered.  The internal drive may be 
  1473.         defined by adjusting the value at 061Ch.  Any CP/M drive may be 
  1474.         specified using the convention that 0=default, 1=A, 2=B, etc.
  1475.  
  1476.              ZM contains three printer setup strings.  The first two are 
  1477.         concerned with printer initialization and listing format, and the 
  1478.         third is used to restore the printer to its normal configuration.  
  1479.         The number of lines per page is given as the first byte in the 
  1480.         initialization strings followed by the number of characters in 
  1481.         the string that follows.  The first byte of the third string 
  1482.         contains the number of characters that follow.
  1483.  
  1484.              There are two 32 character lines in 'USAGE MESSAGE' which 
  1485.         should reflect the respective performance of the first two 
  1486.         printer initialization strings.
  1487.  
  1488.              During initialization, ZM loads the 'DE' register pair to 
  1489.         point to the date field in the header and calls 1D21h.  The 
  1490.         called routine is expected to fill the 8-character field pointed 
  1491.         to by the 'DE' register pair with the current date.  The routine 
  1492.         may alter all registers (except IX) and can extend almost to the 
  1493.         BDOS.  IT MUST NOT ALTER MEMORY BELOW ITS ORIGIN!  Look at the 
  1494.         stack pointer (SP) if you are really concerned about the actual 
  1495.         limit.  Once the date has been obtained, the space occupied by 
  1496.         the routine is reclaimed for runtime storage.  If your system 
  1497.         cannot provide the current date, or you do not wish to have dated 
  1498.         listings, simply use a RET as the first instruction of the date
  1499.         routine.
  1500.  
  1501.              The following listing provides an example for creating an 
  1502.         overlay to configure ZM for your particular requirements.  The 
  1503.         statements "ORG TIC + 18" and "ORG TIC + 17" are used to not
  1504.         only to adjust the current assebbly address, but to generate 
  1505.         a warning (e.g. 10: ORIGIN NOT IN SEQUENCE) in the event the 
  1506.         predefined size constraints are exceeded.
  1507.  
  1508.         ;ZM (Version 1.3p) Custom Setup for MX-100 printer
  1509.  
  1510.         MARK TIC
  1511.  
  1512.         Message1        equ 0300h       ;Option 1 Usage Message
  1513.         Message2        equ 0324h       ;Option 2 Usage Message
  1514.         Drive           equ 0548h       ;Drive & Print Parameters
  1515.         Date            equ 1D20h       ;Date Initialization Routine
  1516.  
  1517.         ORG Message_1
  1518.             ;  !12345678901234567890123456789012! <--32 byte ruler
  1519.             DB '2 = 57 Lines (10 cpi at 6 lpi)  '
  1520.  
  1521.         ORG Message_2
  1522.             ;  !12345678901234567890123456789012! <--32 byte ruler
  1523.             DB '1 = 80 Lines (16.5 cpi at 8 lpi)'
  1524.  
  1525.  
  1526.                                     PAGE 24
  1527.         ORG Drive
  1528.             DB 2      ;Add Drive B: to the search path
  1529.  
  1530.         TIC DB 57                    ;57 lines per page
  1531.             DM ^[, ^F, ^R, ^[, 2     ;Emphasized OFF, condensed OFF, 6 lpi
  1532.             ORG tic + 18              ; <--<< ERROR IF SPACE EXCEEDED
  1533.  
  1534.         TIC DB 80                    ;80 lines per page
  1535.             DM ^[, 'F', ^O, ^[, 0    ;Emphasized OFF, condensed ON, 8 lpi
  1536.             ORG tic + 18              ; <--<< ERROR IF SPACE EXCEEDED
  1537.                 
  1538.         TIC DM ^R, ^[, 'N', 6        ;Condensed OFF, Skip 6 at perf
  1539.             ORG tic + 17              ; <--<< ERROR IF SPACE EXCEEDED
  1540.  
  1541.         ORG DATE  ; PROMPT OPERATOR FOR DATE
  1542.  
  1543.              PUSH IX             ;Preserve IX
  1544.              PUSH DE             ; and date field pointer
  1545.  
  1546.              LD DE,DatePrompt    ;Prompt operator for date
  1547.              LD  C,9
  1548.              CALL  5
  1549.  
  1550.              LD DE,Buffer        ;Accept date from console
  1551.              LD  C,10    
  1552.              CALL  5
  1553.  
  1554.              LD E,^j             ;Punch line feed
  1555.              LD C,2
  1556.              CALL 5
  1557.  
  1558.              POP  DE             ;Restore registers now that
  1559.              POP  IX             ;  we're done with system calls
  1560.  
  1561.              LD HL,BUFFER+1      ;Point to console input
  1562.              LD  A,(HL)          ;  get length
  1563.              OR  A
  1564.              RET Z               ;Exit on null input
  1565.              
  1566.              DEC A               ;Force length to range (1 to 8)
  1567.              AND 7
  1568.              INC A
  1569.              
  1570.              LD  C,A             ;Move string to header date field
  1571.              LD  B,0
  1572.              INC HL
  1573.              LDIR
  1574.              RET
  1575.  
  1576.         DatePrompt     db ^m,^j,^j,'ENTER LISTING DATE as (yy/mm/dd): $'
  1577.         Buffer         db 40
  1578.  
  1579.              END
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.                                     PAGE 26
  1588.  
  1589.  
  1590.  
  1591.  
  1592.                                     I N D E X
  1593.  
  1594.              ! .............................................  7
  1595.              # .............................................  7
  1596.              $ .............................................  4, 9,11
  1597.              & .............................................  7
  1598.              ( ) ...........................................  7
  1599.              * .............................................  7
  1600.              + .............................................  7
  1601.              - .............................................  7
  1602.              < .............................................  7
  1603.              = .............................................  7
  1604.              > .............................................  7
  1605.              ? .............................................  8
  1606.              @ .............................................  7
  1607.              ABORT .........................................  1
  1608.              ADDRESSING ....................................  8
  1609.              ALTERATION .................................... 23
  1610.              BINARY CONSTANTS ..............................  6
  1611.              BIT-7 .........................................  4
  1612.              CARRIAGE RETURNS ..............................  4
  1613.              CHARACTER CONSTANTS ...........................  6
  1614.              COLON .........................................  4, 6
  1615.              CONTROL CHARACTERS ............................  2, 4, 7, 12
  1616.              DATA ..........................................  12,13
  1617.              DB ............................................  9
  1618.              DECIMAL CONSTANTS .............................  6
  1619.              DECIMAL POINTS ................................  4
  1620.              DEFB ..........................................  9
  1621.              DEFM ..........................................  9
  1622.              DEFS ..........................................  9
  1623.              DEFW ..........................................  9
  1624.              DIRECTIVES ....................................  9,20
  1625.              DM ............................................  9
  1626.              DS ............................................  9
  1627.              DW ............................................  9
  1628.              ELSE .......................................... 11
  1629.              END ........................................... 10
  1630.              ENDIF ......................................... 11
  1631.              EQU ...........................................  9
  1632.              ERROR COUNT ...................................  3
  1633.              ERRORS ........................................ 14
  1634.              EXPRESSIONS ...................................  6
  1635.              FATAL ERRORS .................................. 15,16
  1636.              FREE MEMORY ...................................  3,19
  1637.              GET ........................................... 12,19
  1638.              HEADING .......................................  2
  1639.              HEXADECIMAL CONSTANTS .........................  6
  1640.              IF ............................................  8
  1641.              INCL .......................................... 10,19
  1642.              IX ............................................ 13
  1643.              IY ............................................ 13
  1644.              LABELS ........................................  4
  1645.              LINE FEED .....................................  4
  1646.  
  1647.  
  1648.                                     PAGE 27
  1649.  
  1650.  
  1651.  
  1652.              LIST .......................................... 11
  1653.              LISTING .......................................  2, 3
  1654.              MARK .......................................... 11
  1655.              MSG ........................................... 12
  1656.              NEXT ADDRESS ..................................  3
  1657.              NEXT DATA .....................................  3
  1658.              NUMERIC CONSTANTS .............................  6
  1659.              OCTAL CONTSTANTS ..............................  6
  1660.              OPCODES .......................................  5,20
  1661.              OPERANDS ......................................  5,20
  1662.              OPERATORS .....................................  7,20
  1663.              OPTIONS .......................................  2
  1664.              ORG ...........................................  9
  1665.              PREDEFINED USER SYMBOLS ....................... 13,20
  1666.              PROGRAM MEMORY MAP ............................ 16
  1667.              RESERVED SYMBOLS .............................. 20
  1668.              RUNTIME REQUIREMENTS .......................... 19
  1669.              RUN ........................................... 10
  1670.              SPACES ........................................  4
  1671.              STACK SPACE ...................................  3,19
  1672.              STRING CONSTANTS ..............................  6
  1673.              SYMBOLS .......................................  4,13
  1674.              SYNTAX ........................................  7,21
  1675.              TABS ..........................................  4, 6
  1676.              TERMINAL ERRORS ............................... 14,15
  1677.              UNDERSCORE ....................................  4, 6
  1678.              WARNING MESSAGES .............................. 17,18
  1679.              WORDSTAR DOT COMMANDS .........................  4
  1680.              Z80 OPCODES ................................... 20
  1681.              Z80 SYNTAX SUMMARY ............................ 21
  1682.              [ ] ...........................................  7
  1683.              \ .............................................  5
  1684.              ^ .............................................  7
  1685.          
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.                                     PAGE 28
  1710.