home *** CD-ROM | disk | FTP | other *** search
/ HomeWare 14 / HOMEWARE14.bin / prog / a86v371.arj / A13.DOC < prev    next >
Text File  |  1994-01-24  |  19KB  |  403 lines

  1. CHAPTER 13   ASSOCIATED TOOLS AND OUTPUT FILES
  2.  
  3.  
  4. Listings with A86
  5.  
  6. A86 has a powerful listing facility, that allows you to tailor
  7. the format of your listings to your specific needs.  Because the
  8. listing pass adds a significant percentage to the time it takes
  9. A86 to execute, the listing is not produced by default.  You must
  10. include either a +L switch, or the name of a file with a .LST
  11. extension on the A86 invocation line.
  12.  
  13. By default (+L but nothing else specified), an A86 listing file
  14. consists of a sequence of pages, each 59 lines long and 79
  15. characters wide.  Each page has a header line identifying A86 and
  16. its version number, giving the name of the program output file,
  17. the date and time of assembly, the name of the source file
  18. currently being listed, and a page number.  Note that I am not so
  19. obnoxious as to splash my company name over the top of every page
  20. of your listing!  If both a TITLE and a SUBTTL have been
  21. specified, the header consists of three content lines and one
  22. skipped line; otherwise, there are just two content lines.  Each
  23. listing line has a sequential line number, a hex offset and hex
  24. object bytes, an indicator field with "i" for include files and
  25. "m" for macro expansions, and the source code itself.  Nested
  26. includes have no special indication; nested macros are indicated
  27. by increasing indentation of the macro expansion line.  A86 tries
  28. to be intelligent about the formatting of its listings: it will
  29. break up the wraparound of a long line at a word if reasonable.
  30. It will avoid breaking up a multi-line listing of less than 10
  31. lines.  It will break pages at sensible locations (described in
  32. detail shortly, under the PAGE directive).  It will suppress
  33. blank lines at the top and bottom of pages (but it counts them in
  34. the sequential line numbering so you can tell they were there).
  35.  
  36. Five A86 switches, H, I, L, T, and W, allow you to control the
  37. existence and characteristics of titling, pagination, page-number
  38. format, page break control, source line numbering, hex object
  39. display, and source line display.  The operation of these
  40. switches is described in detail in Chapter 3.  Here are some
  41. examples of switch settings that will produce listings meeting
  42. some specialized needs:
  43.  
  44. +L21+T0+W12+I137 produces a listing consisting only of the source
  45. code, with the hex offset of each line placed to the left, and
  46. with the line truncated at 79 columns.  Such a listing file would
  47. be ideal for viewing the source file while debugging on a
  48. primitive remote system that cannot run D86.
  49.  
  50. +L9+T0+W4+I128 produces a list file of just source code, with all
  51. conditional-assembly lines and skipped code removed.  All
  52. titling, pagination, line numbers, and hex codes are eliminated,
  53. so the list file could be renamed as a source file, and
  54. reassembled.  This might be useful for archival purposes, or for
  55. giving individualized versions of a source file to parties who
  56. don't need any of the conditional-assembly options you've
  57. programmed.
  58.                                                              13-2
  59.  
  60. +L+I186+H15+W12 produces a list file that concentrates on the hex
  61. output, increasing the width to 16 bytes per line, showing up to
  62. 15 hex runover lines, and limiting the amount of source code
  63. shown.
  64.  
  65.  
  66. Listing Control Directives
  67.  
  68. In addition to the five switches just mentioned, A86 has a number
  69. of source-code directives that control aspects of listings.
  70.  
  71. The .NOLIST directive causes all subsequent listing to be
  72. suppressed, until a .LIST directive is seen.  Line numbering and
  73. page numbering continues during list suppression, so the result
  74. is as if you had text-edited the listing file to remove all the
  75. suppressed lines.
  76.  
  77. I also offer a macro-definition control code, #H, which causes
  78. the suppression of the listing of macro expansion lines.  If #H
  79. appears anywhere within a macro definition, all calls to that
  80. macro will be listed as the macro call line only, showing the
  81. generated hex object bytes on that call line.  This allows you to
  82. define macros that will be listed as if they were simple machine
  83. instructions.  This effect can be achieved for all macros with an
  84. L switch setting that doesn't include the value 4 (see Chapter
  85. 3).
  86.  
  87. The TITLE directive specifies a title that will appear at the top
  88. of every page of the entire assembly.  The title consists of the
  89. first 60 characters starting with the first nonblank after the
  90. word TITLE on the line.  If you give more than one TITLE
  91. directive in a program, only the first will be recognized.
  92.  
  93. The SUBTTL directive specifies a subtitle to appear at the top of
  94. every page until another SUBTTL directive is given (or until the
  95. next file change if you have the +T16 switch-bit value set).  If
  96. the directive is at the very top of the listing page, or it is
  97. shortly after an automatic page break, the subtitle will take
  98. effect on the page in which it appears.  Otherwise, it will take
  99. effect at the next page.
  100.  
  101. The PAGE directive serves several purposes.  The word PAGE by
  102. itself will force a new page in the listing, at that point.  A
  103. plus sign following the word PAGE causes a new page plus an
  104. incremented section number -- e.g. PAGE + on page 1-17 will cause
  105. a new page 2-1 to begin.  The word PAGE followed by one or more
  106. constant parameters will set various A86 listing variables to the
  107. specified parameter values.  The variables are as follows:
  108.  
  109. 1. The length, in lines, of a listing page.  Minimum is 10;
  110.    maximum is 65535.
  111.  
  112. 2. The width, in characters, of the maximum listing line.
  113.  
  114. 3,4,5,6. The number of lines at the end of a page, less than
  115.    which A86 guarantees will not be "widowed" after a page break
  116.    of level 1,2,3,4, respectively.
  117.                                                              13-3
  118.  
  119. Omitted parameters (either left off the end or via leading commas
  120. or 2 consecutive commas) will remain unchanged.
  121.  
  122. The concept of "page break levels" is unique to A86 listings: it
  123. is my attempt to get A86 to make intelligent decisions about
  124. where to issue new listing pages.  There are 4 page break levels,
  125. normally triggered by gaps (consecutive blank lines) in the
  126. source code, and by source-file changes.  One- and two-line gaps
  127. cause breaks of level 1 and 2, respectively.  Three-or-more-line
  128. gaps cause a break of level 3.  A source-file change causes a
  129. break of level 4.  If a page break occurs close to the end of a
  130. page, and a break of greater level hasn't already been marked,
  131. A86 will mark the point for a potential new page.  If a page
  132. break of equal or greater level doesn't occur before the page is
  133. full, A86 will issue a new page at the marked point.  The
  134. definition of "close to the end of the page" is 10,20,30, and 40
  135. lines, respectively, for break levels 1,2,3,4.  Those line counts
  136. can be changed by parmeters 3,4,5,6 of the PAGE directive, as
  137. already described.
  138.  
  139. If you are intimidated by all this, or if you want to control
  140. page break levels manually, you may specify a T switch value that
  141. does not include the "auto-paging" option value 4.  With that
  142. option disabled, page break levels will occur only at places
  143. where you issue a PAGE directive containing a special parameter
  144. value /1, /2, /3, or /4.  The leading slash indicates that a page
  145. break of the indicated level is desired here.  Such a parameter
  146. will typically be given by itself following PAGE; but, if you
  147. wish, it can be interspersed anywhere among other parameter
  148. values -- it will not be "counted" for the purposes of
  149. determining the other parameters' positions.
  150.  
  151.  
  152.  
  153. Cross-reference Facility
  154.  
  155.  
  156. When you specify the +X switch, A86 will create a
  157. cross-referenced symbol table listing of your program.
  158.  
  159. The output file, having a standard extension of .XRF is an
  160. alphabetical listing of all the non-local symbols in your
  161. program.  For each symbol, A86 gives its type, the file in which
  162. it was defined, its value, and a list of all procedures in which
  163. the file was used.  If you print this file, you typically use the
  164. TCOLS tool to obtain a multi-column listing from A86's
  165. single-column output.
  166.  
  167. Note the use of procedure names to identify references -- this
  168. makes the cross-reference listing truly readable.  Other
  169. cross-reference listings often give either line numbers, which
  170. are meaningless unless you go find the associated line; or a file
  171. name, which doesn't give you as much useful information.
  172.  
  173. Here is a more detailed description of the various pieces of
  174. information provided for each symbol:
  175.                                                              13-4
  176.  
  177. 1. TYPE.  Labels are indicated by a colon immediately following
  178.    the symbol name.  Special symbols such as macro names are
  179.    denoted by an appropriate word such as "macro" in place of the
  180.    value on the following line.  Other symbol types are described
  181.    by one or two characters, following the symbol name.
  182.    Possibilities for the first character are:
  183.  
  184.         m  for a simple memory variable
  185.         +  for an index memory quantity
  186.         c  for a constant
  187.         i  for an interrupt equate
  188.         s  for a structure
  189.  
  190.     If there is a second letter, it is a size attribute: b for
  191.     byte, w for word, f for far (or doubleword).
  192.  
  193. 2. FILE in which the symbol was defined.  The name is stripped of
  194.    its extension, which is presumably the same for all your
  195.    source files.  The name is preceded by = or period, which
  196.    denotes a definition of, not a reference to the symbol.
  197.  
  198. 3. VALUE, given as 4 hex digits, on the line following the
  199.    symbol.  For memory variables, this is the location of the
  200.    variable.  For indexed quantities, this is the
  201.    constant-displacement part of the quantity.  For structures,
  202.    it is the size of the structure.  For interrupt equates, it is
  203.    the number of the interrupt.
  204.  
  205. 4. REFERENCES, given on indented lines following the symbol name.
  206.    All occurrences of the symbol in your program produce a
  207.    reference.  If the symbol is the first thing on a line, it is
  208.    considered a "definition" of that symbol, the reference listed
  209.    is the source file name.  The name is preceded by a period if
  210.    the definition was via a colon (i.e., a label); it is preceded
  211.    by an equals sign otherwise. If the symbol is not the first
  212.    thing on the line, then it is not a definition.  The reference
  213.    listing consists of the name of the last definition that A86
  214.    scanned (which, if your program is organized in a standard
  215.    way, will be the name of the procedure in which the reference
  216.    occurred.
  217.  
  218.    Observe that you must use the local-label facility of A86 to
  219.    make this work.  If you don't use local labels as your
  220.    "place-marker" symbols, the symbol the cross-reference gives
  221.    you will often be the name of the last "place-marker" symbol,
  222.    not the name of the last procedure.
  223.  
  224.    To save space, duplicate reference entries are denoted by a
  225.    single entry, followed by "*n", where n is the decimal number
  226.    of occurrences of that entry.
  227.                                                              13-5
  228.  
  229. A86LIB Source File Library Tool
  230.  
  231. There is a tool, A86LIB.COM, available only if you are
  232. registered, that lets you build libraries of source files.  To
  233. use A86LIB, you must first code and debug the A86 source files
  234. that you wish to include in your library.  Then you issue the
  235. command A86LIB followed by the names of the source files.
  236. Wildcards are accepted; so you will typically want to gather the
  237. source files into a single directory, and use the wildcard
  238. specification.  For example, if you use the filename extension .8
  239. for your source files, you can issue the command A86LIB *.8 to
  240. create the library.
  241.  
  242. The library created consists of a catalog file, always named
  243. A86.LIB, together with the source files that you fed to A86LIB to
  244. create the catalog.
  245.  
  246. The following observations about A86LIB are in order:
  247.  
  248. 1. Unlike object-code libraries, A86.LIB contains only symbol
  249.    names and file names; it does not contain the code itself. You
  250.    MUST retain the source files used to create A86.LIB, because
  251.    A86 will read those files that it needs after consulting
  252.    A86.LIB to read their names.
  253.  
  254. 2. A86LIB records all non-local symbols that start a line, and
  255.    are followed by a colon or an EQU.  (Recall that local symbols
  256.    are those names consisting of a single letter followed by one
  257.    or more decimal digits.)   A86LIB also records all symbols
  258.    appearing on lines starting with the word PUBLIC.
  259.  
  260. 3. If a symbol appears in more than one library source file, it
  261.    will be logged for the first file A86LIB sees, and not the
  262.    subsequent ones.  No error will be reported, unless and until
  263.    A86 tries to assemble both files in one assembly, and sees a
  264.    conflict.
  265.  
  266. 4. A86LIB is simple-minded.  A86LIB does NOT recognize or expand
  267.    macros; nor does it recognize conditional-assembly directives.
  268.    This is because the library files do not stand by themselves;
  269.    the macros and conditional-assembly variables being used might
  270.    well be defined in the main program of the programs accessing
  271.    the library files.
  272.  
  273. You may update A86.LIB by running A86LIB again; either with new
  274. files or previously-recorded ones.  If A86LIB is given a file it
  275. had already read in a previous run, then A86LIB marks all the
  276. symbols it had logged for the file as deleted, before rereading
  277. the file.  Those symbols that are still in the file are then
  278. "unmarked".  Thus, symbols that have been deleted from the file
  279. disappear functionally from A86.LIB, but still occupy space
  280. within A86.LIB.  What I'm getting at is this: A86LIB will
  281. tolerate alterations in library files quite nicely; but for
  282. optimum storage efficiency you should delete A86.LIB and rebuild
  283. it from scratch any time you delete anything from the library.
  284. A86LIB is so fast that this is never very painful.
  285.                                                              13-6
  286.  
  287. Using A86.LIB in A86 Assemblies
  288.  
  289. Once you have created a library with A86LIB, you access it simply
  290. by calling the procedures in it from your A86 program.  When A86
  291. finishes an assembly and sees that there are undefined symbols in
  292. your program, it will automatically look for copies of A86.LIB in
  293. the current directory (then in other directories, as described in
  294. the next section).  If any of the undefined symbols are found in
  295. the A86.LIB catalog, the files containing them are assembled.
  296. You see this in the list of files output to the console by A86.
  297.  
  298. The subroutines in your library or libraries are effectively a
  299. permanent part of the A86 language.  They can be called up
  300. effortlessly in your A86 programs.  In time you can build up an
  301. impressive arsenal of library modules, making A86 as easy to
  302. program in as most high-level languages.
  303.  
  304. You may now have macros in your A86LIB library.  Here's how it
  305. works: when A86 sees a new symbol at the beginning of a line, in
  306. a context where it would formerly have issued an error, A86 will
  307. first look in the A86LIB libraries for the symbol.  If it's
  308. found, A86 will INCLUDE that library file on the spot, and then
  309. assemble the line.  NOTE that if the macro is being called within
  310. a sequence of executable instructions, the library file must
  311. generate no output object code.
  312.  
  313.  
  314.  
  315. Environment Variable A86LIB
  316.  
  317. You can set an environment variable A86LIB to specify which
  318. drives or subdirectories contain A86.LIB files.  The variable
  319. consists of a sequence of path names separated by semicolons,
  320. just like the PATH variable used by the operating system.  For
  321. example, if you include in your AUTOEXEC.BAT file the line
  322.  
  323.    SET A86LIB=C:\bin\lib;\tools\a86lib
  324.  
  325. then A86 will look for A86.LIB in the current directory, then it
  326. will look for C:\bin\lib\A86.LIB, then \tools\a86lib\A86.LIB. A86
  327. will keep looking in all three catalog files, assembling the
  328. appropriate source files from any or all of them, until there are
  329. no more undefined symbols, or there are no more source files to
  330. assemble.
  331.  
  332. For every symbol in an A86.LIB catalog, there is recorded the
  333. name of the library file containing the symbol.  The library file
  334. is assumed to be in the same directory as its A86.LIB file,
  335. unless a complete path name (starting with \ or a drive
  336. specifier) was fed to A86.LIB when A86.LIB was created.
  337.                                                              13-7
  338.  
  339. Forcing a Library Search
  340.  
  341. You may force A86 to assemble library files before moving on to
  342. more of your program's source files.  You do this by placing a
  343. hash sign # (hex code 23) between file names in your invocation
  344. line.  For example, suppose your program has two modules FIRST.8
  345. and LAST.8.  FIRST.8 calls subroutines from your library; but you
  346. need the library files assembled before LAST.8 is assembled. (You
  347. might want this because LAST.8 allocates memory space beyond the
  348. end of your program, which would be the end of LAST.8 if it were
  349. truly the last module.)  You accomplish this by the invocation
  350. line:
  351.  
  352.   A86 FIRST.8 # LAST.8
  353.  
  354. Note that there is never any need to force a library search at
  355. the end of your program modules: A86 always makes a library
  356. search there, if you have any undefined symbols.
  357.  
  358. You may now also force a library search from within a source
  359. file, by placing a line with INCLUDE by itself with no file
  360. names, into the source code.  A86 will include any library files
  361. necessary to resolve any forward-references at the point of the
  362. INCLUDE.
  363.  
  364.  
  365. Mimicking Tool: FAKE.EXE
  366.  
  367. As of this writing, Turbo C is aware only of the existence of
  368. Microsoft's MASM for assembling source files it generates.  I
  369. hope to persuade Borland to provide a switch to Turbo C that
  370. causes it to invoke A86 directly.  Until that happens, I offer
  371. the tool FAKE.EXE, that convinces Turbo C that A86 is really
  372. MASM.
  373.  
  374. To use FAKE.EXE, it must be renamed MASM.EXE in your disk system.
  375. I would have named it MASM myself, except that
  376.  
  377. 1. Bill Gates would probably get mad at me if I did, and
  378.  
  379. 2. You need to decide what to do with your real MASM if you have
  380.    it, before installing FAKE.  You could either place FAKE
  381.    (named MASM.EXE) into the individual directories containing
  382.    Turbo C programs, or you can rename MASM to something like
  383.    MSM.EXE or REALMASM.EXE.
  384.  
  385. Having renamed FAKE.EXE to MASM.EXE, you may now use the Turbo
  386. C's switch, -B, that allows you to place A86 statements into your
  387. C program.  You don't need to worry about the gory details of
  388. what FAKE does.
  389.  
  390. If you like gory details, here they are: FAKE filters the command
  391. line handed to it, replacing switches:
  392.                                                              13-8
  393.  
  394.    /D becomes =
  395.    /ml becomes +c
  396.    /mx becomes +C
  397.    /E becomes +f
  398.  
  399. FAKE also eliminates the semicolon, appends .ASM to the source
  400. file name, and turns on the O and S switches.  It then feeds the
  401. resulting filtered command line to A86 for assembly.
  402.  
  403.