home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / chasm4.zip / CHASM.DOC < prev    next >
Text File  |  1985-06-01  |  146KB  |  5,545 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                         READ
  8.                                         THIS
  9.                                        BEFORE
  10.                                       PRINTING!!!!
  11.  
  12.  
  13.  
  14.       This document has been formatted in a special way. Virtually all dot
  15.       matrix printers have a condensed mode which prints 132 characters
  16.       across a standard 8 1/2 inch page.  When this file is printed out in
  17.       condensed mode, the resulting printed pages can be cut down to 5 1/2 X
  18.       8 1/2 inches.  The cut pages will fit nicely in the back of your
  19.       DOS manual for storage.
  20.  
  21.       Typically, you can turn on this mode by sending a special control
  22.       sequence to the printer from BASIC.  For example, you can turn on the
  23.       condensed mode of the IBM/Epson printer with the BASIC statement:
  24.       LPRINT chr$(15).  If your printer has such a condensed mode, turn it
  25.       on now, before printing the rest of this document.
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.                                          (tm)
  81.                                     CHASM
  82.  
  83.                                Cheap Assembler
  84.                         for the IBM Personal Computer
  85.  
  86.                                 User's Manual
  87.                           (c) 1983 by David Whitman
  88.                                 Version 4.00
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.       David Whitman
  109.       136 Wellington Terrace
  110.       Lansdale, PA 19446
  111.  
  112.       (215) 641-7114 (days)
  113.       (215) 362-8526 (evenings)
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                         Table of Contents
  137.  
  138.  
  139.  
  140.  
  141.       Why CHASM?..................................................1
  142.       What can CHASM do?..........................................2
  143.       What WON'T it do?...........................................3
  144.       System Requirements.........................................4
  145.       Advanced and Subset CHASM...................................5
  146.       Modifying CHASM's I/O Defaults..............................6
  147.       Syntax.....................................................10
  148.       Labels.....................................................12
  149.       Operands...................................................15
  150.       Operand Expressions........................................20
  151.       Resolution of Ambiguities..................................23
  152.       Pseudo-Operations..........................................26
  153.       Macros.....................................................33
  154.       Structures.................................................41
  155.       Outside the Program Segment................................45
  156.       Running CHASM..............................................46
  157.       Error and Diagnostic Messages..............................50
  158.       Execution of Assembled Programs............................54
  159.       Notes for Those Upgrading to This Version of CHASM.........62
  160.       Miscellaneous and A Word From Our Sponsor..................65
  161.       =============================================================
  162.       Appendix A: Mnemonic List..................................70
  163.       Appendix B: Differences Between CHASM and TOA..............72
  164.       Appendix C: Description of Files...........................77
  165.       Appendix D: Bug Reporting Procedure........................78
  166.       Appendix E: Using CHASM on "Compatable" Systems............79
  167.       Compiled Version Order Form................................80
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.                                                                       1
  201.  
  202.       >>Why CHASM?<<
  203.  
  204.       Why go to the trouble to write an assembler, when one already
  205.       exists?  The IBM Macro Assembler is a very powerful software tool
  206.       available off the shelf.  It supports features such as macros,
  207.       multiple segments, and linking to external procedures.
  208.  
  209.       Unfortunately, the cost of all this power is complexity. The
  210.       Macro Assembler is so complicated that IBM warns beginners it is
  211.       only suitable for "experienced assembly language programmers".
  212.  
  213.       For most users, this sophistication is more of a hindrance than
  214.       an aid.  Even when writing short, simple programs, the user is
  215.       saddled with a set of confusing pseudo-ops only appropriate for
  216.       large, multi-segment programs.  Producing a fast loading
  217.       executable file requires running three separate programs (MASM,
  218.       LINK and EXE2BIN) before you can get down to testing.
  219.  
  220.       The macro assembler is totally unsuitable for use with BASIC.
  221.       Although it is *possible* to produce machine language subroutines
  222.       for BASIC with the Macro Assembler, the process is incredibly
  223.       convoluted and confusing.
  224.  
  225.       To top it all off, the Macro Assembler costs an overpriced $125.
  226.  
  227.       CHASM is, I hope, a more reasonable compromise between power and
  228.       accessibility.  CHASM is simple to use and understand.  Unlike
  229.       the Macro Assembler, CHASM doesn't require a second LINK step to
  230.       produce a working program.  CHASM also produces fast loading
  231.       programs without the use of the utility EXE2BIN.
  232.  
  233.       CHASM supports two different, simple mechanisms for getting
  234.       machine language routines into BASIC, the most popular language
  235.       for the IBM Personal Computer.
  236.  
  237.       Finally, the suggested payment for CHASM is a modest $40.
  238.  
  239.       A Note for Beginners:
  240.  
  241.       Before going on, you might find it useful to print and read the
  242.       file PRIMER.DOC, included on your CHASM disk.  PRIMER is a gentle
  243.       introduction to assembly language, which will teach you some of
  244.       the vocabulary and key concepts you will need to start out with.
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.                                                                       2
  267.  
  268.       >>What can CHASM do?<<
  269.  
  270.       CHASM is a tool for translating assembly language into the native
  271.       machine language of the 8088 microprocessor.  Using CHASM, you
  272.       can write down easy to remember "mnemonics" which are then
  273.       converted into the relatively incomprehensible series of ones and
  274.       zeros that your PC prefers to work with.
  275.  
  276.       In addition to simple mnemonic translation (such as provided by
  277.       the mini-assembler in DEBUG), CHASM provides a great many
  278.       "convenience" features which make writing machine language much
  279.       easier.
  280.  
  281.       CHASM allows you to define labels for branching, rather than
  282.       requiring you to figure out offsets or addresses to jump to.
  283.       CHASM also lets you give symbolic names to any constants or
  284.       memory locations you use, to make your program easier to
  285.       understand.
  286.  
  287.       You can instruct CHASM to make your file "BLOADable" so that
  288.       BASIC can load it as a subroutine.   A utility is also provided
  289.       to convert machine language into BASIC "DATA" statements, so that
  290.       BASIC can "POKE" routines into memory.
  291.  
  292.       CHASM has intelligent error and diagnostic messages which guide
  293.       you in correcting mistakes and ambiguities in your program.  A
  294.       nicely formatted listing is produced during assembly, to help
  295.       during debugging.
  296.  
  297.       In general, CHASM is designed to eliminate much of the confusion
  298.       and dirty work involved in writing machine language for the IBM
  299.       PC.
  300.  
  301.       Using CHASM, you can produce:
  302.  
  303.          1. Lightning fast "stand-alone" programs.
  304.  
  305.          2. Machine language subroutines for BASIC programs, both
  306.             interpreted and compiled.
  307.  
  308.          3. External procedures for Turbo Pascal (*)
  309.  
  310.  
  311.  
  312.       * Turbo Pascal is a product of Borland International. 
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.                                                                       3
  333.  
  334.  
  335.       >>What WON'T it do?<<
  336.  
  337.       In the interest of simplicity, CHASM has the following
  338.       restrictions:
  339.  
  340.       1. Multiple segment definitions are not allowed. CHASM assumes
  341.          that your entire program fits in one segment, that the cs, ds,
  342.          and es registers all point to this same segment, and that the
  343.          ss register points to a valid stack area.  An equivalent
  344.          statement is that CHASM produces COM files, not EXE files.
  345.  
  346.       2. Linking to Microsoft languages is not supported.  You can't
  347.          use CHASM to produce object modules for use with IBM/Microsoft
  348.          Pascal or FORTRAN.
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.                                                                       4
  399.  
  400.       >>System Requirements<<
  401.  
  402.       Minimum system requirements to use CHASM are:
  403.  
  404.            IBM PC or true compatible (must emulate IBM BIOS)
  405.            128K of memory
  406.            1 disk drive
  407.            80 column display
  408.            DOS 2.0 or later.
  409.  
  410.       Note the DOS 2.0 requirement.  To provide *true* DOS 2 support,
  411.       it was necessary to give up DOS 1 compatibility.  If you're still
  412.       using DOS 1, you'll need to upgrade to DOS 2.0 or later to use
  413.       CHASM.
  414.  
  415.       Adding more memory will allow you to assemble larger programs.
  416.       CHASM can take advantage of all available memory, up to a
  417.       megabyte.
  418.  
  419.       CHASM will run faster if your source files and object files are
  420.       on a hard disk or RAM disk.
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.                                                                       5
  465.  
  466.       >>Advanced and Subset CHASM<<
  467.  
  468.       CHASM is available in two flavors, Advanced and Subset.
  469.       The two versions vary in their capabilities and method of
  470.       distribution.
  471.  
  472.       The subset version is the budget release.  It may be freely
  473.       copied by individuals as "user-supported" software, and is
  474.       available from user groups and bulletin boards across the
  475.       country.  Every time the subset runs, it prints a banner page
  476.       suggesting a payment of $40 to the author.  As its name
  477.       suggests, Subset CHASM does not support all the features of
  478.       Advanced CHASM.
  479.  
  480.       Advanced CHASM is the deluxe release.  It runs twice as fast, and
  481.       has a number of features not supported by the subset:
  482.  
  483.             macros
  484.             conditional assembly
  485.             include files
  486.             operand expressions
  487.             structures
  488.  
  489.       Advanced CHASM is only available directly from Whitman Software.
  490.       Users who make the suggested $40 payment receive an upgrade to
  491.       Advanced CHASM.  Details, and an order blank are given at the
  492.       end of this document.
  493.  
  494.       Throughout this document, features supported only by the
  495.       advanced version will be marked as follows:
  496.  
  497.         ==>Advanced version only.
  498.  
  499.       Attempts to use these features in the subset version will
  500.       generally result in error messages, with the advanced feature
  501.       otherwise being ignored; however, unpredictable behavior could
  502.       result in some instances.
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.                                                                       6
  531.  
  532.       >>MODIFYING CHASM'S I/O DEFAULTS<<
  533.  
  534.       CHASM supports the use of a configuration file, which can be used
  535.       to override some of CHASM's I/O defaults.  If you are willing to
  536.       accept CHASM's defaults, you may skip this section - CHASM will
  537.       work perfectly well without the file described below.
  538.  
  539.       The configuration process involves supplying a text file named
  540.       CHASM.CFG on your default drive.  You can create this file with
  541.       any text editor or word processor.
  542.  
  543.       You have some freedom in where you put the configuration file.
  544.       If CHASM.CFG is not found in the current directory, CHASM will
  545.       also try the following paths:
  546.  
  547.             \CHASM\CHASM.CFG
  548.             \CHASM.CFG
  549.  
  550.       The file should contain a series of text "switches" of the
  551.       following form:
  552.  
  553.       /SWITCH, xx [, yy, zz,...]
  554.  
  555.       Where "/SWITCH" is a reserved word, listed below, and xx, yy, zz
  556.       are numbers.  The brackets around yy and zz indicate that these
  557.       numbers are optional - don't put brackets in CHASM.CFG.
  558.  
  559.       Each switch should start a new line, and the switch and each of
  560.       the numbers should separated by one or more blanks or commas.
  561.  
  562.       The following switches are implemented:
  563.  
  564.       /132        Printer 132 column mode.  The numbers following this
  565.                   switch are the ASCII codes for the characters which
  566.                   cause your printer to go into condensed mode.  You
  567.                   may specify as many characters as you like.  If you
  568.                   don't provide this switch, CHASM will truncate source
  569.                   lines in listings to avoid going over 80 columns. You
  570.                   can also include characters to activate any special
  571.                   features of your printer you want CHASM to use during
  572.                   printing.  Example: (for IBM printer)
  573.  
  574.                   /132, 15
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.                                                                       7
  597.  
  598.       /80         Printer 80 column mode.  Similar to /132, but the
  599.                   numbers represent the characters to return your
  600.                   printer to normal.  Include the codes for any
  601.                   characters you want CHASM to send to your printer
  602.                   before returning you to DOS.  The following example
  603.                   turns off condensed mode and causes a Form Feed on
  604.                   the IBM printer:
  605.  
  606.                   /80, 18, 12
  607.  
  608.       /FF         Formfeed.  A value of zero tells CHASM that your
  609.                   printer doesn't recognize ASCII 12 as a formfeed
  610.                   command.  Any other value, and CHASM assumes that
  611.                   formfeeds will be recognized.  The default is no
  612.                   formfeed character.
  613.  
  614.                   If /FF is off, CHASM will simulate formfeeds with a
  615.                   series of linefeeds.  However, most printers respond
  616.                   quicker to a formfeed than to multiple line feeds, so
  617.                   set /FF on if possible.  Example: (on)
  618.  
  619.                   /FF, 1
  620.  
  621.       /PAGELEN    CHASM assumes that there are 66 lines to each printed
  622.                   page.  If you use different sized paper, enter the
  623.                   number of lines per page after this switch.
  624.                   Example: (European standard)
  625.  
  626.                   /PAGELEN, 72
  627.  
  628.       /LINES      By default, CHASM will print 58 lines on each printed
  629.                   page, then skip over the perforation to the next
  630.                   page.  You can change this number to suit your paper
  631.                   and personal taste.  Example:
  632.  
  633.                   /LINES, 50
  634.  
  635.       /BEEP       Enables/Disables audible warning when errors are
  636.                   discovered in your source program.  A value of zero
  637.                   turns off beeping, anything else turns it on. The
  638.                   default is on.  Example: (off)
  639.  
  640.                   /BEEP, 0
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.                                                                       8
  663.  
  664.       /FG         Foreground color.  Users with color monitors may
  665.                   select a foreground color from the following list:
  666.  
  667.                   0    Black               8    Gray
  668.                   1    Blue                9    Light Blue
  669.                   2    Green              10    Light Green
  670.                   3    Cyan               11    Light Cyan
  671.                   4    Red                12    Light Red
  672.                   5    Magenta            13    Light Magenta
  673.                   6    Brown              14    Yellow
  674.                   7    White              15    High Intensity White
  675.  
  676.                   Example: (Magenta)
  677.  
  678.                   /FG, 5
  679.  
  680.       /BG         Background color.  Selections 0-7 above are
  681.                   available. Example: (Cyan)
  682.  
  683.                   /BG, 3
  684.  
  685.        /DWIDTH    When listing to a disk file, CHASM normally truncates
  686.                   listing lines to 80 columns to prevent wrap-around
  687.                   when viewing the file.  In some instances, such as
  688.                   disk-based print spooling with DOS's PRINT utility,
  689.                   you may wish to override this truncation.  You can
  690.                   enter a new truncation limit after this switch. 
  691.                   Example: (128 column lines)
  692.  
  693.                   /DWIDTH, 128
  694.  
  695.         /PATH     Path Stratagy.  Affects the way CHASM constructs the
  696.                   default file names for list and object files.  If
  697.                   /PATH is set to 0 (the default), any drive or path
  698.                   specified on the source file name will be included in
  699.                   the default file names.  If /PATH is set to anything
  700.                   else, path and drive info are removed, thus putting
  701.                   the default list and object files in the current
  702.                   directory of the logged drive.  The following table
  703.                   shows how this works:
  704.  
  705.                   /PATH | Source filename   | Default object file
  706.                   ------|-------------------|-------------------------
  707.                      0  | a:\chasm\test.asm |   a:\chasm\test.com
  708.                      1  | a:\chasm\test.asm |   test.com
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.                                                                       9
  729.  
  730.  
  731.                   /PATH only affects how the default file names are
  732.                   constructed - CHASM won't edit filenames that you
  733.                   explicitly type in.
  734.  
  735.        /TIMER     Enables/Disables reporting of total assembly time. A
  736.                   value of 0 turns off timing, anything else turns it
  737.                   on.  The default is off.  This switch is used
  738.                   internally at Whitman Software to benchmark new
  739.                   versions of CHASM.
  740.  
  741.       A sample CHASM.CFG file, suitable for use with the IBM dot matrix
  742.       printer, is included on your CHASM distribution disk.
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.                                                                      10
  795.  
  796.       >>Syntax<<
  797.  
  798.       CHASM accepts a standard DOS text file for input.  Lines may be
  799.       any combination of upper and lower case characters.  CHASM does
  800.       not distinguish between the two cases: everything except single
  801.       quoted strings are automatically converted to upper case during
  802.       the parsing process.  Thus, BUFFER, Buffer, buffer, and bUFFer
  803.       all refer to the same symbol.
  804.  
  805.       The characters  blank ( ), comma (,), single quote (')
  806.       semi-colon (;) and TAB are reserved, and have special meaning to
  807.       CHASM (see below).
  808.  
  809.       Each line must be no more than 80 characters long and have the
  810.       following format:
  811.  
  812.          Label Operation Operand(s) ;comment
  813.  
  814.       The different fields of an input line are separated by the
  815.       delimiters blank ( ), comma (,) or TAB.  Any number of any
  816.       delimiter may be used to separate fields.
  817.  
  818.       Explanation of Fields:
  819.  
  820.       Label: A label is a string of characters, beginning in column 1.
  821.          Depending on the operation field, the label might represent a
  822.          program location for branching, a memory location, or a
  823.          numeric constant (see the section titled "Labels" for more on
  824.          this topic). To ensure that CHASM can distinguish between
  825.          labels and numeric constants, the first character of a label
  826.          must *not* be a number (0-9), plus sign (+) or minus sign(-).
  827.          Anything beginning in column 1, except a comment, is
  828.          considered a label.
  829.  
  830.       Operation: Either a pseudo-op (see the section with the same
  831.          name) or an instruction mnemonic as defined in "The 8086
  832.          Book" by Rector and Alexy.  A list of acceptable mnemonics is
  833.          given in Appendix A.
  834.  
  835.          Note 1: Except as modified below,"The 8086 Book" is the
  836.             definitive reference for use with CHASM.
  837.  
  838.          Note 2: There are several ways to resolve some ambiguities in
  839.             8086 assembly language.  Please read page 3-285 of The 8086
  840.             Book, and "Resolution of Ambiguities" in this document.
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.                                                                      11
  861.  
  862.  
  863.       Operand(s): A list of one or more operands, as defined in
  864.          the section titled "Operands", separated by delimiters.
  865.  
  866.       Comment: Any string of characters, beginning with a semicolon
  867.          (;). Anything to the right of a semicolon will be ignored by
  868.          CHASM.
  869.  
  870.       Note that except for the case of an operation which requires
  871.       operands, or the EQU pseudo-op which requires a label, all of the
  872.       fields are optional.  The fields MUST appear in the order shown.
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.                                                                      12
  927.  
  928.       >>Labels<<
  929.  
  930.       The symbol in the label field of an input line can be interpreted
  931.       in four different ways by CHASM:
  932.  
  933.         1. A program location which may be branched to.
  934.  
  935.         2. A memory location for data storage.
  936.  
  937.         3. An equated symbol, which takes the place of a numeric
  938.            constant.
  939.  
  940.         4. A macro name, which takes the place of a series of
  941.            frequently used source code lines.
  942.  
  943.       The default interpretation of a symbol is a program location for
  944.       branching.  This default is modified by the presence of one of
  945.       the following pseudo-ops in the instruction field:
  946.  
  947.       DB, DM, DS, or DW:
  948.  
  949.             Normal:  The symbol is a memory location.
  950.  
  951.             In a Structure: The symbol is a numeric constant.
  952.  
  953.       EQU:
  954.  
  955.             Normal:  The symbol is a numeric constant.
  956.  
  957.             Memory Option:  The symbol is a memory location.
  958.  
  959.       MACRO: 
  960.            The symbol is a macro name.
  961.  
  962.       A given symbol may have only ONE of the above interpretations!
  963.       Attempts to branch into a memory location or an equated symbol
  964.       will result in error messages.  Similarly, CHASM will not allow
  965.       you to treat program code as a data area.  Examples:
  966.  
  967.       TEXT DB  'Hit any key when ready'  ;memory location
  968.            MOV  AL,TEXT                  ;ok
  969.            JMP  TEXT                     ;wrong!
  970.       LOOP MOV  AX,CX                    ;program location
  971.            JMP  LOOP                     ;ok
  972.            MOV  AX, LOOP                 ;wrong!
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.                                                                      13
  993.  
  994.  
  995.       If for some arcane reason you *need* to branch into a data area,
  996.       you can fool CHASM by placing a label on an otherwise blank line,
  997.       immediately before the data area.  Example:
  998.  
  999.             JNZ NPU
  1000.             RET
  1001.       NPU                                ;dummy label for jump
  1002.             DB  D8H, 00H                 ;an 8087 instruction
  1003.  
  1004.       If you have a masochistic urge to crash your system by writing
  1005.       self-modifying code, there are at least two ways you can defeat
  1006.       CHASM's injunction against using program code as a data area.
  1007.  
  1008.       The first way is to use DS to declare zero bytes of storage
  1009.       immediately before the code you want to access.  A label on the
  1010.       null DS will have the same offset as the immediately following
  1011.       code.  Example:
  1012.  
  1013.              MOV   JUNK1, 9090         ;change endless loop to NOP
  1014.       JUNK1  DS    0
  1015.       JUNK   JMP  JUNK
  1016.  
  1017.       A sneakier approach is to load the OFFSET of a program
  1018.       location into a register, then use the register for indirect
  1019.       addressing. Using the optional displacement field, you can even
  1020.       address the middle of an instruction.  Examples:
  1021.  
  1022.              MOV   BX, OFFSET(CALL)
  1023.              MOVB  1[BX], 00H          ;change interrupt number in code
  1024.       CALL   INT   0
  1025.  
  1026.       In general, I cannot recommend trying to get around CHASM's type
  1027.       restrictions.  If you find yourself in a situation where it
  1028.       seems necessary to fool CHASM, there's probably a safer, more
  1029.       direct way to legally program what you're trying to accomplish.
  1030.  
  1031.       Labels can be up to 80 characters long, but only the first 15
  1032.       characters are significant.  For example, CHASM considers the
  1033.       following labels identical:
  1034.  
  1035.          VERYLONGLABELOVER15CHARACTERS
  1036.          VERYLONGLABELOVER
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.                                                                      14
  1059.  
  1060.       To avoid ambiguity, a given string can legally appear in the
  1061.       label field of only ONE statement.  If the same string appears on
  1062.       more than one instruction, all instances after the first will
  1063.       receive an error message.  Remember that labels are only
  1064.       significant to 15 characters, and if the first 15 characters are
  1065.       identical, an error will occur.
  1066.  
  1067.       TWO   EQU  '2'      ;first use is ok
  1068.       TWO   PROC FAR      ;wrong! symbol already defined
  1069.  
  1070.       CHASM has a number of reserved strings which are "predefined" in
  1071.       the symbol table, and will generate an error message if used as
  1072.       labels.  All the two letter register names are reserved, as are
  1073.       the indirect address mode combinations.  The only other reserved
  1074.       strings are the words "NEAR" and "FAR", and the symbol "$".
  1075.       Examples:
  1076.  
  1077.       AX   MOV  AX, DX      ;wrong! (register name)
  1078.       [DI] ADD  AX, BX      ;wrong! (indirect address)
  1079.       FAR  CALL GETINPUT    ;wrong! (reserved word)
  1080.       $    SUB  AX, DX      ;wrong! (reserved word)
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.                                                                      15
  1125.  
  1126.       >>Operands<<
  1127.  
  1128.       The following operand types are allowed.
  1129.  
  1130.       1. Immediate data: A number, stored as part of the program's
  1131.          object code.  Immediate data are classified as either byte,
  1132.          expressible as an 8 bit binary integer; or word, expressible
  1133.          as a 16 bit binary integer.  If context requires it, CHASM
  1134.          will left-pad byte values with zeroes to convert them to word
  1135.          values.  Attempts to use a word value where only a byte will
  1136.          fit will cause an error message to be printed.
  1137.  
  1138.          Immediate data may be represented in 9 ways:
  1139.  
  1140.             A. An optionally signed decimal number in the range -32768
  1141.                to 32767.  Examples:
  1142.  
  1143.                MOV AL,21
  1144.                MOV BX,-6300
  1145.  
  1146.             B. A series of up to 4 hex digits, followed by the letter
  1147.                H.  The first digit must be non-alphabetic, i.e. in the
  1148.                range 0-9, to allow CHASM to distinguish between numbers
  1149.                and symbols. If necessary, a leading zero, which does
  1150.                not count in the four allowed digits, may be added to
  1151.                fulfill the non-alphabetic condition. Examples:
  1152.  
  1153.                ADD CX, 0B123H
  1154.                ADD DL, 12H
  1155.  
  1156.            C.  A series of up to 16 binary digits, followed by the
  1157.                letter B.  Examples:
  1158.  
  1159.                MASK   EQU   00000111B
  1160.                       MOV   AL, 10000000B
  1161.  
  1162.  
  1163.             D. A symbol representing types A, B or C above,
  1164.                defined using the EQU pseudo-op.  Examples:
  1165.  
  1166.                MASK EQU 10H
  1167.                MAX  EQU 1000
  1168.                     AND  CL,MASK
  1169.                     SUB  AX,MAX
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.                                                                      16
  1191.  
  1192.             E. The offset of a label or storage location returned by
  1193.                the OFFSET operator.  OFFSET always returns a word
  1194.                value. OFFSET is used to get the address of a named
  1195.                memory location, rather than its contents.  Example:
  1196.  
  1197.                       MOV DI,OFFSET(BUFFER)
  1198.                BUFFER DS  0FFH
  1199.  
  1200.             F. The ASCII value of a printable character, represented by
  1201.                the character enclosed in single quotes (').  Thus, the
  1202.                following lines will generate the same object code:
  1203.  
  1204.                   MOV AL,41H  ;ascii code for 'A'
  1205.                   MOV AL,'A'
  1206.  
  1207.             G. ==>Advanced version only:
  1208.                Labels within structures become immediate operands whose
  1209.                values equal their offset within the structure.  See the
  1210.                section titled "Structures" for more detail and
  1211.                examples.
  1212.  
  1213.             H. ==>Advanced version only:
  1214.                The length of a structure, returned either by the LENGTH
  1215.                operator, or simply the structure's name.  See the
  1216.                section titled "Structures" for more detail and
  1217.                examples.
  1218.  
  1219.             I. The number of bytes counted by the COUNT pseudo-op,
  1220.                returned by the LENGTH operator on the COUNT's label.
  1221.                Example:
  1222.  
  1223.                HLP_MSG   COUNT
  1224.                HLP_TXT   DB 'Hit F10 for Help...' cr lf
  1225.                          ENDC
  1226.                          MOV CX, LENGTH(HLP_MSG)  ;length of message
  1227.  
  1228.             J. ==>Advanced version only:
  1229.                An expression that evaluates out to type Immediate.
  1230.                Examples:
  1231.  
  1232.                       MOV AX, (3+2)*5 
  1233.                       MOV DX, MEMLOC1-MEMLOC2
  1234.  
  1235.                See the "Operand Expressions" section for more details.
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.                                                                      17
  1257.  
  1258.       2. Register Operands: One of the 8088's internal registers.
  1259.  
  1260.          A. An 8 bit register from the following list:
  1261.             AH    AL
  1262.             BH    BL
  1263.             CH    CL
  1264.             DH    DL
  1265.  
  1266.          B. A 16 bit register from the following list:
  1267.             AX   BX   CX   DX   SP   BP   SI   DI
  1268.  
  1269.          C. A segment register from the following list:
  1270.             CS   SS   DS   ES
  1271.  
  1272.       3. Memory Operands: The contents of a memory location addressed
  1273.          by one of the following methods.  Note that none of the memory
  1274.          addressing options specifies whether a byte or word operand
  1275.          is being referenced.  See the section titled "Resolution of
  1276.          Ambiguities" for more on this topic.
  1277.  
  1278.          All memory operands can optionally be proceded with a segment
  1279.          overide to specify the segment register to be used in
  1280.          accessing memory.  The overide takes the form of a segment
  1281.          register, followed by a colon, followed by the memory operand.
  1282.          No intervening delimiters are allowed.  Examples:
  1283.  
  1284.               MOV AX, ES:[80H]    ;80H into the extra segment
  1285.               MOV CS:[DI], SI     ;indirect with DI in the code segment
  1286.  
  1287.          Segment overides are also discussed in the section titled
  1288.          "Resolution of Ambiguities".
  1289.  
  1290.          A. Direct address.
  1291.  
  1292.             1. A number, or other immediate operand, enclosed in
  1293.                brackets, indicating an offset into the data segment.
  1294.                Example:
  1295.  
  1296.                BUFFER EQU 5A5AH
  1297.                       MOV BH,[BUFFER]
  1298.                       MOV [80H],DI
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.                                                                      18
  1323.  
  1324.             2. A symbol, defined to be a variable (i.e. a named memory
  1325.                location) using the EQU pseudo-op.  Example:
  1326.  
  1327.                FCB EQU [80H]
  1328.                    MOV DI,FCB
  1329.  
  1330.             3. A symbol, defined to be a variable by its use on a
  1331.                storage defining pseudo-op.  Examples:
  1332.  
  1333.                     MOV AX,FLAG
  1334.                     MOV DATE,BX
  1335.                FLAG DS 1
  1336.                DATE DB 31
  1337.  
  1338.             4. The special symbol '$'.  $ returns an address of value
  1339.                equal to the current setting of CHASM's location
  1340.                counter.  This address can be used as either a memory
  1341.                location, or a program location for branching.  Used by
  1342.                itself, $ has little utility, but it is a very powerful
  1343.                tool when used in expressions.  Example:
  1344.  
  1345.                     MOV AX, $+4    ;get the byte after this instruction
  1346.  
  1347.             5. ===> Advanced version only:
  1348.                An expression that evaluates out to type address.
  1349.                Example:
  1350.  
  1351.                       MOV AX, buffer+3
  1352.                BUFFER DS 20
  1353.  
  1354.                See the "Operand Expressions" section for more details.
  1355.  
  1356.          B. Indirect Address:  The address of the operand is the
  1357.             sum of the contents of the indicated register(s) and a
  1358.             displacement.  The register, or sum of registers, are
  1359.             enclosed in square brackets: []
  1360.  
  1361.             The displacement is optional, and takes the form of an
  1362.             immediate operand, placed without intervening delimiters to
  1363.             the left of the first bracket.
  1364.  
  1365.             Immediate data written as decimal numbers, with values
  1366.             between 127 and -128 generate a signed 8 bit offset.
  1367.             Values outside this range, or those expressed in some
  1368.             other manner generate 16 bit offsets.
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.                                                                      19
  1389.  
  1390.  
  1391.             The following indirect modes are provided:
  1392.  
  1393.             1. Indirect through a base register (BX or BP).  Examples:
  1394.  
  1395.                ENTRYLENGTH EQU 6
  1396.                            MOV AX, ENTRYLENGTH[BP]
  1397.                            MOV DL, -2[BX]
  1398.                            MOV CX, [BP]
  1399.                            MOV 9A9AH[BX], AX
  1400.  
  1401.             2. Indirect through an index register (DI or SI).
  1402.                Examples:
  1403.  
  1404.                MOV [DI], CX
  1405.                MOV CX, -5[SI]
  1406.  
  1407.             3. Indirect through the sum of one base register and one
  1408.                index register.  Examples:
  1409.  
  1410.                MOV [BP+DI], SP      ;note that no spaces are
  1411.                MOV BX, 10H[BX+SI]   ;allowed within the
  1412.                MOV CL, [BP+SI]      ;brackets.
  1413.                MOV DH, -2[BX+DI]
  1414.  
  1415.       4. Labels
  1416.  
  1417.          A label on most instructions may be used as an operand for
  1418.          call and jump instructions.  See the section titled "Labels"
  1419.          for more information.  Examples:
  1420.  
  1421.          START    PROC NEAR
  1422.                   CALL GETINPUT
  1423.                   JMPS START
  1424.                   ENDP
  1425.          GETINPUT PROC NEAR
  1426.  
  1427.       5. Strings
  1428.  
  1429.          A string is any sequence of characters (including delimiters)
  1430.          surrounded by single quotes (').  Example:
  1431.  
  1432.          DB 'Copyright May 15,1982'
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.                                                                      20
  1455.  
  1456.       >>Operand Expressions<<
  1457.  
  1458.       ===> Advanced version only.
  1459.  
  1460.       Advanced CHASM can perform arithmetic calculations at assemble
  1461.       time, to help you generate memory addresses and immediate data
  1462.       constants.
  1463.  
  1464.       The following operand types can participate in operand
  1465.       expressions: 
  1466.  
  1467.            immediate data
  1468.            program locations
  1469.            data storage locations
  1470.  
  1471.       Actually, for the purpose of expression evaluation, CHASM treats
  1472.       both program locations and data storage locations identically.
  1473.       Thus, really only two types of operands are allowed in
  1474.       expressions: immediate and address.
  1475.  
  1476.       Symbols standing for immediate operands must have been defined
  1477.       prior to use in an expression, or you may get Phase Errors (see
  1478.       the error message section for a discussion on this topic).  You
  1479.       should put all your EQU and STRUC pseudo-ops at the beginning of
  1480.       your program, before any machine instructions.
  1481.  
  1482.       The following arithmetic operators are available:
  1483.  
  1484.            +  addition
  1485.            -  subtraction
  1486.            *  multiplication
  1487.            /  integer division
  1488.  
  1489.       Note that / performs *integer* division.  5/2 evaluates to 2.
  1490.  
  1491.       The normal rules of precedence apply.  To force evaluation
  1492.       contrary to normal precedence, you can use parenthesis: ().
  1493.  
  1494.            MOV AX  2+5*3   ;means mov ax, 17 because * outranks +
  1495.            MOV AX, (2+5)*3 ;means mov ax, 21
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.                                                                      21
  1521.  
  1522.       No delimiters can appear within an expression.  If you separate
  1523.       the parts of an expression with delimiters, CHASM will try to
  1524.       interpret each part as a separate operand.
  1525.  
  1526.            MOV [BX], BUFFER + 3    ;WRONG!!
  1527.            MOV [BX], BUFFER+3      ;ok
  1528.  
  1529.       The type of an operand expression is determined by the individual
  1530.       operand types that are combined within it.  In evaluating each
  1531.       operation in an expression, the result type follows this rule:
  1532.  
  1533.            If the two operand types are the same, the result type is
  1534.            IMMEDIATE.
  1535.  
  1536.            If the two operand types are different, the result type is
  1537.            an ADDRESS.
  1538.  
  1539.       In expressions, both program locations and data storage locations
  1540.       are considered identical.  An expression which evaluates to type
  1541.       address can be used in either a MOV or a JMP.
  1542.  
  1543.       The result type of a complicated expression is determined by
  1544.       replacing individual binary operations with their result, and
  1545.       evaluating the (simpler) expression thus formed, following the
  1546.       above rules.
  1547.  
  1548.       Here's a program fragment with some expressions, and a discussion
  1549.       of their types and significance:
  1550.  
  1551.       EXPSAMPLE PROC  NEAR
  1552.                 MOV   AX, 3+5         ;immediate, calculated value
  1553.                 MOV   DX, STRING-END  ;immediate, length of string
  1554.                 MOV   STRING+5, 'A'   ;address, third byte of string
  1555.                 JMP   EXPSAMPLE+100H  ;address, used as program loc.
  1556.                 JMP   STRING+100H     ;valid address syntax, but silly
  1557.       STRING    DB    'MESSaGE'       ;data area
  1558.       END                             ;marks position of end of string
  1559.  
  1560.  
  1561.       The special symbol '$' returns the current value of CHASM's
  1562.       location counter for use in expressions.  $ is of type address.
  1563.       Thus, $-1 is the address of the byte immediately prior to the
  1564.       instruction currently being assembled.
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.                                                                      22
  1587.  
  1588.       The rules for typing expressions were set up to produce the
  1589.       "most useful" result type, taking a guess as to why one would
  1590.       want to do a given calculation.  If the type isn't what you have
  1591.       in mind, you can coerce CHASM using square brackets or the
  1592.       OFFSET function:
  1593.  
  1594.             MOV AX, 3+5              ;immediate
  1595.             MOV AX, [3+5]            ;coerced to address
  1596.             MOV DX, $+4              ;address
  1597.             MOV DX, OFFSET($+4)      ;coerced to immediate
  1598.  
  1599.       Under certain circumstances, CHASM can get confused when you use
  1600.       OFFSET or LENGTH functions in expressions.  The problem occurs if
  1601.       the expression starts with a function, and ends with a close
  1602.       parenthesis:
  1603.  
  1604.             MOV AX, OFFSET(BUFFER)*(3+2)    ;will be misinterpreted
  1605.  
  1606.       CHASM will try to interpret this as the offset of "BUFFER)*(3+2",
  1607.       and you'll get the error message "Illegal or undefined argument
  1608.       for OFFSET".  The solution is to enclose the whole works in
  1609.       parenthesis, to force CHASM to recognise it as an expression:
  1610.  
  1611.             MOV AX, (OFFSET(BUFFER)*(3+2))  ;correct
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.                                                                      23
  1653.  
  1654.       >>Resolution of Ambiguities<<
  1655.  
  1656.       The language defined in "The 8086 Book" contains a number of
  1657.       ambiguities which must be resolved by an assembler.  This is
  1658.       discussed throughout the book, but pages 3-285 and 3-286
  1659.       specifically cover this topic.  CHASM's solutions of these
  1660.       problems are discussed in this section.
  1661.  
  1662.       A. Memory references:
  1663.  
  1664.       When one specifies the address of a memory location, it is
  1665.       unclear how large an operand is being referenced.  An operand
  1666.       might be a byte, or a word.
  1667.  
  1668.          1. If a register is present as an operand, it is assumed that
  1669.             the memory operand matches the register in size.  An
  1670.             exception to this rule are the shift and rotate
  1671.             instructions, where the CL register is used as a counter,
  1672.             and has nothing to do with the size of the other operand.
  1673.             Examples:
  1674.  
  1675.             MOV MASK,AX   ;mask is a word
  1676.             MOV DH,[BX]   ;BX points to a byte
  1677.             NEG [SI]      ;error, operand of unknown size
  1678.             SHR FLAG,CL   ;error, flag is of unknown size
  1679.  
  1680.          2. If no register is present, (or if the only register is CL
  1681.             being used as a counter) the size of the memory operand is
  1682.             specified by adding the suffix "B" or "W" to the
  1683.             instruction mnemonic.  Examples:
  1684.  
  1685.             NEGB [SI]       ;SI points to a byte
  1686.             SHRW FLAG,CL    ;flag is a word
  1687.             MOVW MASK,0AH   ;mask is a word
  1688.             MOVB MASK,0AH   ;mask is a byte
  1689.             MOVW MASK,9A9AH ;must specify size even though
  1690.                             ;immediate operand implies word
  1691.             MOVB DH,[BX]    ;error(!), register already
  1692.                             ;specifies size
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.                                                                      24
  1719.  
  1720.       B. Indirect Branching.
  1721.  
  1722.       The 8088 supports two flavors of indirect branching: intra, and
  1723.       intersegment.  A register is set to point at a memory location
  1724.       which contains a new value for the program counter, and in the
  1725.       case of intersegment branching, a new value for the CS register
  1726.       as well.
  1727.  
  1728.       The syntax of "The 8086 Book" does not specify which flavor of
  1729.       branch is being invoked.  CHASM adds the suffixes "N" (for near,
  1730.       or intrasegment) and "F" (for far, or intersegment) to the
  1731.       indirect CALL and JMP mnemonics.  Examples:
  1732.  
  1733.          CALLN [BX]    ;intrasegment call
  1734.          JMPF  [DI]    ;intersegment jump
  1735.          JMP   [BP]    ;error, unspecified flavor
  1736.  
  1737.       C. Long and Short Jumps
  1738.  
  1739.       Two types of relative jumps are supported by the 8088: short
  1740.       (specified by a signed 8 bit displacement) and long (specified by
  1741.       a 16 bit displacement).  Both are implemented in CHASM as a jump
  1742.       to a label.
  1743.  
  1744.       The short jump is specified by mnemonic JMPS, in accord with the
  1745.       IBM disassembler, but not with The 8086 Book, which uses JMP.
  1746.       Since one of the displacement bits is used to indicate direction,
  1747.       only seven are left to express the magnitude of jump.  JMPS (and
  1748.       similarly, all the jump on condition instructions) is thus
  1749.       limited to branching to labels within a range of -128 to +127
  1750.       bytes.
  1751.  
  1752.       CHASM reserves mnemonic JMP for the long jump.  JMP may be used
  1753.       to jump anywhere within the program segment, but the object code
  1754.       generated is less compact than that from JMPS.
  1755.  
  1756.       Examples:
  1757.  
  1758.          START PROC NEAR
  1759.                JMPS END     ;short jump
  1760.                JMP  START   ;long jump
  1761.          END   ENDP
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.                                                                      25
  1785.  
  1786.       D. Instruction Prefixes.
  1787.  
  1788.       The 8088 supports three instruction prefixes:
  1789.  
  1790.          1. SEG: segment override. An alternate segment register is
  1791.             specified for a reference to memory
  1792.  
  1793.          2. REP, REPE,REPNE,REPZ,REPNZ: repeat. A string primitive is
  1794.             repeated until a condition is met.
  1795.  
  1796.          3. LOCK: Turns on the LOCK signal. Only useful in
  1797.             multi-processor situations.
  1798.  
  1799.       SEG is implemented as a modifier attached to a memory operand.
  1800.       If you want to overide the default segment register for a memory
  1801.       access, precede the memory operand with the segment register
  1802.       followed by a colon.  Examples:
  1803.  
  1804.          MOV AX, ES:FLAG     ;flag is in the extra segment
  1805.          MOV CS:[100H], DX   ;offset 100H in the code segment
  1806.  
  1807.       The other prefixes are implemented as separate instructions. They
  1808.       appear on a separate line, immediately before the instruction
  1809.       which they modify.  For compatability with earlier versions of
  1810.       CHASM, you can also specify segment overides on a separate line,
  1811.       using the mnemonic SEG. Examples:
  1812.  
  1813.          REP
  1814.          MOVSB           ;move bytes until CX decremented to 0
  1815.          SEG SS
  1816.          MOV AX,BUFFER   ;buffer is in the stack segment
  1817.          LOCK
  1818.          MOV [8FFH], AX  ;lock bus to ensure data is transferred
  1819.                          ;before other processors try to access it
  1820.  
  1821.       Note for 8087 users:  You may get unexpected results using the
  1822.          separate instruction form of SEG on 8087 instructions.  Use
  1823.          the operand modifier form for segment overides on 8087
  1824.          instructions.
  1825.  
  1826.       (CHASM version 4.01 will have 8087 support)
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.                                                                      26
  1851.  
  1852.       >>Pseudo-Operations<<
  1853.  
  1854.       The following pseudo-ops are implemented:
  1855.  
  1856.       A. BSAVE: Generate object code in BSAVE format.
  1857.  
  1858.          Instructs CHASM to build a header in the format of BASIC's
  1859.          BSAVE command.  The resulting object code file may be BLOADed
  1860.          by BASIC programs.  No operands are required, and the
  1861.          pseudo-op may appear anywhere within the source code.
  1862.          Example: 
  1863.  
  1864.                ORG    0     ;no psp
  1865.          SUBRT PROC   FAR   ;subroutine for BASIC program
  1866.                BSAVE        ;make BLOADable object file
  1867.  
  1868.       B. COUNT ...ENDC:  Count bytes.
  1869.  
  1870.          Instructs CHASM to count the number of object code bytes
  1871.          generated between COUNT and ENDC.  Both machine instructions
  1872.          and pseudo-ops can appear within the COUNT block. If a label
  1873.          appears on the COUNT, it becomes an immediate operand of value
  1874.          equal to the number of bytes counted.  Neither COUNT or ENDC
  1875.          require any operands.  COUNTs cannot be nested.
  1876.  
  1877.          (COUNT and ENDC are supported mainly for compatibility for
  1878.          earlier releases.  Now that expressions are available, you can
  1879.          get exactly the same result by subtracting two labels, one on
  1880.          either side of the area to be COUNTed.)
  1881.  
  1882.          It is *strongly* recommended that the immediate operands
  1883.          generated by COUNT be accessed via the LENGTH function, which
  1884.          unambiguously forces the "immediate" type on CHASM's first
  1885.          pass.  If you do not use the LENGTH function, forward
  1886.          references to a COUNT may cause phase errors.  (See Phase
  1887.          Error in the Error Message section.)
  1888.  
  1889.          Example: (next page)
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.                                                                      27
  1917.  
  1918.          MESSAGE    COUNT
  1919.          MSG_TXT    DB   'This utility requires DOS 2.0!' beep cr lf
  1920.                     ENDC
  1921.  
  1922.                     MOV SI, OFFSET(MSG_TXT)
  1923.                     MOV DI, OFFSET(BUFFER)
  1924.                     MOV CX, LENGTH(MESSAGE)
  1925.                     REP
  1926.                     MOVSB                   ;move message into buffer
  1927.  
  1928.       C. DB: Declare Bytes
  1929.  
  1930.          Memory locations are filled with values from the operand list.
  1931.          Any number of operands may appear, but all must fit on one
  1932.          line. Acceptable operands are immediate data, or strings
  1933.          enclosed in single quotes (').  DB interprets strings as a
  1934.          series of ASCII bytes.
  1935.  
  1936.          If a label appears, it is redefined as a memory location, and
  1937.          the data area may be referred to using the label, rather than
  1938.          an address. Examples:
  1939.  
  1940.                MOV AX,MASK
  1941.          MASK  DB  00H,01H
  1942.          STG   DB  'A string operand'
  1943.  
  1944.          CHASM generates an error message ("Data too large") if word
  1945.          operands (such as OFFSETs, or numbers greater than 255) are
  1946.          found in the DB operand list. DW should be used for declaring
  1947.          words.
  1948.  
  1949.       D. DM: Declare Multiple Bytes
  1950.  
  1951.          Used to declare blocks of storage, the number of bytes
  1952.          declared being the product of two immediate operands.  If only
  1953.          one operand is present, the other operand is assumed to equal
  1954.          one.
  1955.  
  1956.          (DM is supported mainly for compatibility with earlier
  1957.          releases.  Now that expressions are available, you can
  1958.          accomplish the thing by using DS with an expression for the
  1959.          immediate operand.)
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.                                                                      28
  1983.  
  1984.          As with DB, any label is redefined as a memory location.  To
  1985.          save space, the object code does not appear on the listing.
  1986.          It is anticipated that this pseudo-op will be used in
  1987.          conjunction with STRUC, to declare structured storage.
  1988.          Example:
  1989.  
  1990.             DM  LENGTH(MAILIST) 500   ;mailing list with 500 entries
  1991.  
  1992.       E. DS: Declare Storage
  1993.  
  1994.          Used to declare large blocks of identically initialized
  1995.          storage.  The first operand is required, a number specifying
  1996.          how many bytes are declared.  If a second operand in the form
  1997.          of a number 0-FFH appears, the locations will all be
  1998.          initialized to this value.  If the second operand is not
  1999.          present, locations are initialized to 0.   As with DB, any
  2000.          label is redefined as a memory location.  To save space, the
  2001.          object code does not appear on the listing.  Examples:
  2002.  
  2003.             DS 10         ;10 locs initialized to 0
  2004.             DS 100H,1AH   ;256 locs initialized to 1AH
  2005.  
  2006.       F. DW: Declare Words
  2007.  
  2008.          Used to unambiguously assign a word of storage for each item
  2009.          in the operand list.  Any number of immediate operands may
  2010.          appear, but all must fit on one line.  As with DB, any label
  2011.          is redefined as a memory location. Example:
  2012.  
  2013.              DW 0012H, FFFFH       ;four bytes declared
  2014.  
  2015.       G. EJECT: Begin New Print Page
  2016.  
  2017.          When listing is enabled, causes CHASM to move to the top of
  2018.          the next page in printed listings.  Has no effect on listings
  2019.          sent to the screen or to disk.
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.                                                                      29
  2049.  
  2050.       H. EJECTIF: Conditional Page Break
  2051.  
  2052.          Requires one immediate operand.  If listing is enabled
  2053.          and fewer than that many lines are left on the current page of
  2054.          a printed listing, CHASM will move to the top of the next
  2055.          page.
  2056.  
  2057.          If you put an appropriate EJECTIF at the beginning of each
  2058.          procedure or section of your programs, CHASM will keep them in
  2059.          one piece.  Like EJECT, EJECTIF has no effect on listings to
  2060.          the screen or disk.  Example:
  2061.  
  2062.              EJECTIF 20    ;following procedure is 20 lines long
  2063.  
  2064.       I. ENDC: End of Count
  2065.  
  2066.          See COUNT (above) for details.
  2067.  
  2068.       J. ENDP: End of Procedure
  2069.  
  2070.          See PROC (below) for details.
  2071.  
  2072.       K. ENDSTRUC: End of Structure
  2073.  
  2074.          ==>Advanced version only.  See STRUC (below) for details.
  2075.  
  2076.       L. EQU: Equate
  2077.  
  2078.          Used to equate a symbolic name with a number. The symbol may
  2079.          then be used anywhere the number would be used.  Use of
  2080.          symbols makes programs more understandable, and simplifies
  2081.          modification.
  2082.  
  2083.          An alternate form of EQU encloses the number in square
  2084.          brackets: []. The symbol is then interpreted as a memory
  2085.          location, and may be used as an address for memory access.
  2086.          This version is provided to allow symbolic reference to
  2087.          locations outside the program segment. Examples:
  2088.  
  2089.             MOFFSET    EQU 0B000H
  2090.             MONOCHROME EQU [0000H]
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.                                                                      30
  2115.  
  2116.          Warning: Difficult to debug errors may result from using a
  2117.          ======>  symbol prior to its being defined by EQU.  You are
  2118.                   strongly urged to group all your equates together at
  2119.                   the beginning of programs, before any other
  2120.                   instructions. See "Phase Error" in the Error Message
  2121.                   section.
  2122.  
  2123.       M. IFXX... [ELSE]... ENDIF: Conditional Assembly
  2124.  
  2125.          ===> Advanced version only.
  2126.  
  2127.          CHASM's conditional assembly pseudo-ops can be used to cause
  2128.          macros to expand differently according to the parameters
  2129.          supplied on the invocation.  Eight different IF pseudo-ops are
  2130.          provided, to allow testing for (in)equality, relative size,
  2131.          and (non)existence of parameters.
  2132.  
  2133.          For more details and examples, see the Macro section of this
  2134.          document.
  2135.  
  2136.       N. INCLUDE: Include file
  2137.  
  2138.          ==>Advanced version only.
  2139.  
  2140.          INCLUDE requires one string operand, a filename enclosed in
  2141.          single quotes.  If desired, you can specify a drive and/or a
  2142.          path as part of the filename.
  2143.  
  2144.          The contents of the specified file are logically inserted into
  2145.          the source file at the point where the INCLUDE appears.
  2146.          INCLUDEs cannot be nested: an error message will be printed if
  2147.          the specified file itself contains an INCLUDE.  Example:
  2148.  
  2149.              INCLUDE '\ASM\STDIO.HDR'    ;bring in standard library
  2150.  
  2151.       O. LIST: Enable listing output
  2152.  
  2153.          Output to the list device is enabled, presumably after a
  2154.          NOLIST was encountered.  No operands required.
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.                                                                      31
  2181.  
  2182.       P. MACRO ...ENDM: Macro Definition
  2183.  
  2184.          ==> Advanced version only.
  2185.  
  2186.          Declares a macro.  MACRO requires no operands, and signals
  2187.          CHASM that the following lines constitute a macro definition,
  2188.          and are to be stored for later use, rather than assembled in
  2189.          place.  A label is required on the MACRO statement to name the
  2190.          defined macro.
  2191.  
  2192.          ENDM terminates the macro definition, and requires no
  2193.          operands.
  2194.  
  2195.          For more information and examples, see the section titled
  2196.          "Macros".
  2197.  
  2198.       Q. NOLIST: Disable listing output
  2199.  
  2200.          Normal output to the list device is disabled.  Error messages
  2201.          are listed as usual.  No operands required.
  2202.  
  2203.       R. ORG: Origin
  2204.  
  2205.          Allows direct manipulation of the location counter during
  2206.          assembly.  By default, CHASM assembles code to start at offset
  2207.          100H, thus leaving room for the program segment prefix
  2208.          normally built by COMMAND or DEBUG.  In situations where no
  2209.          PSP is provided, such as routines to be called from BASIC, you
  2210.          should override this default with ORG, or incorrect assembly
  2211.          may result.
  2212.  
  2213.          ORG requires one operand, a number between 0 and FFFFH, which
  2214.          represents the new setting of CHASM's location counter.
  2215.          Although the location counter may be reset anywhere within a
  2216.          program, generally this pseudo-op should be used before any
  2217.          machine executable instructions for meaningful results.
  2218.  
  2219.          Example:
  2220.  
  2221.            ORG 0   ;Code will be assembled for starting
  2222.                    ;offset of 0
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.                                                                      32
  2247.  
  2248.       S. PROC ...ENDP: Procedure Definition
  2249.  
  2250.          Declares a procedure.  One operand is required on PROC, either
  2251.          the word NEAR, or the word FAR.  This pseudo-op warns CHASM
  2252.          whether to assemble returns as intra (near) or intersegment
  2253.          (far).  Procedures called from within the program being
  2254.          assembled should be declared NEAR.  Generally, all others
  2255.          should be FAR.  ENDP terminates the procedure, and requires no
  2256.          operands.  If a RET is encountered outside of a declared
  2257.          procedure, an error occurs.  Procedures may be nested, up to
  2258.          10 deep.  Example:
  2259.  
  2260.          MAIN  PROC  FAR
  2261.                ...
  2262.                ...      ;body of procedure
  2263.                ENDP
  2264.  
  2265.       T. STRUC ...ENDSTRUC: Structure Definition
  2266.  
  2267.          ==> Advanced version only.
  2268.  
  2269.          Declares a structure.  STRUC requires no operands, and signals
  2270.          CHASM that the following lines constitute a structure
  2271.          template, and not actual storage declaration.  If a label
  2272.          appears on the STRUC, the label is equated with the length of
  2273.          the structure.
  2274.  
  2275.          ENDSTRUC terminates the structure definition, and requires no
  2276.          operands.
  2277.  
  2278.          Inside the structure, storage defining pseudo-ops behave
  2279.          somewhat differently.  See the section titled "Structures" for
  2280.          more information. Example:
  2281.  
  2282.              DIRENTRY STRUC      ;disk directory entry
  2283.              NAME     DS    8
  2284.              EXT      DS    3
  2285.              ATRIB    DS    1
  2286.              RESERVED DS   10
  2287.              TIME     DS    2
  2288.              DATE     DS    2
  2289.              START    DS    2
  2290.              SIZE     DS    4
  2291.                       ENDSTRUC
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.                                                                      33
  2313.  
  2314.       >>Macros<<
  2315.  
  2316.       ==>Advanced version only.
  2317.  
  2318.       Macros are an advanced feature.  Beginners may wish to skip this
  2319.       section until they become more experienced with CHASM and
  2320.       assembly language programming.
  2321.  
  2322.       A. Introduction
  2323.  
  2324.          Macros are a shorthand way of writing frequently used
  2325.          sections of code.  Using macros, you can write a code fragment
  2326.          once, then any time you want to use it, just reference it by
  2327.          name.  Once you define a macro and give it a name, anywhere
  2328.          CHASM sees the name will be automatically "expanded" into the
  2329.          previously defined code.
  2330.  
  2331.          For example, suppose you were writing a large program, and at
  2332.          the beginning of each subroutine you pushed all the general
  2333.          purpose registers onto the stack to save their contents.
  2334.          Every subroutine would start out something like this:
  2335.  
  2336.                push ax       ;save register contents
  2337.                push bx
  2338.                push cx
  2339.                push dx
  2340.  
  2341.          Before long, you'd get pretty sick of writing the same thing
  2342.          for each subroutine.  Macros are a way to put some of the
  2343.          boring, repetitive nature of assembly language into the hands
  2344.          of the assembler, freeing you up for the more creative
  2345.          aspects.  Here's how you define a CHASM macro to take the
  2346.          place of this code fragment:
  2347.  
  2348.          savestate  macro
  2349.                     push ax           ;save general purpose registers
  2350.                     push bx
  2351.                     push cx
  2352.                     push dx
  2353.                     endm
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.                                                                      34
  2379.  
  2380.          Note the MACRO and ENDM statements.  These signal to CHASM
  2381.          that the enclosed code is a macro definition to be saved for
  2382.          later use, rather than code to be assembled at this point in
  2383.          your program.  The MACRO statement also gives a name
  2384.          (SAVESTATE) to the macro, which will take the place of the
  2385.          stored code.
  2386.  
  2387.          Now, at the beginning of each subroutine you can just write
  2388.          "SAVESTATE" when you want to push the general purpose
  2389.          registers. Here's an example:
  2390.  
  2391.          get_input  proc  near
  2392.                     savestate
  2393.                     ...
  2394.                     ...
  2395.                     endp
  2396.  
  2397.          Given the previous macro definition, the above example is
  2398.          *exactly* equivalent to:
  2399.  
  2400.          get_input  proc  near
  2401.                     push ax
  2402.                     push bx
  2403.                     push cx
  2404.                     push dx
  2405.                     ...
  2406.                     ...
  2407.                     endp
  2408.  
  2409.          The only difference is that less busy work is required on your
  2410.          part.
  2411.  
  2412.          Macros are NOT subroutines!  Subroutines are coded once, then
  2413.          called within your program at run time.  Macros are expanded
  2414.          in-line at assembly time, and the code is inserted into your
  2415.          program at the invocation point.  If you invoke the macro 20
  2416.          times in your program, you'll end up with 20 copies of the
  2417.          macro code. 
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.                                                                      35
  2445.  
  2446.          Although this does waste some memory space, you save execution
  2447.          time by eliminating the subroutine call and return process.
  2448.          At a minimum, it takes 32 machine cycles to call a subroutine.
  2449.          The four instruction macro given above requires 40 cycles to
  2450.          execute.  If it were coded as a subroutine, the time to
  2451.          execute it would almost *double*.  Macros trade off space for
  2452.          speed.
  2453.  
  2454.       B. Macro Parameters
  2455.  
  2456.          CHASM's macros allow 9 user defined parameters, which are
  2457.          evaluated at expansion time.  The parameters work just like
  2458.          those in DOS batch files.  Here's an example of a macro with
  2459.          one parameter.  PRINT calls DOS function 9 to print a string
  2460.          on the console.  A parameter is used to specify the name of
  2461.          the string to be printed:
  2462.  
  2463.          print    macro
  2464.                   mov  ah, 09H          ;specify print string function
  2465.                   mov  dx, offset(%1)   ;point to string
  2466.                   int  21H              ;call DOS
  2467.                   endm
  2468.  
  2469.          Given this definition, when CHASM sees a line like:
  2470.  
  2471.                print title
  2472.  
  2473.          The following code gets inserted in its place:
  2474.  
  2475.                mov  ah, 09H
  2476.                mov  dx, offset(title)
  2477.                int  21H
  2478.  
  2479.          Note how the "%1" in the macro definition got replaced by
  2480.          "title" which was put as an operand on the invocation of the
  2481.          macro.  You can put up to 9 operands onto a macro invocation,
  2482.          and they will be substituted for the dummy parameters %1
  2483.          through %9.
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.                                                                      36
  2511.  
  2512.          If you put a label on a macro invocation, two things happen.
  2513.          As usual, the label represents a program location for
  2514.          branching, with offset equal to the beginning of the expanded
  2515.          macro.  You can branch into the expanded macro by using the
  2516.          label as an operand on a jump or call instruction.  In
  2517.          addition, if the special dummy parameter "%0" is used in the
  2518.          macro definition, it is replaced with the label text when the
  2519.          macro is expanded.  This feature is provided to facilitate
  2520.          writing loops within macros.
  2521.  
  2522.          If you fail to provide an operand for any dummy parameter used
  2523.          in the macro definition, CHASM substitutes a null string of
  2524.          length zero.  To leave one parameter blank, but provide
  2525.          replacements for parameters with higher numbers, use the
  2526.          special operand "%B" for the one you want blank.  For example:
  2527.  
  2528.               def_mem  macro
  2529.               %1       db  %2, %3
  2530.                        endm
  2531.  
  2532.                        def_mem twobytes, 128, FFH
  2533.                        def_mem %B, 'Hit any key when ready...'
  2534.  
  2535.          Expands to:
  2536.  
  2537.               twobytes  db 128, FFH
  2538.                         db 'Hit any key when ready...'
  2539.  
  2540.       C. Macro Nesting
  2541.  
  2542.          Macro invocations can be nested, up to 10 deep.  Invocations
  2543.          are maintained on a stack, and each invocation has it's own
  2544.          set of parameters.
  2545.  
  2546.          CHASM does not check for recursive macro calls.  If you call a
  2547.          macro from within itself, it's quite possible to get caught in
  2548.          an endless loop.  This can also happen indirectly, where a
  2549.          macro invokes another macro, which ends up calling the first.
  2550.          If you get caught, you can escape by hitting Ctrl-Break.
  2551.  
  2552.          Experienced programmers can use macro recursion, along with
  2553.          expressions and conditional assembly, to create some really
  2554.          elegant macros.  However, this is definitely not for beginners
  2555.          or the faint of heart.  Enter at your own risk.
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.                                                                      37
  2577.  
  2578.       D. Conditional Macro Expansion
  2579.  
  2580.          This advanced feature allows you to write general purpose
  2581.          macros which expand in different ways based on the parameters
  2582.          used on the invocation.
  2583.  
  2584.          For example, suppose you wanted to write a macro to do
  2585.          operating system calls.  Many of the DOS functions just load
  2586.          the function number into AH, then call DOS with an interrupt.
  2587.          Here's a macro to do this:
  2588.  
  2589.          doscall  macro
  2590.                   mov ah, %1
  2591.                   int 21H
  2592.                   endm
  2593.  
  2594.          Given the above definition, "DOSCALL 1" will expand into a
  2595.          call to DOS function #1, keyboard input.
  2596.  
  2597.          Unfortunately, not all DOS calls are quite so simple.  For
  2598.          example, the call for printing a string to the console
  2599.          requires that the offset of the string be loaded into DX.
  2600.          Different system calls are going to require somewhat different
  2601.          handling.  One approach would be to write separate macros for
  2602.          each function.  However, with 87 different functions in DOS 2,
  2603.          this starts to get unwieldy.
  2604.  
  2605.          A more general approach is to incorporate some "intelligence"
  2606.          into the macro, and let it expand differently for different
  2607.          DOS functions.  Here's a slightly more general macro, which
  2608.          loads DX whenever the "print string" function is requested:
  2609.  
  2610.          doscall  macro
  2611.                   mov ah, %1
  2612.                   ife %1 9
  2613.                      mov dx, offset(%2)
  2614.                   endif
  2615.                   int 21H
  2616.                   endm
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.                                                                      38
  2643.  
  2644.          "IFE" is short for "If Equal".  The "IFE" and "ENDIF" bracket
  2645.          a line of macro code which will be included during expansion
  2646.          only if the "IFE" statement is satisfied.  In this example,
  2647.          the MOV DX statement will be included only if the first
  2648.          parameter is equal to 9.  The enclosed line is indented in
  2649.          this example to help show the structure of the macro, but
  2650.          indentation is not required.
  2651.  
  2652.          Given the above definition, "DOSCALL 1" expands to only two
  2653.          lines:
  2654.  
  2655.             mov ah, 1
  2656.             int 21H
  2657.  
  2658.         However, "DOSCALL 9, STRING" expands to three lines:
  2659.  
  2660.             mov ah, 9
  2661.             mov dx, offset(string)
  2662.             int 21H
  2663.  
  2664.          CHASM supports eight different conditional test statements.
  2665.          They are:
  2666.  
  2667.               IFE     "if equal"
  2668.               IFNE    "if not equal"
  2669.               IFGT    "if greater than"
  2670.               IFGE    "if greater than or equal"
  2671.               IFLE    "if less than or equal"
  2672.               IFLT    "if less than"
  2673.               IFB     "if blank"
  2674.               IFNB    "if not blank"
  2675.  
  2676.          Most of the conditionals take two operands, and perform a
  2677.          comparison.  The operands are evaluated, and their values are
  2678.          compared according to the condition being tested.  Strings are
  2679.          compared in the normal alphabetical order sense.  Examples:
  2680.  
  2681.               IFE   15, 0FH       ;is true
  2682.               IFGT  'ABCD' 'EFGH' ;is false
  2683.               IFLE  20H, 128      ;is true
  2684.  
  2685.          IFB and IFNB require only one operand, which should be a dummy
  2686.          parameter.  These conditionals test whether the parameter was
  2687.          left "blank" or if a replacement was provided on the
  2688.          invocation.
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.                                                                      39
  2709.  
  2710.  
  2711.          You can place as many lines as you like between an IF
  2712.          statement and the ENDIF.  All will be included if the
  2713.          condition tested is true, and none will be included if it's
  2714.          false.
  2715.  
  2716.          An optional "ELSE" construct is also provided.  Statements
  2717.          after the ELSE get included only if the tested condition is
  2718.          false. CHASM's conditional assembly syntax can be summarized
  2719.          as follows:
  2720.  
  2721.              IF.....            ;if statement with parameter(s)
  2722.                s1                  ;statements included if true
  2723.                s2                  ;    "         "      "   " 
  2724.              ELSE               ;end of "true" option, begin "false"
  2725.                s3                  ;statements included if false
  2726.                s4                  ;    "         "      "   "
  2727.              ENDIF              ;end of conditional assembly
  2728.  
  2729.          IF statements can be nested, up to 10 deep.  During
  2730.          nesting, CHASM assumes that ELSEs are paired with the
  2731.          latest unfinished IF statement.  For example:
  2732.  
  2733.          example macro
  2734.                  ife %1, 1
  2735.                     db 'Outer IF is true'
  2736.                     ifb %2
  2737.                        'Inner IF is true'
  2738.                     else
  2739.                        'Where do I belong?'
  2740.                     endif
  2741.                  endif
  2742.  
  2743.          "EXAMPLE 1, 5" expands to:
  2744.  
  2745.                 db 'Outer IF is true'
  2746.                 db 'Where do I belong?'
  2747.  
  2748.          But "EXAMPLE 2" produces no expansion at all.
  2749.  
  2750.          This is easiest to follow if you use "structured" indenting
  2751.          when writing the macro, as in the example above. Remember,
  2752.          however, that CHASM ignores indenting and follows the
  2753.          "latest unfinished" rule in figuring out which IF gets the
  2754.          ELSE.  Don't fool yourself with improper indentation.
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.                                                                      40
  2775.  
  2776.  
  2777.       E. Final Notes:
  2778.  
  2779.          The conditional assembly pseudo-ops are not restricted to use
  2780.          only in macros, although there aren't that many useful
  2781.          non-macro applications.
  2782.  
  2783.          CHASM won't recursively expand parameters.  If you use a dummy
  2784.          parameter symbol as an operand on a macro invocation, the
  2785.          expanded macro contains the dummy parameter symbol, NOT the
  2786.          indirectly referenced replacement text.
  2787.  
  2788.          Like equates and structures, macro definitions should all be
  2789.          placed at the beginning of your programs, before the macro
  2790.          gets invoked.  If you invoke a macro before it's defined, a
  2791.          phase error will occur.
  2792.  
  2793.          Macro definitions are stored and expanded blindly by CHASM,
  2794.          with no syntax checking.  Dummy parameter symbols can appear
  2795.          in any of the input line fields.  Any errors in a macro
  2796.          definition will only become evident when CHASM expands the
  2797.          macro and attempts to assemble the result.
  2798.  
  2799.          In keeping with the "shorthand" philosophy of macros, the
  2800.          results of macro expansion don't normally appear on the
  2801.          listing.  If you want to see the expansion for debugging
  2802.          purposes, insert a LIST pseudo-op as the first line of the
  2803.          macro definition.
  2804.  
  2805.          Once you start writing macros, you might find it useful to
  2806.          gather them together into a single file.  You can then pull
  2807.          this file into the beginning of all your programs with an
  2808.          INCLUDE pseudo-op.  Macros which don't get invoked won't add
  2809.          anything to the object code produced, and you'll save yourself
  2810.          the trouble of typing in the ones you *do* need.  If you put a
  2811.          NOLIST at the beginning and a LIST at the end of your INCLUDE
  2812.          file, you don't even have to look at the definitions on your
  2813.          listings.
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.                                                                      41
  2841.  
  2842.       >>Structures<<
  2843.  
  2844.       ==>Advanced version only.
  2845.  
  2846.       Structures are an advanced feature.  Beginners may wish to skip
  2847.       this section until they become more experienced with CHASM and
  2848.       assembly language programming.
  2849.  
  2850.       CHASM's structure capability allows you to generate a "template"
  2851.       with which to organize repetitive data structures.  As an example
  2852.       of a repetitive data structure, consider a phone list.  Each
  2853.       entry in the list has three components:
  2854.  
  2855.            Name    - 20 characters
  2856.            Address - 50 characters
  2857.            Phone   - 10 characters
  2858.  
  2859.       Each entry thus uses a total of 80 bytes of storage.  To declare
  2860.       a list with 500 entries, you would declare 80 x 500 = 4000 bytes:
  2861.  
  2862.            PHONELIST  DS  4000   ;500 entries @ 80 bytes/entry
  2863.  
  2864.       That's easy enough, but now what's the offset of the 346th
  2865.       address field?  This is starting to get confusing, and time
  2866.       consuming to figure out.
  2867.  
  2868.       Furthermore, hard-coding numbers (like that 4000, above) into a
  2869.       program is never a good idea.  What's going to happen when you
  2870.       decide to add a zip code field, or make more room in the name
  2871.       field because you just met Alexandria Zbrievskivich?  You'd have
  2872.       to go through and change by hand each number which depended on
  2873.       the actual layout of your data.  Murphy's law guarantees that
  2874.       it'll take somewhere between "several" and "too many" assemblies
  2875.       to find them all.
  2876.  
  2877.       Structures allow you to set up a symbolic template which makes it
  2878.       much easier to manage structured data like this phone list.  By
  2879.       using symbols defined in the structure, rather than bare numbers,
  2880.       a change in data structure doesn't mean a frantic search
  2881.       throughout your entire program to make corrections.  If you
  2882.       change the structure definition, the symbols take on new values
  2883.       automatically.
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.                                                                      42
  2907.  
  2908.       Here's what the phone list structure looks like:
  2909.  
  2910.            LISTENTRY  STRUC
  2911.            NAME       DS 20
  2912.            ADDRESS    DS 50
  2913.            PHONE      DS 10
  2914.                       ENDSTRUC
  2915.  
  2916.       Note the STRUC and ENDSTRUC statements.  They mark the beginning
  2917.       and end of the structure, and give it a name (LISTENTRY).
  2918.  
  2919.       Within the structure are storage defining pseudo-ops.  DS is used
  2920.       in this example, but DB, DW, and DM could also be used.  ORG can
  2921.       be used within a structure, but any 8088 instruction will result
  2922.       in an diagnostic message and termination of the structure
  2923.       definition.
  2924.  
  2925.       Inside a structure, the storage defining pseudo-ops
  2926.       behave somewhat differently than normal.  No actual storage is
  2927.       set aside, but CHASM keeps track of how much space would normally
  2928.       be declared.
  2929.  
  2930.       Labels on pseudo-ops get assigned values equal to their offset
  2931.       within the *structure*, not within the program as a whole.  Also,
  2932.       CHASM will treat the labels as immediate operands, rather than
  2933.       memory locations.  The result of the structure given above is to
  2934.       generate three immediate operands, with the following values:
  2935.  
  2936.            NAME    =  0
  2937.            ADDRESS = 20
  2938.            PHONE   = 70
  2939.  
  2940.       CHASM does one other piece of useful book-keeping during
  2941.       structure definitions.  If a label appears on the STRUC
  2942.       pseudo-op, it gets treated as an immediate operand, whose value
  2943.       is equal to the total length of the structure.
  2944.  
  2945.       You can either use the STRUC label directly as an operand, or if
  2946.       you like "pretty" code, use the LENGTH operator on it.  In this
  2947.       example, both LISTENTRY and LENGTH(LISTENTRY) are immediate
  2948.       operands of value 80.
  2949.  
  2950.       (Inside note: LENGTH is a null operator, provided mainly for
  2951.       aesthetic reasons.  Using LENGTH will often make your code more
  2952.       readable, but is equivalent to using just the label itself.)
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.                                                                      43
  2973.  
  2974.  
  2975.       Like equates and macros, structures should be placed at the
  2976.       beginning of your programs before any machine instructions,
  2977.       otherwise phase errors can occur.  If you *do* embed structures
  2978.       inside your program, you can eliminate any phase errors by using
  2979.       the LENGTH function to reference any of the immediate operands
  2980.       generated by the embedded structure.
  2981.  
  2982.       The immediate operands generated during a structure definition
  2983.       can be very useful in writing your program.  Following the phone
  2984.       list example, here's a better way to declare storage for the
  2985.       list:
  2986.  
  2987.          NUMENTRYS  EQU 500
  2988.          PHONELIST  DM  LISTENTRY*NUMENTRYS ;500 entries of length
  2989.                                             ;defined by the structure.
  2990.  
  2991.       Now if you add another field to the structure, PHONELIST will
  2992.       automatically increase in size.
  2993.  
  2994.       The 8088's indirect addressing modes, coupled with structures,
  2995.       make a very powerful combination for accessing structured data in
  2996.       memory.  Suppose AX contains the number of the entry you want to
  2997.       work on.  You can calculate the address of the entry as follows:
  2998.  
  2999.           MOV BX, LENGTH(LISTENTRY)    ;length per entry
  3000.           MUL AX,BX                    ;times entry number
  3001.           ADD AX, OFFSET(PHONELIST)    ;plus the starting offset
  3002.           MOV BX,AX                    ;BX <== frame pointer
  3003.  
  3004.       BX is now a "frame pointer" - it points to the beginning of the
  3005.       desired entry.  You can access the various parts of the entry
  3006.       using the optional displacement field in the indirect address.
  3007.       For example, here's how you would store the letter 'A' into the
  3008.       first byte of the address field:
  3009.  
  3010.            MOV  ADDRESS[BX], 'A'
  3011.  
  3012.       As another example, the following line reads the third letter of
  3013.       the name into the AL register:
  3014.  
  3015.            MOV  AL, NAME+3[BX]
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.                                                                      44
  3039.  
  3040.       The more complicated indirect modes can be used to scan through
  3041.       or point within the fields.  The following program fragment gets
  3042.       the fourth digit in the phone number:
  3043.  
  3044.            MOV DI, 4             ;specify 4th digit
  3045.            MOV AL, PHONE[BX+DI]  ;read it into AL
  3046.  
  3047.       Often times, you'll want to process entries sequentially.  To
  3048.       move to the next entry, you just add the length of the entry to
  3049.       the frame pointer:
  3050.  
  3051.            ADD   BX, LENGTH(LISTENTRY)    ;point to next entry
  3052.  
  3053.       The preceding examples should give you a feel for what you can
  3054.       do with structures, but do not exhaust all the possibilities.
  3055.       Experiment with this feature, and many of your programs will be
  3056.       both more readable and more easily modified.
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.                                                                      45
  3105.  
  3106.       >>Outside the Program Segment<<
  3107.  
  3108.       As mentioned previously, CHASM does not support multiple segment
  3109.       definitions.  Provision is made for limited access outside of the
  3110.       program segment, however.
  3111.  
  3112.       A. Memory References:
  3113.          To access memory outside the program segment, you move a new
  3114.          segment address into the DS register, then address using
  3115.          offsets in the new segment.  The memory option of the EQU
  3116.          pseudo-op allows you to give a variable name to offsets in
  3117.          other segments. For example, to access DOS's equipment flag:
  3118.  
  3119.             BIOS_DATA   EQU  40H
  3120.             EQUIP_FLAG  EQU  [0010H]
  3121.                         MOV  AX,BIOS_DATA  ;can't move immed. to DS
  3122.                         MOV  DS,AX
  3123.                         MOV  AX,EQUIP_FLAG ;get bios equipment flag
  3124.  
  3125.       B. Code Branching:
  3126.          CHASM supports 4 instructions for branching outside the
  3127.          program segment.
  3128.  
  3129.          1. Direct CALL and JMP
  3130.  
  3131.             New values for the PC and CS registers are included in the
  3132.             instruction as two immediate operands.  Example:
  3133.  
  3134.             BIOS         EQU  0F000H            ;RAM bios segment
  3135.             DISKETTE_IO  EQU  0EC59H            ;disk handler
  3136.                          JMP  DISKETTE_IO,BIOS
  3137.  
  3138.          2. Indirect CALLF and JMPF
  3139.  
  3140.             Four consecutive bytes in memory are initialized with new
  3141.             values for the PC and CS registers.  The CALLF or JMPF then
  3142.             references the address of the new values.  Example:
  3143.  
  3144.             BIOS        EQU   0F000H           ;RAM bios segment
  3145.             PRINTER_IO  EQU   0EFD2H           ;printer routine
  3146.                         MOV   [DI],PRINTER_IO
  3147.                         MOV   2[DI],BIOS
  3148.                         CALLF [DI]
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.                                                                      46
  3171.  
  3172.       >>Running CHASM<<
  3173.  
  3174.       A. Prompt Mode
  3175.  
  3176.          From DOS, type:
  3177.  
  3178.            CHASM
  3179.  
  3180.          If you're using the Subset version, a hello screen is printed,
  3181.          followed by the message:
  3182.  
  3183.            Hit Esc to exit, anything else to continue...
  3184.  
  3185.          Advanced CHASM skips the commercial message.
  3186.  
  3187.          You're now presented with a series of prompts:
  3188.  
  3189.             Source code file name? [.asm]
  3190.  
  3191.          Type in the name of the file which contains your program.  If
  3192.          you don't include an extension for the filename, CHASM
  3193.          assumes it to be .ASM.  If CHASM is unable to find the file,
  3194.          it will give you the option of naming another file, or
  3195.          returning to DOS.  Note that anywhere CHASM expects a
  3196.          filename, you can optionally include a drive and/or path.
  3197.  
  3198.          Assuming your file is present, CHASM prompts:
  3199.  
  3200.             Direct listing to Printer (P), Screen (S), or Disk (D)?
  3201.             [nul:]
  3202.  
  3203.          Respond with either an upper or lower case letter.  If you
  3204.          just press enter, no listing will be produced.  If you select
  3205.          "D", CHASM will prompt:
  3206.  
  3207.             Name for listing file? [fname.lst]
  3208.  
  3209.          Type in a name for the listing file.  If you just press ENTER,
  3210.          the name defaults to that of your source file, with an
  3211.          extension of .LST.
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.                                                                      47
  3237.  
  3238.          Listing Notes:
  3239.  
  3240.             1. The setting of the /PATH configuration switch controls
  3241.                the exact form of the default list file name.
  3242.  
  3243.             2. Regardless of where the listing is sent, error messages
  3244.                are always echoed to the screen.
  3245.  
  3246.             3. Suppressing the listing will result in faster assembly.
  3247.  
  3248.          The final prompt is:
  3249.  
  3250.             Name for object file? [fname.com]
  3251.  
  3252.          Type in a name for the assembled program.  If you just press
  3253.          ENTER, the name defaults to that of your source file, with an
  3254.          extension of .COM.
  3255.  
  3256.          Note: The setting of the /PATH configuration switch controls
  3257.                the exact form of the default object file name.
  3258.  
  3259.          CHASM now assembles your program.  A status line is maintained
  3260.          on the screen, showing how many lines have been processed,
  3261.          along with how many errors have been discovered.  CHASM makes
  3262.          two passes over your source file, outputting the listing and
  3263.          object code on the second pass.  You may abort assembly and
  3264.          return to DOS at any time by hitting Ctrl-C or Ctrl-Break.
  3265.  
  3266.          At the end of the second pass, a final summary of the assembly
  3267.          process is printed.  It will look something like:
  3268.  
  3269.             0 Error(s) detected
  3270.             0 Diagnostic(s) offered
  3271.  
  3272.          954 (3BAH) Bytes of object code generated
  3273.  
  3274.          This information should be self-explanatory.  The number of
  3275.          bytes is given in both decimal and hex format.
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.                                                                      48
  3303.  
  3304.          If labels appeared in your program, a dump of the symbol table
  3305.          will follow.  This lists each user-defined symbol, along with
  3306.          its value (in hex). The symbols are printed in alphabetical
  3307.          order.  Each value is preceded by a one-letter code, which
  3308.          tells the symbol's type:
  3309.  
  3310.                   P: a program location
  3311.                   M: a memory location for data
  3312.                   I: immediate data
  3313.  
  3314.          Upon exit, CHASM sets the system variable ERRORLEVEL to
  3315.          (surprise!) the total number of errors discovered in your
  3316.          source file. If you run CHASM from a batch file, you can use
  3317.          this feature to automatically invoke your text editor if
  3318.          errors were discovered.
  3319.  
  3320.       B. Expert Mode:
  3321.  
  3322.          This mode allows you to specify all i/o information on the
  3323.          command line which invokes CHASM.  The syntax is:
  3324.  
  3325.             CHASM sourcefile [p|s|d|/] [listfile|/] [objectfile]
  3326.  
  3327.          Items within brackets ([]) are optional. You may select *one*
  3328.          of any list of items separated by a bar (|).
  3329.  
  3330.          Basically, you just include on the command line all your
  3331.          responses to the normal prompts.  Each response must be
  3332.          separated from the others by either a space or comma.
  3333.  
  3334.          If you don't specify the list device/file or the object file,
  3335.          they default to NUL: and sourcename.COM respectively.  To
  3336.          represent a carriage return (to specify a default choice, but
  3337.          allow modifying a later response) use the character slash (/).
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.                                                                      49
  3369.  
  3370.          Expert mode examples:
  3371.  
  3372.             1. Source file is EXAMPLE.ASM, no listing, object file
  3373.                EXAMPLE.COM:
  3374.  
  3375.                   CHASM example
  3376.  
  3377.             2. Source file is SDIR.ASM, list to printer, object file
  3378.                SDIR.COM:
  3379.  
  3380.                   CHASM sdir p
  3381.  
  3382.             3. Source file is MYFILE.PRG, list to disk file MYFILE.LST,
  3383.                object file SUBR.COM:
  3384.  
  3385.                   CHASM myfile.prg d / subr.com
  3386.  
  3387.  
  3388.  
  3389.  
  3390.  
  3391.  
  3392.  
  3393.  
  3394.  
  3395.  
  3396.  
  3397.  
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.                                                                      50
  3435.  
  3436.       >>Error and Diagnostic Messages<<
  3437.  
  3438.       Error messages generated on pass one appear on the listing before
  3439.       any source code is printed, and mention the line number to which
  3440.       they refer.  The majority of messages occur during pass two, and
  3441.       will appear in the listing immediately prior to the line which
  3442.       caused the message.  Unless the listing itself is going to the
  3443.       screen, messages and the source line which generated them will be
  3444.       echoed there.
  3445.  
  3446.       Add Leading Zero to Hex Constant: Diagnostic.  The unknown
  3447.          symbol could be interpreted as a hexadecimal number if a
  3448.          leading zero was added.
  3449.  
  3450.       CHASM Internal Error: XX PC: YYYY or
  3451.       CHASM I/O Error: XX PC: YYYY 
  3452.          Sigh. You just discovered a problem in CHASM itself.  Please
  3453.          contact Whitman Software, following the procedure in the
  3454.          appendix on Bug Reporting.
  3455.  
  3456.       Could Use JMPS: Diagnostic.  The specified label requires an
  3457.          offset of less than 128 bytes; specifying the short jump would
  3458.          result in more compact code.  The assembled code is correct,
  3459.          however.
  3460.  
  3461.       Conditional Nested Too Deeply:  IF statements can only be nested
  3462.          10 deep.
  3463.  
  3464.       Data too Large: XXX   XXX was found in DB operand list, but is a
  3465.          word value.  Use DW to declare words.
  3466.  
  3467.       DM out of range:  The product of the DM's operands is either
  3468.          negative, or greater than 32767.
  3469.  
  3470.       Duplicate Definition of XXX in (linenum): Pass 1 error.  An
  3471.          attempt was made to define a symbol already present in the
  3472.          symbol table.
  3473.  
  3474.       ELSE without IF: An ELSE was encountered, but no corresponding
  3475.          conditional pseudo-op was found.
  3476.  
  3477.       ENDC without COUNT: An ENDC was encountered, but no corresponding
  3478.          COUNT was found.
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.                                                                      51
  3501.  
  3502.       ENDIF without IF: An ENDIF was encountered, but no corresponding
  3503.          conditional pseudo-op was found.
  3504.  
  3505.       ENDM without MACRO:  An ENDM was encountered, but no
  3506.          corresponding MACRO was found.
  3507.  
  3508.       ENDP without PROC: An ENDP was encountered, but no corresponding
  3509.          PROC was found.
  3510.  
  3511.       ENDSTRUC without STRUC: An ENDSTRUC was encountered, but no
  3512.          corresponding STRUC was found.
  3513.  
  3514.       EQU Without Label: No symbol was found to equate with the
  3515.          operand.
  3516.  
  3517.       File not found: XXX in (linenum).  Pass one error.  CHASM was
  3518.          unable to find the file XXX, specified in the INCLUDE
  3519.          pseudo-op.
  3520.  
  3521.       Heap Full: Too many XXX.  Usually a Pass one error.
  3522.          You've run out of memory for the symbol and macro tables.  You
  3523.          shouldn't see this message unless you have only 128K and are
  3524.          assembling a very large program.
  3525.  
  3526.       Illegal Label: XXX in (linenum). Pass one error.  The symbol
  3527.          XXX begins in column one and has as its first character a
  3528.          number, or a plus or minus sign.  Alternatively, you tryed to
  3529.          use the reserved symbol '$' as a label.
  3530.  
  3531.       Illegal Operation for Structure - ENDSTRUC Implied: Diagnostic.
  3532.          The current line is within a structure, and is not a storage
  3533.          defining pseudo-op.  CHASM generates an ENDSTRUC, which
  3534.          terminates the structure definition, then assembles the line
  3535.          normally.
  3536.  
  3537.       Illegal or Undefined Argument for LENGTH:  The argument for the
  3538.          LENGTH  function was not present in the symbol table as an
  3539.          immediate operand on pass 2.
  3540.  
  3541.       Illegal or Undefined Argument for OFFSET: The argument for the
  3542.          OFFSET function was not present in the symbol table as a near
  3543.          label or memory location on pass 2.
  3544.  
  3545.       Missing ENDC: The end of the input file was encountered, and at
  3546.          least one COUNT had not been terminated by an ENDC.
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.                                                                      52
  3567.  
  3568.  
  3569.       Missing ENDM:  The end of the input file was encountered, and
  3570.          at least one MACRO had not been terminated by an ENDM.
  3571.  
  3572.       Missing ENDP: The end of the input file was encountered, and at
  3573.          least one PROC had not been terminated by an ENDP.
  3574.  
  3575.       Missing ENDSTRUC: The end of the input file was encountered, and
  3576.          at least one STRUC had not been terminated by an ENDSTRUC.
  3577.  
  3578.       Multiple Segment Overides are Illegal:  Diagnostic.  You have
  3579.          specified more than one segment overide on this instruction.
  3580.          The first overide is used, and the other(s) ignored.
  3581.  
  3582.       Nested COUNT:  A COUNT was encountered while CHASM was already
  3583.          COUNTing.  COUNTs cannot be nested.
  3584.  
  3585.       Nested INCLUDE: An INCLUDE was encountered in an INCLUDEd file.
  3586.          The INCLUDE pseudo-op cannot be nested.
  3587.  
  3588.       Nested Structure: A STRUC was encountered inside a structure.
  3589.          Structures cannot be nested.
  3590.  
  3591.       No Name For Macro:  Diagnostic.  The macro statement did not have
  3592.          a label.  CHASM is unable to give a name to the macro, and you
  3593.          will be unable to reference it.
  3594.  
  3595.       Phase Error: A label or memory location is found to have
  3596.          different values on pass 1 and pass 2.  A difficult to debug
  3597.          error: generally the problem is not caused by the statement
  3598.          which received the error message.
  3599.  
  3600.          There are four documented ways to generate this error.
  3601.  
  3602.          1. A previous instruction used a symbolic immediate operand
  3603.             prior to the symbol's definition.
  3604.  
  3605.          2. A previous instruction made improper use of a forward
  3606.             referenced label, either an attempt to branch into a data
  3607.             area, or to access a code area as if it was data.
  3608.  
  3609.          3. The label on the flagged statement is defined more than
  3610.             once in the program.
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.                                                                      53
  3633.  
  3634.          4. A previous instruction invoked a macro prior to its
  3635.             definition.
  3636.  
  3637.          Whitman Software would appreciate hearing about any other
  3638.          situations which cause the Phase Error message to appear.
  3639.  
  3640.       Procedures Nested Too Deeply: Procedures may be nested no more
  3641.          than 10 deep.
  3642.  
  3643.       Source Line Truncated:  The length of the input line exceeded 80
  3644.          characters.
  3645.  
  3646.       Specify Word or Byte Operation: Diagnostic.  CHASM suggests that
  3647.          the Syntax Error might be resolved by adding the suffix "B" or
  3648.          "W" to the instruction mnemonic.  Most, but not all, ambiguous
  3649.          memory references are flagged with this diagnostic.
  3650.  
  3651.       Syntax Error: (OP) (DEST) (SOURCE).  CHASM was unable to find a
  3652.         version of the instruction (OP) which allows the operands
  3653.         (DEST) and (SOURCE).  Either the instruction doesn't exist, or
  3654.         it is an inappropriate choice for the given operands.
  3655.  
  3656.         Syntax Error messages are followed by two diagnostics which
  3657.         spell out in words CHASM's best guess about the operands.
  3658.  
  3659.       Too Far For Short Jump: The displacement to the specified label
  3660.          is not in the range -128 to +127.
  3661.  
  3662.       Undefined Operand for EQU: Any operands on an EQU statement must
  3663.          have been previously defined.
  3664.  
  3665.       Undefined Symbol XXX: The symbol XXX was used as an operand, but
  3666.          never appeared as a label, and is not a predefined symbol.
  3667.  
  3668.       Unrecognized Operand XXX: XXX is used in the DB or DW operand
  3669.          list, but is not a valid immediate operand. (or string, in the
  3670.          case of DB).
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.                                                                      54
  3699.  
  3700.       >>Execution of Assembled Programs<<
  3701.  
  3702.       A. Object code format
  3703.  
  3704.          The object code file produced by CHASM is in the form of a
  3705.          memory image, exactly as will be present in your computer at
  3706.          run time.  No link step is required.  Provided that the segment
  3707.          registers are set correctly, the architecture of the 8088
  3708.          guarantees that code is self-relocating, and will run correctly
  3709.          loaded anywhere in memory.  Storing a program as an exact image
  3710.          of memory at run time is called the COM format by IBM.
  3711.  
  3712.          This COM format is *not* that produced by the IBM assembler.
  3713.          The output of the IBM assembler is in the form of an "object
  3714.          module" suitable for input to the linker.  The object module
  3715.          is not directly executable, but must first be "filtered"
  3716.          through the linker.  This adds an extra step to the process of
  3717.          producing a working program, but gives you the option of
  3718.          combining multiple object modules into one program.  The
  3719.          resulting linked program is *still* not a memory image, but
  3720.          has a header which is used to perform relocation during
  3721.          loading.  This linked program plus header is called the EXE
  3722.          format by IBM.
  3723.  
  3724.       B. Running Assembled Programs From DOS
  3725.  
  3726.          DOS provides a loader for running machine language programs.
  3727.          To run a program, you merely type its name, without the
  3728.          extension.  This is what you're doing every time you use a DOS
  3729.          external command such as FORMAT or CHKDSK.  In fact, the COM
  3730.          format is named after "external COMmand".
  3731.  
  3732.          When DOS loads a program, it examines the file extension to
  3733.          determine what format the file is in, either COM or EXE.  This
  3734.          is why CHASM defaults to using the extension .com for your
  3735.          object file.  If you plan to run the program from DOS, don't
  3736.          change the extension.
  3737.  
  3738.          For COM programs, DOS builds a 255 byte long "program segment
  3739.          prefix" and sets the segment registers to point to this PSP.
  3740.          The contents of the file are then loaded verbatim right after
  3741.          the PSP, at offset hex 100 in the segment defined by the
  3742.          segment registers.  As soon as loading is complete, your
  3743.          program is executed starting with the instruction at hex 100.
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.                                                                      55
  3765.  
  3766.          Although you can totally ignore the PSP, you should read pages
  3767.          E-3 through E-11 of the DOS manual to see what DOS puts there
  3768.          for you.  It turns out there are some real goodies which your
  3769.          program might want to use.
  3770.  
  3771.          When your program is done, it must transfer control back to
  3772.          DOS, otherwise the 8088 will continue to fetch what it
  3773.          believes are instructions from whatever garbage or bit-hash
  3774.          happens to follow your program in memory.  The easiest way to
  3775.          return to DOS is to execute the instruction:
  3776.  
  3777.            INT 20H
  3778.  
  3779.          This is the vectored interrupt reserved by DOS for program
  3780.          termination.
  3781.  
  3782.          While we're on the topic of vectored interrupts, you would be
  3783.          well rewarded to study both the DOS manual and Technical
  3784.          Reference to find out what happens when you execute some of
  3785.          the other interrupts.  Some very useful functions, such as
  3786.          file handling and screen i/o, are available at the machine
  3787.          language level through this mechanism.
  3788.  
  3789.          Looking at things the other way, by changing the interrupt
  3790.          vector for a given function to point to your own code, you can
  3791.          override the way DOS or the BIOS does something, and do it
  3792.          your way.  DOS even provides a method (via interrupt 27H) by
  3793.          which your new code can be grafted onto DOS, and not be
  3794.          overwritten by other programs.
  3795.  
  3796.       C. Debugging Assembled Programs
  3797.  
  3798.          IBM provides an excellent utility with DOS, called DEBUG.COM.
  3799.          By specifying your program's name as a parameter when invoking
  3800.          DEBUG, you can observe your program execute with DEBUG's trace
  3801.          and other functions.  To debug your program, from DOS type:
  3802.  
  3803.             DEBUG progname.COM
  3804.  
  3805.          DEBUG builds a PSP and loads your program just like DOS does,
  3806.          but you have the added power of the debugging commands to
  3807.          monitor your program while it runs.  See chapter 6 of the DOS
  3808.          manual for more details about using DEBUG.
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.                                                                      56
  3831.  
  3832.          On the topic of debugging, I can recommend most highly a
  3833.          program called TRACE86, from Morgan Computing (10400 N.
  3834.          Central Expressway, Suite 210, Dallas, TX 75231).  The program
  3835.          replaces DEBUG, and although a little steeply priced at $125,
  3836.          makes the IBM debugger look silly.  I've been using TRACE86
  3837.          for some time now, and wouldn't be without it.
  3838.  
  3839.       D. Using Assembled Programs in BASIC
  3840.  
  3841.          To incorporate a machine language subroutine in a BASIC
  3842.          program, write it in assembly language, then assemble it with
  3843.          CHASM.  You should read page C-7 of the BASIC manual for some
  3844.          conventions to use in writing your subroutine.  In particular,
  3845.          note that you must declare the routine to CHASM as a FAR
  3846.          procedure using the PROC pseudo-op, and that the last
  3847.          instruction of the routine should be a RET.
  3848.  
  3849.          Unlike programs which are run directly from DOS, your routine
  3850.          will not be preceded by a program segment prefix.  You should
  3851.          prevent CHASM from leaving room for a PSP by putting an ORG 0
  3852.          pseudo-op at the beginning of your routine. If you don't
  3853.          include the ORG, memory references will not be assembled
  3854.          correctly.  Example:
  3855.  
  3856.               ORG  0    ;no psp
  3857.          SUBR PROC FAR  ;far procedure
  3858.               ...       ;body of subroutine
  3859.               RET
  3860.               ENDP
  3861.  
  3862.          CHASM supports two methods for getting assembled routines into
  3863.          BASIC programs.  The methods differ in whether the routine is
  3864.          included in the BASIC program file, or in a separate file.
  3865.  
  3866.          A utility program called COM2DATA is provided for including
  3867.          machine language within BASIC program files.  The program is
  3868.          distributed in source code form (file COM2DATA.ASM) and must
  3869.          be assembled with CHASM prior to use.  The program functions
  3870.          as a DOS 2 filter, reading a COM file in from the standard
  3871.          input, and writing a series of BASIC DATA statements to the
  3872.          standard output.
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.                                                                      57
  3897.  
  3898.          COM2DATA's syntax is as follows:
  3899.  
  3900.            COM2DATA [<infile] [>outfile] [linenum]
  3901.  
  3902.          You specify the input and output files as with any DOS 2
  3903.          filter.  The linenum parameter sets the starting line number
  3904.          used on the BASIC code produced.  If you don't specify
  3905.          linenum, it defaults to 1000.
  3906.  
  3907.          If you MERGE the file of DATA statements into your BASIC
  3908.          program, the program can then READ the data and POKE it into
  3909.          memory.  An example program to do this is given on page C-6 of
  3910.          the BASIC manual.  An alternative approach would be to store
  3911.          the routine in a string variable, which could later be located
  3912.          with the VARPTR function. 
  3913.  
  3914.          If you would prefer to keep your machine language subroutine
  3915.          in a separate file, include a BSAVE pseudo-op somewhere within
  3916.          your assembly language source code.  CHASM will build a header
  3917.          on the object code produced, which will mimic that built by
  3918.          BASIC's BSAVE command.  The resulting file may be BLOADed by
  3919.          BASIC to any location in memory.
  3920.  
  3921.          You transfer control to your routine with either the USR
  3922.          function, or the CALL statement.  Syntax for these statements
  3923.          can be found in the BASIC manual.
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.                                                                      58
  3963.  
  3964.       E. Using Assembled Programs with Turbo Pascal:
  3965.  
  3966.          CHASM and Turbo Pascal work splendidly together, complementing
  3967.          each other's strong points.  You can use CHASM to provide new
  3968.          functions you wish Turbo had, or to fine tune a critical
  3969.          procedure for optimum speed.
  3970.  
  3971.          Turbo loads external procedures and functions within the same
  3972.          segment as the rest of your Pascal program.  You have no
  3973.          control of the exact load location (more on this later), but
  3974.          on the other hand, you don't have to worry about setting aside
  3975.          a special location for your procedures (as in BASIC).  Since
  3976.          your external procedure is loaded in the same segment as the
  3977.          Pascal code, it should be declared NEAR to CHASM:
  3978.  
  3979.            EXTERNAL PROC NEAR
  3980.                     ...           ;body of procedure
  3981.                     ...
  3982.                     ENDP
  3983.  
  3984.          Turbo passes parameters to your procedure/function via the
  3985.          stack.  To work effectively, a good grasp of the stack
  3986.          structure is critical.  Read the Turbo manual for information
  3987.          on internal data formats and parameter passing, to see just
  3988.          what to expect on the stack.  Also, remember that the stack
  3989.          grows down from the top of memory.
  3990.  
  3991.          If you're going to access the stack in your procedure, the
  3992.          first thing you should do is set up BP as a stack pointer.
  3993.          Since Turbo also uses BP, you have to save the current value
  3994.          first.  The obvious place to save it is on the stack...
  3995.  
  3996.             PUSH BP            ;save old BP
  3997.             MOV  BP, SP        ;and set up to indirectly address stack
  3998.  
  3999.          You can now access the parameters on the stack using offsets
  4000.          off the BP register.  Note that since you PUSHed BP,
  4001.          everything is 2 bytes deeper onto the stack than what Turbo
  4002.          originally sent you.
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.  
  4025.  
  4026.  
  4027.  
  4028.                                                                      59
  4029.  
  4030.          Here's an example.  Suppose you declare the following external
  4031.          function in Turbo:
  4032.  
  4033.             function Sum(x,y: int): int;
  4034.                external 'sum.com';
  4035.  
  4036.          After you've pushed BP, here's how the stack looks:
  4037.  
  4038.              stack contents           indirect address
  4039.           ----------------------------------------------
  4040.              <value of parameter y>        6[BP]
  4041.              <value of parameter x>        4[BP]
  4042.              <return address to Turbo>     2[BP]
  4043.              <old BP value>                 [BP]
  4044.  
  4045.          The indirect addresses go up two at a time, since each item on
  4046.          the stack is a word (two bytes) long. You can access the
  4047.          parameters using their indirect addresses. Here's the code for
  4048.          an external function to add two integer parameters:
  4049.  
  4050.          SUM  PROC NEAR
  4051.               PUSH BP          ;save old BP
  4052.               MOV  BP, SP      ;set up stack pointer
  4053.  
  4054.               MOV  AX,  4[BP]  ;get parameter x
  4055.               MOV  ADD, 6[BP]  ;add parameter y
  4056.                                ;leave sum in AX to return to Turbo
  4057.  
  4058.               POP  BP          ;restore old BP for Turbo
  4059.               RET  4           ;clear params off stack
  4060.               ENDP
  4061.  
  4062.          Functions return scalar results by having the value in AX upon
  4063.          return.  This function saves some time by calculating the
  4064.          value in AX in the first place.  Upon exit, the function POPs
  4065.          BP, to restore the value Turbo was using.
  4066.  
  4067.          Note the RET 4.  This returns to Turbo, while simultaneously
  4068.          POPing (and discarding) 4 bytes off the stack.  This clears
  4069.          off the two parameters which Turbo passed.  If there were
  4070.          three parameters, you'd use a RET 6; if none, a simple RET
  4071.          would do. When Turbo receives control, it assumes that you've
  4072.          cleaned up the stack by removing all parameters.  If you don't
  4073.          do this properly, a run-time error, or even a system crash
  4074.          will result.
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.                                                                      60
  4095.  
  4096.  
  4097.          (Typical scenario:  Turbo tries to return from one of its own
  4098.          subroutines, thinking the top of the stack has the return
  4099.          address.  Unfortunately, the top is really an integer
  4100.          parameter, left over from your external function.  Turbo's
  4101.          RET sends control into some random area of memory, and boom -
  4102.          the system crashes.)
  4103.  
  4104.          It's easy to get confused about the exact contents of the
  4105.          stack.  If your procedure doesn't seem to be working right,
  4106.          the first thing to suspect is Turbo and you have different
  4107.          ideas about what's where on the stack.  A DEBUG session can
  4108.          usually straighten things out.
  4109.  
  4110.          A problem of addressability can crop up if your external
  4111.          procedure tries to maintain its own local variables and/or
  4112.          constants.  The problem is that you have no way of knowing
  4113.          just where Turbo is going to load your procedure within the
  4114.          shared segment.  As such, the address CHASM calculates for any
  4115.          memory locations are going to be offset from their real values
  4116.          by some unknown constant, the offset of the procedure within
  4117.          the shared segment.  This is called a relocation problem.
  4118.  
  4119.          Fortunately, there's a way around this problem, but it
  4120.          requires using a trick.  Your program has to figure out, *at
  4121.          run time*, just where it's located in memory.  If you could
  4122.          find out the offset of any known point in your procedure,
  4123.          you'd "have your bearings" so to speak, and could go on.
  4124.  
  4125.          The trick is as follows.  The 8088 CALL instruction pushes the
  4126.          address of the next instruction onto the stack, then branches
  4127.          to the location given in the CALL.  By performing a dummy
  4128.          CALL, then stealing the value off the stack, we have the
  4129.          location of a known spot in the procedure.   By subtracting
  4130.          the offset within the procedure of that known location, we get
  4131.          a pointer to the beginning of the procedure which can be used
  4132.          to access everything else.  Here's an example:
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.  
  4154.  
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.                                                                      61
  4161.  
  4162.          LOCAL  PROC NEAR
  4163.                 PUSH BP                     ;set up to access stack
  4164.                 MOV  BP, SP                 ; ditto
  4165.  
  4166.                 CALL DUMMY                  ;establish addressability
  4167.          DUMMY  POP  BX                     ;  "           "
  4168.                 SUB  BX, OFFSET(DUMMY)
  4169.  
  4170.                 MOV  AX, 4[BP]                ;get parameter
  4171.                 SEG  CS                       ;offset relative to CS
  4172.                 ADD  OFFSET(TOTAL)[BX], AX    ;maintain running total
  4173.  
  4174.                 POP  BP
  4175.                 RET  2
  4176.          TOTAL  DW   0000H
  4177.                 ENDP
  4178.  
  4179.          We use indirect addressing here.  After the funny business
  4180.          with the CALL, POP, SUB sequence, BX has a pointer to the
  4181.          beginning of the procedure.  Using indirect addressing, we
  4182.          take that pointer and we add in the offset of the memory
  4183.          location we want to access.  In this example we're using a
  4184.          local variable to maintain a running total of the parameter
  4185.          which gets passed.
  4186.  
  4187.          Note the SEG CS just before the ADD which accesses the
  4188.          location TOTAL.  Since we found our bearings by stealing the
  4189.          address of a program instruction, our offset is known relative
  4190.          to the CS register, NOT the DS which is normally used to
  4191.          access data.  The SEG CS forces the 8088 to calculate the
  4192.          address using CS rather than the default DS register.  Every
  4193.          time you access a memory location within your procedure, you
  4194.          *MUST* do it relative to CS by using a segment overide.
  4195.  
  4196.          Turbo is very forgiving about what values you leave in the
  4197.          registers upon return.  If you modify their contents, you do
  4198.          have to restore BP, SP and SS before returning to Turbo.
  4199.          However, as far as I can tell, you can safely trash the
  4200.          contents of all the general purpose registers, plus DI, SI, DS
  4201.          and ES.
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.  
  4226.                                                                      62
  4227.  
  4228.       >>Notes for Those Upgrading to This Version of CHASM<<
  4229.  
  4230.       CHASM is not yet carved in stone - improvements and corrections
  4231.       are made fairly frequently, based on both my own experience in
  4232.       using the program, and the comments of outside users.  This
  4233.       section summarizes the changes which have been made since version
  4234.       1.2 was released.  Changes followed with an asterisk (*) denote
  4235.       modifications which could invalidate programs written under
  4236.       earlier versions of CHASM.
  4237.  
  4238.       Version     Notes
  4239.  
  4240.       4.00        Total rewrite in Turbo Pascal.  Subset replaces
  4241.                   interpreted version as free distribution release.
  4242.                   Faster assembly.  Symbol and macro tables can now use
  4243.                   all available memory.  Nested macros now permitted.
  4244.                   Operand expressions.  $ now returns location counter
  4245.                   value.  New syntax for segment overides.  Conditional
  4246.                   pseudo-ops now evaluate operands.  Improved error and
  4247.                   diagnostic messages.  DOS 2 or later now required
  4248.                   (*). DOS 2 path support for files. Setting of DOS 2
  4249.                   ERRORLEVEL. EJECTIF pseudo-op added. New
  4250.                   configuration switches: /FF, /DWIDTH, /TIMER, /PATH.
  4251.                   CHASM.CFG must now have only one switch per line (*).
  4252.  
  4253.       3.15        Macros added. New pseudo-ops: MACRO, ENDM, IFE, IFNE,
  4254.                   IFB, IFNB, ELSE, ENDIF.
  4255.  
  4256.       3.14        Interpreted version frozen at version 2.13, further
  4257.                   changes apply only to compiled version.  Memory
  4258.                   requirement raised to 128K.  INCLUDE, STRUC,
  4259.                   ENDSTRUC, DM, DW, LIST, NOLIST, COUNT and ENDC
  4260.                   pseudo-ops added.  Alternate mnemonics for the jump
  4261.                   on condition instructions, and alternate syntax for
  4262.                   the DIV and MUL instructions.  Binary numbers added.
  4263.  
  4264.       2.13        Assembly can now be aborted with the Esc key.
  4265.                   Negative decimal numbers are working again.  Input
  4266.                   lines now limited to 80 characters, and labels must
  4267.                   begin with a non-numeral. (*) 
  4268.  
  4269.       2.12        Listings can now be suppressed.  Error messages are
  4270.                   echoed to the console on non-screen listings.
  4271.                   Expert mode added.
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.  
  4289.  
  4290.  
  4291.  
  4292.                                                                      63
  4293.  
  4294.       2.11        Pagination improved.  Listings now time stamped.
  4295.                   OFFSETs and word values now allowed in DB operand
  4296.                   list.
  4297.  
  4298.       2.10        Equated symbols allowed in the DB operand
  4299.                   list.  Status line improved.
  4300.  
  4301.       2.09        The first digit of hexadecimal constants must now be
  4302.                   in the range 0-9. A leading zero is permitted on four
  4303.                   digit hex constants, to allow fulfilling this
  4304.                   condition. (*)
  4305.  
  4306.       2.08        Configuration process expanded.  CHASM now skips over
  4307.                   perforations on printed listings.  EJECT pseudo-op
  4308.                   added.
  4309.  
  4310.       2.07        Oops.  Configuration file now works as advertised.
  4311.  
  4312.       2.06        CHASM now supports reverse long jumps.
  4313.  
  4314.       2.05        Compiled version released.  BSAVE pseudo-op.
  4315.                   Configuration process simplified.
  4316.  
  4317.       2.04        TABs are now expanded and replaced with blanks, for
  4318.                   compatibility with IBM text editors.
  4319.  
  4320.       2.03        Two bugs corrected.  The first bug involved incorrect
  4321.                   assembly of indirect memory references which used a
  4322.                   displacement in the range 128-255.  The second caused
  4323.                   a program crash if a hex number longer than 4 digits
  4324.                   was in found in the input file.
  4325.  
  4326.       2.01        COM2DATA utility added.
  4327.  
  4328.       2.00        Corrected a bug in the DS and DB pseudo-ops which
  4329.                   caused the last label in a program to be redefined as
  4330.                   a memory location.  Also, the TAB character was added
  4331.                   as a new delimiter, and PRIMER.DOC was added to the
  4332.                   CHASM package.
  4333.  
  4334.       1.9         The short jump is now represented with mnemonic JMPS,
  4335.                   for compatibility with DEBUG version 1.1. (*)
  4336.  
  4337.       1.8         The operand type "character" was added as a new way
  4338.                   to represent immediate data.
  4339.  
  4340.  
  4341.  
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.  
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354.  
  4355.  
  4356.  
  4357.  
  4358.                                                                      64
  4359.  
  4360.  
  4361.       1.7         The DS operator now works for blocks larger than 255
  4362.                   bytes.  Also, the OFFSET function now works properly
  4363.                   in the displacement field of an indirect memory
  4364.                   reference.
  4365.  
  4366.       1.6         A revision of this document.  Some sections were
  4367.                   improved slightly, and in response to user requests,
  4368.                   a section on execution of assembled programs was
  4369.                   added.
  4370.  
  4371.       1.5         Corrected an error which generated the message "Data
  4372.                   too Long" if the value FFH was used as 8 bit
  4373.                   immediate data.
  4374.  
  4375.       1.4         User interface improved.  CHASM now traps some common
  4376.                   input errors such as misspelling a file name, or
  4377.                   forgetting to turn on your printer.
  4378.  
  4379.       1.3         A speed enhancement.  Version 1.3 benchmarks about 5
  4380.                   times faster than version 1.2.
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.                                                                      65
  4425.  
  4426.       >>Miscellaneous and A Word From Our Sponsor...<<
  4427.  
  4428.       A. Programming Notes:
  4429.  
  4430.          1. CHASM is written in Turbo Pascal.  The source code is
  4431.             available to registered users by sending a formatted disk
  4432.             and stamped return mailer.  If you make any improvements,
  4433.             I'd like to hear about them for possible inclusion in
  4434.             future releases.
  4435.  
  4436.             Please note that although you can modify CHASM for your own
  4437.             use, under NO CIRCUMSTANCES may you distribute modified or
  4438.             translated versions, either in the public domain or for
  4439.             profit.
  4440.  
  4441.       B. Red Tape and Legal Nonsense:
  4442.  
  4443.          1. Disclaimer:
  4444.  
  4445.             CHASM is distributed as is, with no guarantee that it will
  4446.             work correctly in all situations.  In no event will the
  4447.             Author be liable for any damages, including lost profits,
  4448.             lost savings or other incidental or consequential damages
  4449.             arising out of the use of or inability to use these
  4450.             programs, even if the Author has been advised of the
  4451.             possibility of such damages, or for any claim by any other
  4452.             party.
  4453.  
  4454.             Despite the somewhat imposing statement above, it *is* my
  4455.             intention to fix any bugs which are brought to my
  4456.             attention.  See the appendix on Bug Reporting for more
  4457.             details.
  4458.  
  4459.          2. Copyright Information:
  4460.  
  4461.             The entire CHASM distribution package, consisting of the
  4462.             main program, documentation files, and various data and
  4463.             utility files, is copyright (c) 1983, 1984 and 1985 by
  4464.             David Whitman.  The author reserves the exclusive right to
  4465.             distribute this package, or any part thereof, for profit.
  4466.             The name "CHASM (tm)", applied to a microcomputer assembler
  4467.             program, is a trade mark of David Whitman.
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480.  
  4481.  
  4482.  
  4483.  
  4484.  
  4485.  
  4486.  
  4487.  
  4488.  
  4489.  
  4490.                                                                      66
  4491.  
  4492.             CHASM's Subset version and various subsidiary files may be
  4493.             copied freely by individuals for evaluation purposes.  It
  4494.             is expected that those who find the package useful will
  4495.             make a contribution directly to the author of the program.
  4496.             The Subset version identifies itself by displaying a banner
  4497.             page giving the author's address and inviting free copying.
  4498.             ONLY VERSIONS DISPLAYING THIS BANNER PAGE MAY BE COPIED.
  4499.  
  4500.             CHASM's Advanced version is only available to registered
  4501.             users who have made the $40 suggested payment.  Registered
  4502.             users may copy the program for backup purposes, but must
  4503.             restrict use of the program to either one user or one CPU,
  4504.             at their option.
  4505.  
  4506.             CHASM's source code is made available for educational
  4507.             purposes and to allow users to customize for their own
  4508.             personal use.  Under NO CIRCUMSTANCES may modified versions
  4509.             or translations into other computer languages be
  4510.             distributed, either in the public domain or for profit.
  4511.  
  4512.             User groups and clubs are authorized to distribute CHASM's
  4513.             Subset version under the following conditions:
  4514.  
  4515.             1.  No charge is made for the software or documentation.  A
  4516.                 nominal distribution fee may be charged, provided that
  4517.                 it is no more than $8 total.
  4518.  
  4519.             2.  Recipients are to be informed of the user-supported
  4520.                 software concept, and encouraged to support it with
  4521.                 their donations.
  4522.  
  4523.             3.  The program and documentation are not modified in ANY
  4524.                 way, and are distributed together.
  4525.  
  4526.             Interested manufacturers are invited to contact Whitman
  4527.             Software to discuss licensing CHASM for bundling with
  4528.             MS-DOS based computer systems. 
  4529.  
  4530.             Distribution of CHASM outside the United States is through
  4531.             licensed distributors, on a royalty basis.  Interested
  4532.             distributors are invited to contact Whitman Software. 
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.                                                                      67
  4557.  
  4558.          3. Royalty Information: 
  4559.  
  4560.             No royalties are required to distribute programs produced
  4561.             using CHASM.  However, if you send me a copy of any major
  4562.             program you have produced using CHASM, I'll give you a free
  4563.             page of advertising in this document. 
  4564.  
  4565.          4. Educational Discount:
  4566.  
  4567.             Substantial discounts are available for multi-CPU licenses
  4568.             of CHASM's Advanced version to educational institutions.
  4569.             Contact Whitman Software for details.
  4570.  
  4571.       C. An Offer You Can't Refuse. 
  4572.  
  4573.          CHASM is User-Supported software, distributed under a
  4574.          modification of the FREEWARE (tm) marketing scheme developed
  4575.          by Andrew Fluegelman, whose efforts are gratefully
  4576.          acknowledged. 
  4577.  
  4578.          Anyone may obtain a free copy of CHASM's Subset version by
  4579.          sending a blank, formatted diskette to the author. An
  4580.          addressed, postage-paid return mailer must accompany the disk
  4581.          (no exceptions, please). 
  4582.  
  4583.          A copy of the program, with documentation, will be sent by
  4584.          return mail.  The program will carry a notice suggesting a
  4585.          payment to the program's author.  Making the payment
  4586.          is totally voluntary on the part of the user.  Regardless of
  4587.          whether a payment is made, the user is encouraged to
  4588.          share the program with others.  Payment for use is
  4589.          discretionary on the part of each subsequent user. 
  4590.  
  4591.  
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.  
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621.  
  4622.                                                                      68
  4623.  
  4624.          The underlying philosophy here is based on three principles: 
  4625.  
  4626.          First, that the value and utility of software is best assessed
  4627.             by the user on his/her own system.  Only after using a
  4628.             program can one really determine whether it serves personal
  4629.             applications, needs, and tastes. 
  4630.  
  4631.          Second, that the creation of independent personal computer
  4632.             software can and should be supported by those who benefit
  4633.             from its use.  Remember the Tanstaafl principal:  There
  4634.             Ain't No Such Thing as a Free Lunch.
  4635.  
  4636.          Finally, that copying and networking of programs should be
  4637.             encouraged, rather than restricted.  The ease with which
  4638.             software can be distributed outside traditional commercial
  4639.             channels reflects the strength, rather than the weakness,
  4640.             of electronic information. 
  4641.  
  4642.         If you like this software, please help support it.  Your
  4643.         support can take three forms: 
  4644.  
  4645.         1. Become a registered user.  The suggested payment for
  4646.            registration is $40.
  4647.  
  4648.         2. Suggestions, comments, and bug reports.  Your comments will
  4649.            be taken seriously - user feedback was responsible for most
  4650.            of the changes listed in CHASM's revision history. 
  4651.  
  4652.         3. Spread the word.  Make copies of the Subset for friends.
  4653.            Write the editor of your favorite computer magazine.
  4654.            Astronomical advertising costs are one big reason that
  4655.            commercial software is so overpriced.  To continue offering
  4656.            CHASM this way, I need your help in letting other people
  4657.            know about CHASM. 
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683.  
  4684.  
  4685.  
  4686.  
  4687.  
  4688.                                                                      69
  4689.  
  4690.         Those who make the $40 payment to become registered users
  4691.         receive the following benefits:
  4692.  
  4693.         1. An upgrade to the Advanced version of the program. The
  4694.            Advanced version executes twice as fast as the Subset and
  4695.            supports macros, operand expressions and other features.  An
  4696.            order form for the Advanced version is given at the end of
  4697.            this manual. 
  4698.  
  4699.         2. User support, by phone or mail.  Support is only
  4700.            available to registered users.  Phone numbers and the
  4701.            address for help are given below.
  4702.  
  4703.         3. Notices announcing the release of significant upgrades.
  4704.  
  4705.       CHASM is copyrighted, and users are requested NOT to make copies
  4706.       of the Advanced version other than for their own use.  I am
  4707.       strongly opposed to copy protection, and would regret being
  4708.       forced to protect CHASM.  Please recognize the amount of time and
  4709.       money which went into producing CHASM, and respect the wishes of
  4710.       the author. 
  4711.  
  4712.             David Whitman
  4713.             136 Wellington Terrace
  4714.             Lansdale, PA 19446
  4715.  
  4716.             (215) 641-7114 (days)
  4717.             (215) 362-8526 (evenings)
  4718.  
  4719.  
  4720.  
  4721.  
  4722.  
  4723.  
  4724.  
  4725.  
  4726.  
  4727.  
  4728.  
  4729.  
  4730.  
  4731.  
  4732.  
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  
  4753.  
  4754.                                                                      70
  4755.  
  4756.       Appendix A: Mnemonic List
  4757.  
  4758.       This appendix lists the mnemonics which CHASM will recognize,
  4759.       grouped roughly by function.  Consult "The 8086 Book" for
  4760.       definitions of these instructions, and for the operands each will
  4761.       accept.  Mnemonics marked with an asterisk (*) will accept a 'B'
  4762.       or 'W' suffix for ambiguous memory references.
  4763.  
  4764.       Arithmetic:
  4765.  
  4766.       AAA      AAD       AAM       AAS       ADC*      ADD*      CBW
  4767.       CWD      CMP*      CMPS*     DAA       DAS       DEC*      DIV*
  4768.       IDIV*    IMUL*     INC*      MUL*      NEG*      SBB*      SUB* 
  4769.  
  4770.       Data Movement:
  4771.  
  4772.       LAHF     LDS       LEA       LES       LODS*     MOV*     MOVS*
  4773.       POP      POPF      PUSH      PUSHF     SAHF      STOS*    XCHG
  4774.       XLAT
  4775.  
  4776.       Logical:
  4777.  
  4778.       AND*     NOT*      OR*       TEST*     XOR* 
  4779.  
  4780.       String Primitives:
  4781.  
  4782.       CMPS*    LODS*     MOVS*     SCAS*     STOS*
  4783.  
  4784.       Instruction Prefixes:
  4785.  
  4786.       LOCK     REP       REPE      REPNE     REPNZ     REPZ      SEG
  4787.  
  4788.       Program Counter Control: (unconditional)
  4789.  
  4790.       CALL     CALLN     CALLF     JMP       JMPF      JMPN      JMPS
  4791.       RET
  4792.  
  4793.       Program Counter Control: (conditional)
  4794.  
  4795.       JA       JAE      JB      JBE      JC        JCXZ       JE
  4796.       JG       JGE      JL      JLE      JNA       JNAE       JNB
  4797.       JNBE     JNC      JNE     JNG      JNGE      JNL        JNLE
  4798.       JNO      JNO      JNP     JNS      JNZ       JO         JP
  4799.       JPE      JPO      JS      JZ       LOOP      LOOPE      LOOPNE
  4800.       LOOPNZ   LOOPZ
  4801.  
  4802.  
  4803.  
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.  
  4810.  
  4811.  
  4812.  
  4813.  
  4814.  
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.                                                                      71
  4821.  
  4822.  
  4823.       Processor Control:
  4824.  
  4825.       CLC      CLD       CLI       CMC       HLT       NOP       STC
  4826.       STD      STI       WAIT
  4827.  
  4828.       I/O:
  4829.  
  4830.       IN       OUT
  4831.  
  4832.       Interrupt:
  4833.  
  4834.       INT      INTO      IRET
  4835.  
  4836.       Rotate and Shift:
  4837.  
  4838.       RCL*     RCR*      ROL*      ROR*      SAL*      SAR*      SHL*
  4839.       SHR*
  4840.  
  4841.  
  4842.  
  4843.  
  4844.  
  4845.  
  4846.  
  4847.  
  4848.  
  4849.  
  4850.  
  4851.  
  4852.  
  4853.  
  4854.  
  4855.  
  4856.  
  4857.  
  4858.  
  4859.  
  4860.  
  4861.  
  4862.  
  4863.  
  4864.  
  4865.  
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871.  
  4872.  
  4873.  
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.                                                                      72
  4887.  
  4888.       Appendix B: Differences Between CHASM and That Other Assembler
  4889.  
  4890.       Virtually all magazine articles about assembly language
  4891.       programming on the IBM PC assume that the reader is using That
  4892.       Other Assembler - you know, the one that costs $150.  This
  4893.       appendix will try to summarize the differences between the two
  4894.       programs.  Please note that I do not own a copy of That Other
  4895.       Assembler, and therefore this section is not complete, nor even
  4896.       guaranteed to be correct.  Anyone with more experience is
  4897.       invited to make additions or corrections.
  4898.  
  4899.       A. General Differences
  4900.  
  4901.       The biggest difference is philosophical.  The IBM assembler was
  4902.       designed for use by professional assembly language programmers,
  4903.       to write operating systems and other huge projects.  This is
  4904.       reflected in the large size and relative complexity of the macro
  4905.       assembler.
  4906.  
  4907.       On the other hand, CHASM was designed for use by beginners, to
  4908.       write relatively short programs.  This was done by leaving out a
  4909.       some of the power offered by IBM's assembler, in exchange for
  4910.       simplicity and small size.  The main simplification involved
  4911.       producing object code in the COM format, rather than the EXE
  4912.       format chosen by IBM. There are two main consequences of this
  4913.       choice:
  4914.  
  4915.          1. You can't link routines assembled by CHASM to
  4916.             Microsoft languages. (Although you *can* include them in
  4917.             Turbo Pascal or BASIC programs.)
  4918.  
  4919.          2. Your program has to fit in one 64K segment.  If (shudder!)
  4920.             you want to write a 256K assembly language program, you're
  4921.             out of luck.
  4922.  
  4923.       Like Pascal, the IBM assembler is a strongly typed language.  By
  4924.       requiring you to specify the *type* of each memory location you
  4925.       will access in your program, the IBM assembler generally knows
  4926.       what size of memory operand you want.  If you don't like the
  4927.       declared size, you have to overide the default with the PTR
  4928.       operator.  Thus, to loading the AL register from a location
  4929.       declared word is a syntax error, unless you specify BYTE PTR
  4930.       before the address.
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.  
  4946.  
  4947.  
  4948.  
  4949.  
  4950.  
  4951.  
  4952.                                                                      73
  4953.  
  4954.       In analogy to the C language, CHASM is weakly typed. CHASM is
  4955.       perfectly happy extracting a byte from where you originally set
  4956.       aside a word - CHASM can't tell the difference. In most cases,
  4957.       CHASM can tell what size you want from context:  if you're using
  4958.       a word register, it's a word memory access. On the other hand,
  4959.       for any access to memory which doesn't have a register as the
  4960.       other operand, you must add either a 'B' or a 'W' to the
  4961.       instruction mnemonic used by IBM.
  4962.  
  4963.       B. Miscellaneous Differences:
  4964.  
  4965.          1. Short Jumps:
  4966.  
  4967.             IBM uses the SHORT keyword, CHASM uses an 'S' suffix.
  4968.             Example:
  4969.  
  4970.             JMP   SHORT label    ;ibm
  4971.             JMPS  label          ;chasm
  4972.  
  4973.          2. Offset Function:
  4974.  
  4975.             Where IBM precedes an operand with the keyword OFFSET,
  4976.             CHASM has a *function* called OFFSET. CHASM requires
  4977.             parentheses around the operand. Example:
  4978.  
  4979.             MOV   AX, OFFSET FCB  ;ibm
  4980.             MOV   AX, OFFSET(FCB) ;chasm
  4981.  
  4982.          3. Declaring Storage:
  4983.  
  4984.             A.  If you don't care what value a memory location is
  4985.                 initialized to, the IBM assembler allows you to specify
  4986.                 '?' as its contents.  In CHASM, if you don't care what
  4987.                 value the variable is initialized to, just put down a
  4988.                 zero.  Example:
  4989.  
  4990.                    DB   ?      ;ibm
  4991.                    DB   0      ;chasm
  4992.  
  4993.  
  4994.  
  4995.  
  4996.  
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.  
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.                                                                      74
  5019.  
  5020.             B.  The IBM assembler allows the keyword DUP as an operand
  5021.                 in storage declaring pseudo-ops.  This means to repeat
  5022.                 the definition as many times as the number just before
  5023.                 the DUP.  Example:
  5024.  
  5025.                 DW   3 DUP(?)  ;ibm
  5026.                 DW   0, 0, 0   ;chasm
  5027.  
  5028.       4. ASSUME Pseudo-op:
  5029.  
  5030.          IBM's ASSUME pseudo-op tells the assembler where the segment
  5031.          registers will be pointing.  CHASM always assumes that the CS,
  5032.          DS and SS registers point to the beginning of the code
  5033.          segment, and that the SS register has been set up to point to
  5034.          a valid stack area.  If you find an ASSUME pseudo-op where the
  5035.          CS, DS and ES registers point to different locations, you will
  5036.          have to figure out the addresses for memory references in the
  5037.          DS or ES segments yourself.
  5038.  
  5039.       5. Segment Pseudo-op:
  5040.  
  5041.          This pseudo-op is used to set up multiple segments in the IBM
  5042.          assembler.  Since CHASM only allows one segment, there is no
  5043.          equivalent pseudo-op.  If there is only one segment definition
  5044.          in an IBM assembler program, everything is fine, just leave
  5045.          the pseudo-op out for CHASM.
  5046.  
  5047.          Often times the SEGMENT pseudo-op is used to provide
  5048.          addressing of an area in the BIOS, or perhaps the interrupt
  5049.          vector table at the beginning of memory.  For example, if a
  5050.          program needed to get at the BIOS data area, in the IBM
  5051.          assembler you would define a dummy segment with the same
  5052.          structure as that in the BIOS listing in Technical Reference:
  5053.  
  5054.            DATA          SEGMENT AT 40H
  5055.            RS232_BASE    DW    4 DUP(?)
  5056.            PRINTER_BASE  DW    4 DUP(?)
  5057.            EQUIP_FLAG    DW    ?
  5058.            MFG_TST       DB    ?
  5059.            MEMORY_SIZE   DW    ?
  5060.            IO_RAM_SIZE   DW    ?
  5061.  
  5062.          All this is really accomplishing is giving a name to some
  5063.          memory locations which are outside the actual program being
  5064.          written.
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.                                                                      75
  5085.  
  5086.  
  5087.          In CHASM, you can simulate the dummy segment using a
  5088.          structure.  This will generate a series of immediate operands
  5089.          whose values correspond to the offsets of the labels in the
  5090.          dummy segment.  You can then reference the locations by
  5091.          enclosing the label names in square brackets, to coerce from
  5092.          type immediate to type address.
  5093.  
  5094.            DUMMY         STRUC            ;simulate dummy segment
  5095.            RS232_BASE    DW    0, 0, 0, 0
  5096.            PRINTER_BASE  DW    0, 0, 0, 0
  5097.            EQUIP_FLAG    DW    0
  5098.            MFG_TST       DB    0
  5099.            MEMORY_SIZE   DW    0
  5100.            IO_RAM_SIZE   DW    0
  5101.                          ENDSTRUC
  5102.                          MOV AX, [EQUIP_FLAG]
  5103.  
  5104.       6. Labels:
  5105.  
  5106.          The macro assembler indicates a local label by appending a
  5107.          colon (:).  The colon does not become part of the label, and
  5108.          is not included when referencing the label.  CHASM's labels
  5109.          are all global, and although they may end with a colon, the
  5110.          colon will become part of the label itself, and must then be
  5111.          used when referencing the label.  Example:
  5112.  
  5113.          a2:   mov ax,cx      ;ibm
  5114.                jmp a2         ; "
  5115.  
  5116.          a2:   mov ax,cx      ;chasm
  5117.                jmp a2:        ;  "
  5118.  
  5119.       7. Entry Point:
  5120.  
  5121.          The macro assembler allows you to specify the point within
  5122.          your program where execution will begin.  A label is put
  5123.          on the entry point, then to indicate entry, the same label is
  5124.          placed on the "END" pseudo-op.  Since COM programs must always
  5125.          start at offset 100H, CHASM doesn't allow setting an entry
  5126.          point.
  5127.  
  5128.  
  5129.  
  5130.  
  5131.  
  5132.  
  5133.  
  5134.  
  5135.  
  5136.  
  5137.  
  5138.  
  5139.  
  5140.  
  5141.  
  5142.  
  5143.  
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.  
  5150.                                                                      76
  5151.  
  5152.       Appendix C: Description of Files
  5153.  
  5154.       Your CHASM distribution disk contains a number of files.  This
  5155.       appendix will give a brief statement of the purpose of each.
  5156.  
  5157.       FILE           DESCRIPTION
  5158.       ----------------------------------------------------------------
  5159.       CHASM.CFG       Sample configuration file, for IBM printer.
  5160.  
  5161.       CHASM.COM       The CHASM program (either subset or advanced)
  5162.  
  5163.       CHASMS.COM      This file may appear on the disk of advanced
  5164.                       version users.  It is the current subset version,
  5165.                       that can be shared with others.  Please rename it
  5166.                       CHASM.COM on their disk, to avoid confusion.
  5167.  
  5168.       CHASM.DOC       This document.
  5169.  
  5170.       EXAMPLE.ASM     Sample source file.
  5171.  
  5172.       COM2DATA.ASM    Source code for COM2DATA filter.
  5173.  
  5174.       COM2DATA.DOC    Documentation for COM2DATA.
  5175.  
  5176.       FREEWARE.DOC    References to other User Supported programs.
  5177.  
  5178.       PRIMER.DOC      Simple introduction to assembly language.
  5179.  
  5180.       Occasionally, various other sample source files for CHASM will be
  5181.       distributed.  These files will have extension ASM, and will be
  5182.       accompanied by a corresponding DOC file.
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  
  5196.  
  5197.  
  5198.  
  5199.  
  5200.  
  5201.  
  5202.  
  5203.  
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.                                                                      77
  5217.  
  5218.       Appendix D: Bug Reporting Procedure
  5219.  
  5220.       Although each version of CHASM is tested extensively prior to
  5221.       release, any program of this magnitude is bound to contain a few
  5222.       bugs.  It is the intention of Whitman Software to correct any
  5223.       genuine problem which is reported.
  5224.  
  5225.       If you think you have found a bug in CHASM, please take the time
  5226.       to report it for correction.  Although any report is helpful,
  5227.       correction of the problem will be easiest if you provide the
  5228.       following:
  5229.  
  5230.          1. The version of CHASM you are using.  Your problem may have
  5231.             been fixed already!
  5232.  
  5233.          2. A brief description of what you believe the problem to be.
  5234.  
  5235.          3. A printed listing of a source file which manifests the
  5236.             problem.
  5237.  
  5238.             * DON'T send a 5,000 line program which has one
  5239.               manifestation of the bug!  Isolate the problem area, or
  5240.               write a short sample routine that demonstrates the bug.
  5241.  
  5242.       Unlike normal commercial software, where corrections are saved up
  5243.       for major a revision, bugs in CHASM are fixed as soon as
  5244.       reported, with a new version released almost immediately (which
  5245.       is why there are so many versions in CHASM's revision history).
  5246.  
  5247.                      =====> BONUS <======
  5248.  
  5249.       If you send a copy of your problem source file on disk, it will
  5250.       be returned with either a new, corrected version of CHASM, or
  5251.       with an explanation of what you were doing wrong to *think* you'd
  5252.       found a bug.
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.                                                                      78
  5283.  
  5284.       Appendix E: Using CHASM on "Compatible" Systems
  5285.  
  5286.       CHASM was written specifically for the IBM PC, but should
  5287.       function normally on true "compatibles".  This appendix is a new
  5288.       section to summarize compatibility data for various systems.
  5289.  
  5290.       Since CHASM version 4.00 is a totally new program, little
  5291.       compatibility data is currently available.  If you are using (or
  5292.       are unable to use...) CHASM on a non-IBM computer, please write
  5293.       with your experiences.  Does CHASM work correctly on your system?
  5294.       Are there specific problem areas?  Can they be worked around?
  5295.  
  5296.       The following systems are known to run CHASM version 4.00
  5297.       successfully:
  5298.  
  5299.              IBM PC
  5300.              IBM XT
  5301.              IBM 3270 PC and 3270 PC/G
  5302.              Zenith 150
  5303.  
  5304.       The following systems have one or more problems:
  5305.  
  5306.       ================================================================
  5307.       Tandy 1200HD - version 4.00 seems to crash this system.  The
  5308.       problem has not yet been isolated.  Input from others with access
  5309.       to a Tandy 1200HD would be appreciated.
  5310.       ================================================================
  5311.  
  5312.  
  5313.  
  5314.  
  5315.  
  5316.  
  5317.  
  5318.  
  5319.  
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.                                                                      79
  5349.  
  5350.             ********ADVANCED VERSION ORDER FORM********
  5351.  
  5352.       Please add me to the list of registered CHASM users, and send me
  5353.       an upgrade to Advanced CHASM.  I understand that CHASM is
  5354.       copyrighted, and agree not to distribute any unauthorized copies
  5355.       of this Advanced version.
  5356.  
  5357.       Note that version 4.00 requires DOS 2 (or later) and 128K
  5358.  
  5359.       Computer Model: ____________________________________
  5360.  
  5361.       Diskette format:            Total Memory: _______K
  5362.                                      (128K required)
  5363.          __ single sided/DOS 2
  5364.  
  5365.          __ doubled sided/DOS 2
  5366.  
  5367.       Check one:
  5368.  
  5369.              ___ I enclose a check for $40
  5370.  
  5371.              ___ I am a past customer.  The enclosed check brings my
  5372.                  total payment up to $40.
  5373.  
  5374.  
  5375.       Where did you hear about CHASM? ________________________________
  5376.  
  5377.       Name:    _______________________________________________________
  5378.  
  5379.       Address: _______________________________________________________
  5380.  
  5381.       City, State, Zip: ______________________________________________
  5382.  
  5383.  
  5384.       ================================================================
  5385.            Send order form and check to:
  5386.  
  5387.                 Whitman Software
  5388.                 136 Wellington Terrace
  5389.                 Lansdale, PA 19446
  5390.  
  5391.  
  5392.  
  5393.  
  5394.  
  5395.  
  5396.  
  5397.  
  5398.  
  5399.  
  5400.  
  5401.  
  5402.  
  5403.  
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  
  5410.  
  5411.  
  5412.  
  5413.  
  5414.                                                                      80
  5415.  
  5416.         ==============PRINTER ENHANCEMENT===================
  5417.  
  5418.  
  5419.       Michael Hoyt, of Soft and Friendly Software, has produced a set
  5420.       of printer enhancement programs using CHASM, which is sold under
  5421.       the name Prowriter Utilities.  The package supports the following
  5422.       printers:
  5423.  
  5424.           NEC 8023A-C
  5425.           Prowriter I  (C. Itoh 8510)
  5426.           Prowriter II (C. Itoh 1550)
  5427.  
  5428.       The package contains three programs:
  5429.  
  5430.           PRINT_CHARACTERS
  5431.           PRINT_SCREEN
  5432.           PRINT_SET
  5433.  
  5434.       Once PRINT_CHARACTERS is run, it attaches itself to DOS, and
  5435.       makes your printer have exactly the same character set as your
  5436.       video monitor.  The conversion is very professionally done.
  5437.       Particularly impressive are the line drawing characters, which
  5438.       actually form connected lines, both horizontally and vertically.
  5439.  
  5440.       As if this wasn't enough, PRINT_CHARACTERS adds italics
  5441.       capability as well.  The italics make very effective emphasis in
  5442.       documents and letters, and look really good.
  5443.  
  5444.       PRINT_SCREEN is a graphics screen dump, activated by the normal
  5445.       Shift/PrtSc sequence.  Several options are available which trade
  5446.       off speed and print quality.  Since I have the mono card, I
  5447.       haven't tried PRINT_SCREEN, but Michael sent me a sample printout
  5448.       which looked quite nice.
  5449.  
  5450.       PRINT_SET is a menu-driven program to turn on and off the various
  5451.       special printing modes supported by these printers.  A simple but
  5452.       effective program.
  5453.  
  5454.       I've been using this package with my NEC 8023 for a few months
  5455.       now, and I like them quite a bit.  To get a copy, send $35 to:
  5456.  
  5457.           Soft and Friendly
  5458.           RR 2 Box 65
  5459.           Solsberry, IN 47459
  5460.  
  5461.  
  5462.  
  5463.  
  5464.  
  5465.  
  5466.  
  5467.  
  5468.  
  5469.  
  5470.  
  5471.  
  5472.  
  5473.  
  5474.  
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  
  5480.                                                                      81
  5481.  
  5482.  
  5483.  
  5484.            ================= NEW PRODUCT ==================
  5485.  
  5486.       If you use the IBM/Microsoft BASIC compiler, chances are your
  5487.       programs are bigger and slower than they have to be.  If all
  5488.       unreferenced line numbers are removed from your source program,
  5489.       and the /N switch is used, BASCOM will "optimize" your program.
  5490.       The result is tighter, more efficient code.
  5491.  
  5492.       NUMZAP is a utility which carefully scans your source file, and
  5493.       deletes all the non-essential line numbers.  Performing this task
  5494.       by hand would be prohibitively time consuming and you'd probably
  5495.       introduce errors into your program in the process.  NUMZAP will
  5496.       do the job in minutes, 100% error free.
  5497.  
  5498.       The old BASIC version of CHASM was passed through NUMZAP, and the
  5499.       resulting compiled code shrank by a factor of 10% (!).  That 10%
  5500.       reduction could make the difference between your program running
  5501.       in 64K, or having users with minimal systems get "Out of Memory"
  5502.       messages just before your program crashes.
  5503.  
  5504.       An added advantage to using NUMZAP is that bigger programs can be
  5505.       compiled.  You may not be aware that there is a limit on the size
  5506.       of program which the compiler can handle.  BASCOM uses up space
  5507.       remembering the offset of each line number in your program. If
  5508.       you have too many numbered lines, BASCOM will run out of room and
  5509.       you'll get a unending series of "TC" (Too Complex) error
  5510.       messages.  By eliminating the unneeded line numbers, you give
  5511.       BASCOM more elbow room.  The free space available to compile
  5512.       CHASM increased 27% (!) after using NUMZAP.
  5513.  
  5514.       NUMZAP is available under the standard FREEWARE deal - just send
  5515.       a formatted disk and self-addressed, stamped return mailer to:
  5516.  
  5517.                   David Whitman
  5518.                   136 Wellington Terrace
  5519.                   Lansdale, PA 19446
  5520.  
  5521.       Be sure to specify that you are interested in NUMZAP.  If you
  5522.       like the program, a donation of $15 is suggested.
  5523.  
  5524.  
  5525.  
  5526.  
  5527.  
  5528.  
  5529.  
  5530.  
  5531.  
  5532.  
  5533.  
  5534.  
  5535.  
  5536.  
  5537.  
  5538.  
  5539.  
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.