home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / z1.ark / Z1.DOC < prev    next >
Encoding:
Text File  |  1986-10-24  |  8.0 KB  |  179 lines

  1.  
  2. HEADER                                                  24 Oct 1986
  3. TITLE
  4. VERSION
  5. ;
  6. DESCRIPTION     Describes Z1.COM in terms of changes to Z80MR.COM
  7. ;
  8. KEYWORDS
  9. SYSTEM          CP/M-80, V2.2
  10. FILENAME        Z1.DOC
  11. WARNINGS        Describes only the new features.  Original Z80MR and
  12. ;                 associated doc files available on disk #B25 from Micro
  13. ;                 Cornucopia Magazine
  14. ;
  15. SEE-ALSO        Z1.COM
  16. AUTHORS         Neil Koozer
  17. COMPILERS
  18. ;
  19. Z1.DOC   by   Neil R. Koozer, Kellogg Star Rt. Box 125, Oakland, OR 97462
  20. ;
  21. Z1.COM  is  my own modification of Z80MR.COM.  The original  Z80MR and
  22. associated .DOC files are on disk #B25 from Micro Cornucopia Magazine,
  23. P.O. box 223, Bend, OR 97709.  The following is a description of the
  24. changes:
  25. ;
  26. LIST C.  Using the C-option causes the assembler to produce a .COM  file
  27. directly without producing a HEX file.  In this mode, the gaps left by
  28. ORG and DS statements are filled with 00's except at the beginning of
  29. the file.  If you put a bunch of buffers at the beginning, they will not
  30. add to the stored code in the .COM file.  See the source listing Z1.AZM
  31. for an example of using an up-loader to put the code where it runs.
  32. ;
  33. LIST P.  Using the P-option invokes single-pass operation.  In order for
  34. LIST P to be recognized, it must be in the very first line of the source
  35. file.  The regular labels can't be used for forward reference in single-
  36. pass operation, so the source needs to be arranged like a Pascal program.
  37. ;
  38. Subroutines, jump destinations and data objects need to be defined be-
  39. fore they are used.  In the few places where this can not be done, we
  40. use psuedo-labels (see below) for forward references.
  41. ;
  42. PSUEDO-LABELS.  These are abbreviated symbols intended for use in very
  43. short jumps and for forward references in single pass operation.  They
  44. are actually embellished versions of the $ symbol.  They consist of two
  45. characters, the first of which is $.
  46. ;
  47. $0 thru $9 , $%, $!, $@, $? are backward symbols and work almost the same
  48. as regular symbols:
  49. ;
  50.         $0      LD      A,B     ; This line same as  $0:   DEFL   $
  51.                 DJNZ    $0      ;                          LD    A,B
  52.                 LD      B,85
  53.         $0      CALL    DOSUMPN
  54.                 DJNZ    $0
  55. ;
  56. These symbols don't go into the symbol table, so there is no search time
  57. to find them.  Using these symbols prevents a lot of nonsense symbols
  58. from bloating the symbol table, thereby making large programs assemble
  59. more efficiently.  These  symbols can be redefined at will and can be
  60. referenced any number of times after each definition.
  61. ;
  62. $A thru $Z are forward symbols:
  63. ;
  64.                 JR      NZ,$A   ; Symbol $A initialized here
  65.                 LD      A,45
  66.                 JR      $B
  67.         $A      LD      A,73    ; Symbol $A resolved here
  68.         $B      LD      (THERE),A
  69.                ....
  70. ;
  71. Each of these symbols can only be used (or initialized) once until it is
  72. resolved.  After being resolved, it is free to be used again.  Since
  73. these symbols must toggle between active (initialized) and inactive (re-
  74. solved), the assembler can recognize an unbalance and issue an error
  75. code.  A 'W' in the left  margin  denotes  such a phase error.  If two
  76. lines must  make forward reference to the same spot, then two psuedo
  77. labels can be used:
  78.  
  79.                 JR      Z,$C
  80.                 CP      'S'
  81.                 JR      Z,$D
  82.                 ...
  83.         $C
  84.         $D      LD      A,B
  85. ;
  86. The psuedo-labels can be used in expressions, but the forward varieties
  87. suffer the same restrictions as external symbols.  The expression is re-
  88. stricted to effectively adding a forward symbol to the rest of the ex-
  89. pression.  The 'E' error code shows up for invalid  expressions.  Since
  90. these symbols do not nest, there are two separate symbols with a nesting
  91. property, $$ for backward and $_ for forward.  They are primarily for
  92. jump tables:
  93.         $$      <routine1>
  94.         $$      <routine2>
  95.         $$      <routine3>
  96.         ...
  97.         JMPTABL DW     $$,$$,$$,...
  98. ;
  99. Another usage:
  100.  
  101.                 LD      B,0
  102.         $$      PUSH    BC
  103.                 LD      B,0
  104.         $$      DJNZ    $$      ; This one references the second $$
  105.                 POP     BC
  106.                 DJNZ    $$      ; This one references the first $$
  107. ;
  108. Because of their nesting property, the symbols $$ and $_ can be used in
  109. macros, thereby preventing macros from filling the symbol table with
  110. nonsense symbols.  The maximum nesting depth of $$ and $_ is set by a
  111. couple of EQU's at the beginning of the source code of the assembler.
  112. They are presently set at 40 for $$ and 10 for $_.
  113. ;
  114. The forward psuedo-labels only work when outputting a .COM file.  If you
  115. want to make a .HEX file,  you have to use two-pass operation if there
  116. are any forward references.
  117. ;
  118. LIST and *LIST are now the same.  They both will accept a list of single
  119. character options as well as the words ON and OFF.
  120. ;
  121.         *LIST   A,B,ON
  122.                 LIST    A,ON,B
  123.                 LIST    A,B,S   ; All three are equivalent.
  124. ;
  125. It is best to keep the ON or OFF at the end of the list because the
  126. statement:
  127.                 LIST    A,OFF,B
  128. ;
  129. will also turn off B.
  130. ;
  131. INTERNAL CHANGES.  In order to resolve forward references during single-
  132. pass assembly, I changed the buffering of the object output to use de-
  133. mand-paged virtual memory.  To speed up the handling of text, I changed
  134. the buffering method for the input, include and listing files.  The me-
  135. thod essentially adds some auxilliary space to the length of the buffer
  136. so that you never have to worry about the end of the buffer occuring in
  137. the line you are working on.  This obviates many operations and allows
  138. some operations to be done with Z80 block move instructions.  To speed
  139. up symbol search, I replaced the linear search with a binary search.
  140. When symbols are created, they are inserted into the table alphabeti-
  141. cally.  At first thought, this seemed like too much moving,  but it is
  142. very mush faster than sorting and makes the binary search possible during
  143. the first pass.  To speed up the search for mnemonics, I put them all
  144. into a 'state machine'.  This is faster than a binary search because it
  145. never has to start over at the beginning of the next word.  It essen-
  146. tially does a multi-way branch on each character.  For example, in the
  147. words DEFL, DEFS, DEFW and  DEFM, after getting through DEF it only uses
  148. the fourth character to determine if it has one of these words.  It does
  149. not have to go through DEF again.  The 'state machine' is also fast be-
  150. cause there is no looping involved; it consists entirely of compares and
  151. branches.  I took the register names out of the symbol table and put
  152. them into their own little state machine.  Ditto for the flag-condition
  153. mnemonics.
  154.  
  155. SPEED.  This thing assembles itself to a .COM file in 15.8 sec on my Z80
  156. system (3.68 Mhz, 1 wait, RAM disk).  This is around 17 times faster
  157. than the original Z80MR can assemble itself and be LOADed.  For another
  158. comparison, it takes the CP/M LOAD program 9 seconds to translate the
  159. equivalent .HEX file into a .COM file.
  160.  
  161. OTHER NOTES.  If you run this assembler, you may notice in the listing
  162. output that the addresses are printed in 24-bit format.   This is
  163. because I have begun to convert the assembler to a 32000 cross-assembler.
  164. It currently handles the program counter as a 32-bit value and is able
  165. to make .COM files larger than 64k (if you can train your Z80 to use
  166. them).  The  psuedo-labels store 32-bit values,  but the regular symbols
  167. still use only 16-bit  values.
  168. ;
  169. I can't really test the  features pertaining to relocatable code since
  170. there is no  linker.  I'm also planning to change the way symbols are
  171. stored in order to allow arbitrary-length  symbols.  This  will probably
  172. gain some additional speed.
  173. ;
  174.                                         - Neil R. Koozer
  175.  
  176. P.S.  My  32000 cross assembler is now operational.  Anyone desiring a
  177.       copy please send a card.
  178.  
  179.