home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / commercial-software / programming / Z80TOOLS.ZIP / DISK1.ZIP / TOOLKIT.DOC < prev   
Text File  |  1998-07-30  |  17KB  |  413 lines

  1.          This disk contains software described and displayed in
  2.  
  3.                          DR. DOBBS' Z80 TOOLKIT
  4.  
  5.                           by David E. Cortesi
  6.  
  7.                         The Copyright Statement
  8.  
  9. Like the book, the contents of this disk are Copyright (c) 1985 by M&T
  10. Publishing, 2464 Embarcadero Way, Palo Alto, CA 94303.  All rights
  11. reserved.  The original purchaser is permitted to copy this material in
  12. any way needed to support his or her personal computer use, provided
  13. that embedded copyright statements are retained.  Distribution of the
  14. program source files in any form or via any medium is expressly
  15. forbidden.  Apply to publisher for permission to distribute in object
  16. form as an embedded part of another product.
  17.  
  18.                         The Necessary Disclaimer
  19.  
  20. Like any nontrivial software, these programs surely contain errors of
  21. logic despite the best efforts of all concerned.  Moreover, the nature
  22. of library functions is such as to make their misuse more likely, and
  23. the consequences of their misuse potentially more serious, than that of
  24. other programs.  Finally, the purpose, methods, and internal design of
  25. the programs are described at length in the companion book.  Therefore
  26. the reader is responsible for judging the fitness of this software for
  27. use in any particular application and neither author nor publisher will
  28. be liable for damages consequent on such use.
  29.  
  30.                              And So To Work
  31.  
  32.      You must perform several tasks in order to use this material.  Your
  33. first move should be to print this file and read it through in comfort.
  34. Then you can refer to it while typing commands, make notes in its
  35. margin, and so forth.
  36.  
  37.      Next you must copy the distribution disks so you can put the
  38. originals away in a safe place and use the copied files thereafter.  The
  39. copy need not be in the same format as these disks: if you have a hard
  40. disk, or if your normal diskette format holds more data, by all means
  41. copy the files in your usual format.
  42.  
  43.                          The Distributed Files
  44.  
  45.      These disks should contain the following files.  They won't be in
  46. this order but you should be able to find them all.  Here they are with
  47. their sizes in kilobytes and capsule descriptions:
  48.  
  49. toolkit.doc       16k   this file
  50. antdir.com         6k   lists contents of anthologies
  51. antget.com         6k   copies files out of anthologies
  52. cmdrel.ant/x/y    18k   anthology of command program object files
  53. modules.rel        6k   object of modules developed in the book
  54. env22.rel         13k   object of toolkit functions (CP/M 2.2)
  55. env30.rel         13k   object of toolkit functions (CP/M 3.0)
  56. environ.lib       22k   toolkit function macros
  57. cmdasm.ant/x/y    77k   anth: command program source files
  58. modules.ant/x/y   51k   anth: module source files
  59. maclibs.ant/x/y   61k   anth: commented toolkit macros
  60. seqfile1.ant/x/y 103k   anth: source of most file functions
  61. seqfile2.ant/x/y  41k   anth: source of file open/close
  62. strings.ant/x/y   31k   anth: source of string functions
  63. integers.ant/x/y  27k   anth: source of integer functions
  64. tests.ant/x/y      8k   anth: source of character tests
  65. program.ant/x/y   16k   anth: source of program control functions
  66.  
  67. Check that they're all present and accounted for.
  68.  
  69.                          Regarding Anthologies
  70.  
  71. The design of anthologies and the anthology commands was described in
  72. chapters 8-10.  If you haven't read them, here's a capsule explanation.
  73.      An anthology is a collection of smaller files.  The files held in
  74. an anthology are called "members" of the anthology.  An anthology is
  75. held in three CP/M files.  They all have the same filename, while their
  76. filetypes are .ANT (the data) and .ANX and .ANY (directories).  Thus you
  77. have the three files
  78.  
  79.      cmdrel.ant
  80.      cmdrel.anx
  81.      cmdrel.any
  82.  
  83. which together make up the single anthology, CMDREL.
  84.      The antdir command lists the contents of an anthology.  You can
  85. list the contents of CMDREL, for instance, with the command
  86.  
  87.      antdir cmdrel
  88.  
  89. The antdir command is like DIR in that you may select a set of files --
  90. say, the anthology commands -- by supplying a filespec:
  91.  
  92.      antdir cmdrel ant*.*
  93.  
  94.      An anthologized file must be copied out from the anthology before
  95. it can be used for anthing.  The antget command copies members from
  96. anthologies.  To copy a particular file -- say, the typist program --
  97. from the CMDREL anthology, give the anthology name and the filespec of
  98. the member:
  99.  
  100.      antget cmdrel typist.rel
  101.  
  102. The antget command will accept wildcards in its second operand, so you
  103. may copy out several members with similar names:
  104.  
  105.      antget c:cmdrel b:ant*.rel
  106.  
  107.      The Antdir and Antget commands are supplied in executable form for
  108. CP/M 2.2 (but will also run on CP/M Plus).  Other anthology commands are
  109. in the CMDREL anthology and have to be linked before they can be run.
  110.  
  111.                   Preparing The Toolkit Object Library
  112.  
  113. The toolkit support functions are provided in two forms, one for CP/M
  114. 2.2 and one for CP/M 3.0 (CP/M Plus).  You must use the version
  115. appropriate for your system.  The 2.2 versions will work under CP/M Plus
  116. (but won't handle file passwords).  However, the Plus file tools will
  117. *not* work under 2.2.
  118.      Both sets of tools are provided in object form.  The file ENV22.REL
  119. contains the CP/M 2.2 version; ENV30.REL is for CP/M 3.0.  Your next
  120. task is to copy the correct version for your system under the filename
  121. ENVIRON.  The form in which you copy it depends on whose LINK command
  122. you are using.
  123.      If you are using the Digital Research LINK command that comes with
  124. RMAC, I recommend you use the Digital Research LIB command to make an
  125. indexed relocatable library, like this (for 2.2):
  126.  
  127.      lib environ.irl[i]=env22.rel
  128.  
  129. The same command, using ENV30.REL, would be right for CP/M Plus.
  130.      Link programs from other publishers can't handle the .IRL file
  131. format.  For them, it's best to leave the object file in .REL format and
  132. copy it with pip:
  133.  
  134.      pip environ.rel=env22.rel[v]
  135.  
  136. This ENVIRON object library is a file you will use fairly often, so copy
  137. it to your assembler work disk.  You won't need the ENV22 and ENV30
  138. files again except as backup.
  139.  
  140.                         Linking Command Programs
  141.  
  142. All the command programs developed in the book (and some bonus extras)
  143. are stored in two anthologies: CMDASM contains their source files, and
  144. CMDREL their object files.  To save space, only antdir and antget are on
  145. the disk as complete .COM files.  They had to be, so you could get at
  146. the others!
  147.      Two steps are needed to prepare each command file.  First you must
  148. copy it out from CMDREL; then you must link it with the support modules
  149. and toolkit functions.  Suppose you wanted the PACK program next.
  150. Extract it with
  151.  
  152.      antget cmdrel pack.rel
  153.  
  154. and then link it this way (using the Digital Research link command):
  155.  
  156.      link pack,modules[s],environ.irl[s]
  157.  
  158. It may be possible to link these programs using a linker from another
  159. vendor.  However, I HAVE NOT TESTED ANY OTHER LINKER, and can't advise
  160. on command sequences or problems.
  161.      List the members of cmdrel now and link any that you want to use.
  162. The resulting command files (.COM files) may be copied to other disks
  163. for use as you see fit.  After this, you won't need the CMDREL anthology
  164. except for backup.
  165.  
  166.      Use the same linking procedure for a program of your own, or for a
  167. command you take from the CMDASM anthology and modify: assemble it, then
  168. link it with the toolkit modules from the MODULES and ENVIRON libraries.
  169. If you don't plan to write programs of your own, you needn't read any
  170. further in this file.
  171.  
  172.                      Setting Up the Toolkit Macros
  173.  
  174. To make programs of your own or modify the ones from the book, you must
  175. assemble them, probably with the RMAC assembler from Digital Resarch.
  176. Before it can call on a toolkit function, any program must contain the
  177. statement
  178.  
  179.      maclib environ
  180.  
  181. This loads ENVIRON.LIB, the library of macros that are the interface to
  182. the toolkit functions.  But before you use it in an assembly, you must
  183. make sure that ENVIRON.LIB is correct for your operating system.
  184.      The very first line of ENVIRON.LIB is
  185.  
  186.      CpmLevel equ 22h
  187.  
  188. This is correct if you are in fact using CP/M 2.2 or another DOS
  189. compatible with it.  However, if you are using CP/M Plus you ought to
  190. edit the distributed version of ENVIRON.LIB and change that first line
  191. to read
  192.  
  193.      CpmLevel equ 30h
  194.  
  195. Now you may copy the macro library to your assembly work disk.
  196.      The CpmLevel equate has very little effect in your own programs and
  197. in those from the book.  Primarily, it decides whether or not the PROLOG
  198. macro will generate code to set the CP/M Plus Program Return Code when a
  199. program ends.  CP/M 2.2 doesn's support a Program Return Code, but no
  200. harm comes from trying to set it.
  201.      The effect of CpmLevel on a toolkit function can be profound.  Some
  202. of the file functions assemble drastically different code in the two
  203. systems.  That explains why you received two different toolkit object
  204. libraries (ENV22 and ENV30) but only one set of command object files
  205. (CMDREL).
  206.  
  207.      Now that ENVIRON.LIB is ready to use, you might like to to examine,
  208. change, and reassemble the source of the command programs.  Those files
  209. are in the CMDASM anthology.  List its members with antdir and extract
  210. them with antget.  Once copied out, you may treat them like any other
  211. assembler source files.
  212.  
  213.                          Commented Macro Source
  214.  
  215. Should you examine ENVIRON.LIB, you will see that it contains no
  216. comments or pretty formatting.  That is because it has been processed by
  217. the command SQASM, a utility that strips all comments, blank lines, and
  218. redundant spaces from an assembly source file.  Stripping ENVIRON.LIB
  219. makes it smaller, which shortens assembly time a lot.
  220.      Commented versions of the macros do exist.  They are contained in
  221. the MACLIBS anthology.  Check it with antdir; you'll see it contains
  222. several macro libraries.  Feel free to extract them with antget and
  223. browse through them.
  224.      ENVIRON.LIB is constructed by catenating seven of those libraries.
  225. Each of the seven contains macros from a different area.  The files are
  226. separated for ease of editing, then made into a single ENVIRON.LIB for
  227. ease of assembly.  If you should want to make a change in ENVIRON.LIB
  228. (not something you would normally do), here is the right way to go about
  229. it.  First, extract its seven components (this could be a submit file):
  230.  
  231.      antget maclibs equates.lib
  232.      antget maclibs smallz80.lib
  233.      antget maclibs program.lib
  234.      antget maclibs seqfile.lib
  235.      antget maclibs tests.lib
  236.      antget maclibs integers.lib
  237.  
  238. Then edit the library that contains the macro to be changed.  Put the
  239. updated version back in MACLIBS with antput.  Then create a new
  240. ENVIRON.LIB with these commands (which ought to be a submit file):
  241.  
  242.      sqasm equates.lib 1.x
  243.      sqasm smallz80.lib 2.x
  244.      sqasm program.lib 3.x
  245.      sqasm seqfile.lib 4.x
  246.      sqasm strings.lib 5.x
  247.      sqasm tests.lib 6.x
  248.      sqasm integers.lib 7.x
  249.      era environ.lib
  250.      pip environ.lib=1.x,2.x,3.x,4.x,5.x,6.x,7.x
  251.      era *.x
  252.  
  253. The SQASM command is in CMDREL; you'll have to link it for use.
  254.  
  255.                          Extra Macro Libraries
  256.  
  257. The MACLIBS anthology contains four macro libraries that are not used in
  258. ENVIRON.LIB.  The first is SERVICES.LIB; it contains equates for all the
  259. BDOS services, and a macro that makes it easy to call the BDOS.  Use it
  260. in programs of your own if you need to write explicit calls on the BDOS.
  261. The second extra is FCR.LIB; it describes the fields of a File Control
  262. Record.  You should never need to include it in your own programs.
  263. However, FCR and SERVICES are used by some toolkit functions, and you'd
  264. have to copy them out in order to reassemble those source files.
  265.      A third library, BIOSCALL.LIB, is used by none of these programs.
  266. It defines names for BIOS entry points and has a macro for calling the
  267. BIOS.  The call goes through a module, BIOS, that is present in the
  268. ENV22/30 object libraries (its source is in the PROGRAM anthology).
  269.      Finally, OTHERZ80.LIB contains the Z80 instructions that were
  270. omitted from ENVIRON.LIB.  The instructions that deal with index
  271. register IY, with the alternate register set, with the unauthorized Z80
  272. instructions, and with hardware I/O are defined here.  If you need them,
  273. copy out this library and name it your programs.
  274.  
  275.                         The Toolkit Source Files
  276.  
  277.      The assembly source of toolkit functions is contained in five
  278. anthologies, each corresponding to one functional area.  You'll notice a
  279. correspondence between the names of these anthologies and the names of
  280. five of the maclibs in the MACLIBS anthology.  That's no coincidence!
  281. The modules stored in the SEQFILE anthologies are the ones that are
  282. called by the macros found in SEQFILE.LIB, and the same correspondence
  283. holds for the PROGRAM, STRINGS, TESTS, and INTEGERS anthologies.
  284.      To view a module's source, extract it with antget.  Should you want
  285. to assemble one, notice which macro libraries it includes, and extract
  286. those from the MACLIBS anthology for it to use.
  287.      Should you change a module, you may test it with a program of your
  288. own by naming it separately in the link:
  289.  
  290.      link testprog,newmod,environ.irl[s]
  291.  
  292. Here "testprog" is a program that will exercise the changed function of
  293. "newmod."  Since it is specifically named, the file "newmod.rel" will be
  294. linked while the old version of it still in ENVIRON.IRL will be ignored.
  295.      After testing a module may be updated in ENVIRON.IRL with the LIB
  296. utility from Digital Research:
  297.  
  298.      lib environ.irl[i]=environ.irl<newmod>
  299.  
  300. The order in which modules appear in ENVIRON.IRL is critical: a module
  301. must follow all the modules that call upon it, and ZZPROG must be the
  302. very last.  Thus you should only update a module in the way shown above;
  303. don't use LIB to delete a module or tack it on the front or back.
  304.      In the unlikely event that you have to reassemble and reconstruct
  305. the entire toolkit object library, here is a table of all the toolkit
  306. source modules, with their source anthology names, in the order that
  307. they appear in ENVIRON.IRL:
  308.  
  309. ; file control routines
  310.      fckpt seqfile1
  311.      fdirs seqfile1
  312.      fattrs seqfile1
  313.      fqeof seqfile1
  314. ; get routines
  315.      fsgbw seqfile1
  316.      fsgxw seqfile1
  317.      fskip seqfile1
  318.      fsgst seqfile1
  319.      fsgac seqfile1
  320.      fsgbk seqfile1
  321.      fsg24 seqfile1
  322.      fsgbb seqfile1
  323.      fsgby seqfile1
  324. ; put routines
  325.      fspbx seqfile1
  326.      fspwx seqfile1
  327.      fsplx seqfile1
  328.      fspbd seqfile1
  329.      fspbw seqfile1
  330.      fspsw seqfile1
  331.      fspld seqfile1
  332.      fspst seqfile1
  333.      fspac seqfile1
  334.      fspbk seqfile1
  335.      fsp24 seqfile1
  336.      fspbb seqfile1
  337.      fspby seqfile1
  338. ; direct-access routines
  339.      frecda seqfile1
  340.      fsize seqfile1
  341.      fnote seqfile1
  342.      fseek seqfile1
  343. ; open/close routines
  344.      fopni seqfile2
  345.      fopno seqfile2
  346.      fopna seqfile2
  347.      fopnu seqfile2
  348.      fopnc seqfile2
  349.      fopne seqfile2
  350.      fbufr seqfile2
  351.      fmake seqfile2
  352.      fclos seqfile2
  353.      fpass seqfile2
  354.      fasgn seqfile2
  355. ; internal file routines
  356.      frfil seqfile1
  357.      fbadv seqfile1
  358.      fbout seqfile1
  359.      fbupd seqfile1
  360.      fbinp seqfile1
  361.      fbrra seqfile1
  362.      fbaim seqfile1
  363.      feror seqfile1
  364.      fstsp seqfile1
  365. ; string functions
  366.      strhex strings
  367.      strplw strings
  368.      strpbw strings
  369.      strpbb strings
  370.      strpnd strings
  371.      strtxt strings
  372.      strput strings
  373.      strtak strings
  374.      strapp strings
  375.      strend strings
  376.      strgsw strings
  377.      strgbw strings
  378.      strgxw strings
  379.      strskp strings
  380.      strlok strings
  381.      strcmp strings
  382.      strlen strings
  383. ; integer arithmetic
  384.      random integers
  385.      lwldst integers
  386.      lwarth integers
  387.      cpllw integers
  388.      div816 integers
  389.      divlw integers
  390.      divsw integers
  391.      divbw integers
  392.      mpy816 integers
  393.      mpysw integers
  394.      mpybw integers
  395.      cmpsw integers
  396.      cplbw integers
  397.      addahl integers
  398. ; tests
  399.      touppr tests
  400.      test01 tests
  401.      test02 tests
  402.      test03 tests
  403. ; program control
  404.      cmdtok program
  405.      dsaloc program
  406.      ramfil program
  407.      bios program
  408.      zzprog program
  409. sts
  410. ; program control
  411.      cmdtok program
  412.      dsaloc program
  413.