home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / ASMUTL / CHEAPASM.ZIP / CHASM.DOC < prev    next >
Encoding:
Text File  |  1987-01-11  |  47.3 KB  |  2,003 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.      
  8.      
  9.      
  10.      
  11.      
  12.      
  13.      
  14.      
  15.      
  16.      
  17.                                    (tm)
  18.                               CHASM
  19.      
  20.      
  21.                         Cheap Assembler 
  22.                   for the IBM Personal Computer
  23.      
  24.                      (1983) by David Whitman
  25.                            Version 1.9
  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.                                                                       1 
  72.  
  73.                        Table of Contents
  74.      
  75.      Why Chasm?...........................................2
  76.      
  77.      What can Chasm do?...................................3
  78.      
  79.      What WON'T it do?....................................3
  80.      
  81.      Syntax...............................................4
  82.      
  83.      Operands.............................................6
  84.      
  85.      Resolution of Ambiguities...........................10
  86.      
  87.      Pseudo-Operations...................................13
  88.      
  89.      Outside the Program Segment.........................16
  90.      
  91.      Running Chasm.......................................18
  92.      
  93.      Error and Diagnostic Messages.......................20
  94.      
  95.      Execution of Assembled Programs.....................23
  96.      
  97.      Notes for Those Upgrading to This Version of Chasm..26
  98.      
  99.      Miscellaneous and A Word From Our Sponsor...........28
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.                                                                       2 
  138.  
  139.      I. Why Chasm?
  140.          
  141.          Why go to the trouble to write an assembler, when
  142.      one already exists?  The IBM Macro Assembler is a very
  143.      powerful software tool available off the shelf.  It
  144.      supports features such as macros, definition of
  145.      multiple segments, and linking to external procedures.
  146.          
  147.          Unfortunately, all of this power doesn't fit into a
  148.      64K machine, and even when using the small subset
  149.      version, 64K users are limited by memory to only very
  150.      small programs. The macro assembler is also very
  151.      complex, hard to understand, and costs a hundred bucks.
  152.          
  153.          Even though the price of memory keeps dropping, I
  154.      suspect that the majority of the IBM PC's out there have
  155.      no more than 64K installed.  Also, I suspect that most
  156.      end-user assembly language programmers are like myself,
  157.      and are not interested in writing huge, complicated
  158.      programs in assembler. I want to write short
  159.      subroutines to call from BASIC, small patches to
  160.      existing assembler programs (such as DOS), and perhaps
  161.      some games. For such uses, I think the combination of
  162.      the Macro Assembler and a tub full of extra memory
  163.      represents an incredible overkill. Chasm is, I hope, a
  164.      more reasonable compromise between power and
  165.      accessability (both in cost and complexity).
  166.  
  167.  
  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.  
  201.  
  202.  
  203.                                                                       3 
  204.  
  205.      II. What can Chasm do?
  206.      
  207.          Chasm takes a text file, consisting of mnemonics,
  208.      user-defined symbols, numbers, and pseudo-ops, and
  209.      produces a file of corresponding machine language for
  210.      the 8088 processor. Chasm allows you to define labels
  211.      for branching, rather than requiring you to figure out
  212.      offsets or addresses to jump to.  It allows you to
  213.      represent with a name any constants you want to use,
  214.      making your programs easier to understand. Most
  215.      importantly, it translates mnemonics to their machine
  216.      language equivalents freeing you from the task of hand
  217.      translation.
  218.          
  219.      III. What WON'T it do?
  220.      
  221.          In the interest of simplicity, Chasm has a number
  222.      of restrictions:
  223.      
  224.          1. Statement syntax is not quite as free as in the
  225.             macro assembler.
  226.          
  227.          2. The number of pseudo-ops is severely cut down
  228.             from the macro assembler.
  229.          
  230.          3. Macros are not supported.  (Note that the IBM
  231.             assembler doesn't support macros in systems
  232.             smaller than 96K)
  233.          
  234.          4. Expressions (such as BUFFER - 2 ) are not
  235.             supported, at least in version 1.0.
  236.          
  237.          5. Multiple segment definitions are not allowed, at
  238.             least in version 1.0. Chasm assumes that your
  239.             entire program fits in one segment, that the cs,
  240.             ds, and es registers all point to this same
  241.             segment, and that the ss register points to a
  242.             valid stack area.
  243.          
  244.          6. External linking is not supported, at least in
  245.             version 1.0.
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.                                                                       4 
  270.  
  271.      IV. Syntax
  272.      
  273.      Chasm accepts a standard DOS text file for input. Lines
  274.      may be any combination of upper and lower case
  275.      characters. Chasm does not distinguish between the two
  276.      cases:  everything except single quoted strings are
  277.      automatically converted to upper case during the
  278.      parsing process. Thus, BUFFER, Buffer, buffer, and
  279.      bUFFer all refer to the same symbol.
  280.      
  281.      The characters  blank ( ) , comma (,), single quote (')
  282.      and semi-colon (;) are reserved, and have special
  283.      meaning to Chasm (see below).
  284.      
  285.      Note also that Chasm is written in BASIC, and use of
  286.      the double quote charactor (") may cause bizarre
  287.      effects by confusing the interpreter into breaking down
  288.      input lines in an undesirable way.  The double quote
  289.      may be safely represented in a text message by
  290.      declaring a byte containing its ASCII value. Thus, to
  291.      represent the text:
  292.      
  293.      Use ASCII value for "double quotes"
  294.      
  295.      You may use:
  296.      
  297.      DB 'Use ASCII value for ' 22H 'double quotes' 22H
  298.      
  299.      Each line must be less than 256 characters long and
  300.      have the following format:
  301.      
  302.      Label Operation Operand(s) ;comment
  303.      
  304.      The differant fields of an input line are separated
  305.      by the delimiters blank ( ) or comma (,).  Any number of
  306.      either delimiter may be used to separate fields. 
  307.      
  308.      Explanation of Fields:
  309.      
  310.      Label: A label is a string of characters, beginning in
  311.         column 1. Depending on the operation field, the label
  312.         might represent a program location for branching, a
  313.         memory location, or a numeric constant. Note that
  314.         anything  beginning in column 1, except a comment, is
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.                                                                       5 
  336.  
  337.         considered a label.
  338.      
  339.      Operation: Either a pseudo-op (see section VII) or an
  340.         instruction mnemonic as defined in "The 8086 Book" by
  341.         Rector and Alexy.
  342.      
  343.         Note 1: Except as modified below,"The 8086 Book" is
  344.            the definitive referance for use with Chasm.
  345.      
  346.         Note 2: There are several ways to resolve some
  347.            ambiguities in 8086 assembly language. Please read
  348.            page 3-285 of The 8086 Book, and section VI of
  349.            this document. 
  350.      
  351.      Operand(s): A list of one or more operands,as defined
  352.         in section V, separated by delimiters.
  353.      
  354.      Comment: Any string of characters, beginning with a
  355.         semicolon (;).  Anything to the right of a semicolon
  356.         will be ignored by Chasm.
  357.      
  358.      Note that except for the case of an operation which
  359.      requires operands, or the EQU pseudo-op which requires
  360.      a label, all of the fields are optional. The fields
  361.      MUST appear in the order shown. 
  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.  
  399.  
  400.  
  401.                                                                       6 
  402.  
  403.      V. Operands
  404.      
  405.      The following operand types are allowed.
  406.      
  407.      1. Immediate data: A number, stored as part of the
  408.         program's object code.  Immediate data are classified
  409.         as either byte, expressable as an 8 bit binary
  410.         integer; or word, expressable as a 16 bit binary   
  411.         integer. If context requires it, CHASM will left-pad
  412.         byte values with zeroes to convert them to word values.     
  413.         Attempts to use a word value where only a byte will    
  414.         fit will cause an error message to be printed.
  415.      
  416.      Immediate data may be represented in 5 ways:
  417.      
  418.         A. An optionally signed decimal number in the range
  419.            -32768 to 32767. Examples:
  420.      
  421.             MOV AL,21
  422.             MOV BX,-6300
  423.      
  424.         B. A series of up to 4 hex digits, followed by the
  425.            letter H. Examples:
  426.      
  427.            ADD CX,1234H
  428.            ADD DL FDH
  429.      
  430.         C. A symbol representing types A or B above,
  431.            defined using the EQU pseudo-op.  Examples:
  432.      
  433.            MASK EQU 10H
  434.            MAX  EQU 1000
  435.                 AND  CL,MASK
  436.                 SUB  AX,MAX
  437.      
  438.         D. The offset of a label or storage location returned
  439.            by the OFFSET operator.  OFFSET always returns a
  440.            word value. OFFSET is used to get the address
  441.            of a named memory location, rather than its contents. 
  442.            Example:
  443.      
  444.                   MOV DI,OFFSET(BUFFER)
  445.            BUFFER DS  FFH
  446.      
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.                                                                       7 
  468.  
  469.         E. The ASCII value of a printable character,
  470.            represented by the character enclosed in single
  471.            quotes (').  Thus, the following lines will
  472.            generate the same object code:
  473.      
  474.                   MOV AL,41H  ;ascii code for 'A'
  475.                   MOV AL,'A'
  476.      
  477.      2. Register Operands: One of the 8088's internal
  478.         registers.
  479.      
  480.         A. An 8 bit register from the following list:
  481.            AH    AL
  482.            BH    BL
  483.            CH    CL
  484.            DH    DL
  485.      
  486.         B. A 16 bit register from the following list:
  487.            AX   BX   CX   DX   SP   BP   SI   DI
  488.      
  489.         C. A segment register from the following list:
  490.            CS   SS   DS   ES
  491.      
  492.      3. Memory Operands: The contents of a memory
  493.         location addressed by one of the following
  494.         methods. Note that none of the memory
  495.         adressing options specifies the whether a
  496.         byte or word operand is being referanced.
  497.         See section VI for more on this topic.
  498.      
  499.         A. Direct address.
  500.      
  501.            1. A number, or symbol representing a
  502.               number, enclosed in brackets, indicating
  503.               an offset into the data segment. Example:
  504.      
  505.               BUFFER EQU 5A5AH
  506.                      MOV BH,[BUFFER]
  507.                      MOV [80H],DI
  508.      
  509.            2. A symbol, defined to be a variable (i.e.
  510.               a named memory location) using the EQU
  511.               pseudo-op. Example:
  512.      
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.                                                                       8 
  534.  
  535.                   FCB EQU [80H]
  536.                       MOV DI,FCB
  537.          
  538.             3. A symbol, defined to be a variable by its
  539.                use on a storage defining pseudo-op.
  540.                Examples:
  541.          
  542.                     MOV AX,FLAG
  543.                     MOV DATE,BX
  544.                FLAG DS 1
  545.                DATE DB 31
  546.          
  547.          B. Indirect Address:  The address of the operand is
  548.             the sum of the contents of the indicated
  549.             register(s) and a displacement. The register, or
  550.             sum of registers, are enclosed in square
  551.             brackets: [] 
  552.      
  553.             The displacement is optional, and takes the
  554.             form of an immediate operand, placed without
  555.             intervening delimiters to the left of the first
  556.             bracket.  Displacements in the range -128 to 127
  557.             (i.e. hex 0 - 7F, FF80 - FFFF) are interpreted as
  558.             signed 8 bit quantities. All other displacements
  559.             are interpreted as unsigned 16 bit quantities.
  560.             (Note that although the 8088 supports unsigned 16
  561.             bit displacements up to hex FFFF for indirect
  562.             adressing, Chasm isn't smart enough to distinguish
  563.             between -1 and FFFFH.)
  564.      
  565.             The following indirect modes are allowed:
  566.          
  567.             1. Indirect through a base register (BX or BP).
  568.                Examples:
  569.          
  570.                ENTRYLENGTH EQU 6
  571.                            MOV AX, ENTRYLENGTH[BP]
  572.                            MOV DL, -2[BX]
  573.                            MOV CX, [BP]
  574.                            MOV 9A9AH[BX], AX
  575.          
  576.             2. Indirect through an index register (DI or SI).
  577.                Examples:
  578.          
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.                                                                       9 
  600.  
  601.                MOV [DI], CX
  602.                MOV CX, -5[SI]
  603.          
  604.             3. Indirect through the sum of one base register
  605.                and one index register. Examples:
  606.          
  607.                MOV [BP+DI], SP      ;note that no spaces are
  608.                MOV BX, 10H[BX+SI]   ;allowed within the
  609.                MOV CL, [BP+SI]      ;brackets.
  610.                MOV DH, -2[BX+DI]
  611.      
  612.        4. Labels
  613.          
  614.             A label on a machine instruction may be used as
  615.             an operand for call and jump instructions.
  616.             Examples:
  617.         
  618.                START PROC NEAR
  619.                      CALL GETINPUT
  620.                      JMPS START
  621.                      ENDP
  622.             GETINPUT PROC NEAR
  623.          
  624.        5. Strings
  625.             A string is any sequence of characters (including
  626.             delimiters) surrounded by single quotes (').
  627.             Example:
  628.      
  629.             DB 'Copyright May 15,1982'
  630.      
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.                                                                       10 
  666.  
  667.      VI. Resolution of Ambiguities.
  668.          
  669.          The language defined in "The 8086 Book" contains a
  670.      number of ambiguities which must be resolved by an
  671.      assembler. This is discussed throughout the book, but
  672.      pages 3-285 and 3-286 specifically cover this topic.
  673.      Chasm's solutions of these problems are discussed in
  674.      this section.
  675.          
  676.      A. Memory referances:
  677.      
  678.          When one specifies the address of a memory
  679.      location, it is unclear how large an operand is being
  680.      referanced. An operand might be a byte, or a word.
  681.          
  682.          1. If a register is present as an operand, it is
  683.             assumed that the memory operand matches the
  684.             register in size. An exception to this rule are
  685.             the shift and rotate instructions, where the CL
  686.             register is used as a counter, and has nothing
  687.             to do with the size of the other operand. Examples:
  688.          
  689.             MOV MASK,AX   ;mask is a word
  690.             MOV DH,[BX]   ;BX points to a byte
  691.             NEG [SI]      ;error, operand of unknown size
  692.             SHR FLAG,CL   ;error, flag is of unknown size
  693.          
  694.          2. If no register is present, (or if the only
  695.             register is CL being used as a counter) the size
  696.             of the memory operand is specified by adding the
  697.             suffix "B" or "W" to the instruction mnemonic.
  698.             Examples:
  699.      
  700.             NEGB [SI]       ;SI points to a byte
  701.             SHRW FLAG,CL    ;flag is a word
  702.             MOVW MASK,0AH   ;mask is a word
  703.             MOVB MASK,0AH   ;mask is a byte
  704.             MOVW MASK,9A9AH ;must specify size even though 
  705.                             ;immediate operand implies word
  706.             MOVB DH,[BX]    ;error(!), register already
  707.                             ;specifies size
  708.          
  709.      B. Indirect Branching.
  710.      
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.                                                                       11 
  732.  
  733.          The 8088 supports two flavors of indirect
  734.      branching: intra, and inter segment. A register is set
  735.      to point at a memory location which contains a new
  736.      value for the program counter, and in the case of
  737.      intersegment branching, a new value for the CS register
  738.      as well.
  739.          
  740.          The syntax of "The 8086 Book" does not specify
  741.      which flavor of branch is being invoked.  Chasm adds
  742.      the suffixes "N" (for near, or intrasegment) and "F"
  743.      (for far, or intersegment) to the indirect CALL and JMP
  744.      mnemonics. Examples:
  745.          
  746.          CALLN [BX]    ;intrasegment call
  747.          JMPF  [DI]    ;intersegment jump
  748.          JMP   [BP]    ;error, unspecified flavor
  749.          
  750.      C. Long and Short Jumps
  751.          
  752.      Two types of relative jumps are supported by the
  753.      8088: short (specified by a signed 8 bit displacement)
  754.      and long (specified by an unsigned 16 bit displacement).         
  755.      Both are implemented in Chasm as a jump to a label.
  756.      
  757.      The short jump is specified by mnemonic JMPS, in accord       
  758.      with the IBM disassembler, but not with The 8086 Book, which 
  759.      uses JMP.  Since one of the displacement bits is used as a sign
  760.      bit, only seven are left to express the magnitude of jump.  JMPS
  761.      (and similarly, all the jump on condition instructions) is thus
  762.      limited to branching to labels within a range of -128 to +127
  763.      bytes.
  764.      
  765.      Chasm reserves mnemonic JMP for the long jump.  Note that JMP      
  766.      may only be used to jump in the forward direction, since the       
  767.      sixteen bit displacement is unsigned, and assumed to be positive.  
  768.      Examples:
  769.      
  770.          START PROC NEAR
  771.                JMPS START   ;short jump
  772.                JMPS END     ;short jump
  773.                JMP  END     ;long jump
  774.                JMP  START   ;error: reverse long jump
  775.          END   ENDP
  776.      
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.                                                                       12 
  798.  
  799.      D. Instruction Prefixes.
  800.          
  801.          The 8088 supports three instruction prefixes:
  802.          
  803.          1. SEG: segment override. An alternate segment
  804.             register is specified for a referance to memory
  805.          
  806.          2. REP, REPE,REPNE,REPZ,REPNZ: repeat. A string
  807.             primitive is repeated until a condition is met.
  808.          
  809.          3. LOCK: Turns on the LOCK signal. Only useful in
  810.             multiprocessor situations.
  811.          
  812.          Chasm implements these prefixes as separate
  813.      instructions, rather than prefixes to another
  814.      instruction.  They appear on a separate line,
  815.      immediately before the instruction which they modify.
  816.      This is in accord with the output of the IBM
  817.      disassembler, but not with the IBM macro assembler.
  818.      Examples:
  819.          
  820.          SEG ES
  821.          MOV AX,FLAG  ;flag is in the extra segment
  822.          REP
  823.          MOVSB        ;move bytes until CX decremented to 0
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.                                                                       13 
  864.  
  865.      VII. Pseudo-Operations
  866.          
  867.          The following pseudo-ops are implemented:
  868.          
  869.          A. DB: Declare Bytes
  870.          
  871.             Memory locations are filled with values from the
  872.             operand list. Any number of operands may appear,
  873.             but all must fit on one line. Acceptable operands
  874.             are numbers between 0 and FFH (0-255 decimal), or
  875.             strings enclosed in single quotes (').  If a label
  876.             appears, it is considered a variable, and the
  877.             location may be refered to using the label, rather
  878.             than an address. Examples:
  879.          
  880.                     MOV AX,MASK
  881.               MASK  DB  00H,01H
  882.               STG   DB  'A string operand'
  883.          
  884.          B. DS: Declare Storage
  885.          
  886.             Used to declare large blocks of identically
  887.             initialized storage.  The first operand is
  888.             required, a number specifying how many bytes
  889.             are declared.  If a second operand in the form
  890.             of a number 0-FFH appears, the locations will
  891.             all be initialized to this value. If the second
  892.             operand is not present, locations are initialized
  893.             to 0. As with DB, any label is considered a 
  894.             variable.  To save space, the object code does not
  895.             appear on the listing. Examples:
  896.      
  897.             DS 10         ;10 locs initialized to 0
  898.             DS 100H,1AH   ;256 locs initialized to 1AH
  899.          
  900.          C. ENDP: End of Procedure
  901.          
  902.             See PROC (below) for details.
  903.          
  904.          D. EQU: Equate
  905.      
  906.             Used to equate a symbolic name with a number.
  907.             The symbol may then be used anywhere the
  908.             number would be used.  Use of symbols makes
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.                                                                       14 
  930.  
  931.             programs more understandable, and simplifies
  932.             modification. 
  933.          
  934.             An alternate form of EQU encloses the number
  935.             in square brackets: [].  The symbol is then
  936.             interpreted as a variable, and may be used as an
  937.             address for memory access.  This version is
  938.             provided to allow symbolic referance to locations
  939.             outside the program segment.
  940.      
  941.             Warning: Difficult to debug errors may result
  942.             from using a symbol prior to its being defined
  943.             by EQU.  I strongly urge that all equates be
  944.             grouped together at the beginning of programs,
  945.             before any machine instructions. See "Phase Error"
  946.             in section IX. Examples:
  947.          
  948.                 MOFFSET    EQU B000H
  949.                 MONOCHROME EQU [0000H]
  950.          
  951.          E. ORG: Origin
  952.          
  953.             Allows direct manipulation of the location
  954.             counter during assembly.  By default, Chasm
  955.             assembles code to start at offset 100H, the
  956.             origin expected by COMMAND.COM for .COM
  957.             programs.  Using ORG you may override this
  958.             default. Example:
  959.          
  960.                ORG 0   ;Code will be assembled for starting
  961.                        ;offset of 0
  962.          
  963.          F. PROC ...ENDP: Procedure Definition
  964.      
  965.             Declares a procedure.  One operand is required on
  966.             PROC, either the word NEAR, or the word FAR.
  967.             This pseudo-op warns Chasm whether to assemble
  968.             returns as intra (near) or intersegment (far).
  969.             Procedures called from within your program should
  970.             be declared NEAR. All others should be FAR.
  971.             ENDP terminates the procedure, and requires no
  972.             operands.  If a RET is encountered outside of a
  973.             declared procedure, an error occurs.  Procedures
  974.             may be nested, up to 10 deep. Example:
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.                                                                       15 
  996.  
  997.      
  998.                 MAIN   PROC  FAR
  999.                        ...
  1000.                        ...      ;body of procedure
  1001.                        ENDP
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.                                                                       16 
  1062.  
  1063.      VIII. Outside the Program Segment
  1064.          
  1065.          As mentioned previously, Chasm does not support
  1066.      multiple segment definitions.  Provision is made for
  1067.      limited access outside of the program segment, however.
  1068.          
  1069.          A. Memory Referances
  1070.             To access memory outside the program segment, you
  1071.             simply move a new segment address into the DS
  1072.             register, then address using offsets in the new
  1073.             segment.  The memory option of the EQU pseudo-op
  1074.             allows you to give a variable name to offsets in
  1075.             other segments. For example, to access the graphics
  1076.             charactor table in ROM:
  1077.      
  1078.             BIOS       EQU  F000H
  1079.             CHARTABLE  EQU  [FA6EH]
  1080.                        MOV  AX,BIOS   ;can't move immed. to DS 
  1081.                        MOV  DS,AX
  1082.                        MOV  AL,CHARTABLE ;1st byte of char. table
  1083.          
  1084.          B. Code Branching
  1085.      
  1086.             Chasm supports 4 instructions for branching
  1087.             outside the program segment.
  1088.      
  1089.             1. Direct CALL and JMP
  1090.                New values for the PC and CS registers are
  1091.                included in the instruction as two immediate
  1092.                operands. Example:
  1093.          
  1094.                BIOS        EQU  F000H    ;RAM bios segment
  1095.                DISKETE_IO  EQU  EC59     ;disk handler
  1096.                            JMP  DISKETE_IO,BIOS
  1097.      
  1098.             2. Indirect CALLF and JMPF
  1099.                Four consecutive bytes in memory are
  1100.                initialized with new values for the PC and CS
  1101.                registers.  The CALLF or JMPF then referances
  1102.                the address of the new values. Example:
  1103.          
  1104.                BIOS        EQU   F000H    ;RAM bios segment
  1105.                PRINTER_IO  EQU   EFD2H    ;printer routine  
  1106.                            MOV   [DI],PRINTER_IO
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.                                                                       17 
  1128.  
  1129.                            MOV   2[DI],BIOS
  1130.                            CALLF [DI]
  1131.          
  1132.      
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.                                                                       18 
  1194.  
  1195.       
  1196.      IX. Running Chasm
  1197.          
  1198.          From DOS, type:
  1199.          
  1200.          CHASM
  1201.          or
  1202.          BASIC CHASM/C:0
  1203.          
  1204.          After a few seconds, Chasm prints a hello screen,
  1205.      then prompts:
  1206.          
  1207.          Hit any key to continue...
  1208.          
  1209.          Chasm prompts:
  1210.          
  1211.          Source code file name? [.asm]
  1212.          
  1213.          Type in the name of the file which contains your
  1214.      program. If you do not include an extension for the
  1215.      filename, Chasm assumes it to be .ASM.  If Chasm is
  1216.      unable to find the file, it will give you the option
  1217.      of naming another file, or returning to DOS.
  1218.          
  1219.          Assuming your file is present, Chasm prompts:
  1220.          
  1221.          Direct listing to Printer (P), Screen (S), or Disk
  1222.      (D)?
  1223.          
  1224.          Respond with either an upper or lower case letter.
  1225.      If you select "D", Chasm will prompt:
  1226.          
  1227.          Name for listing file? [fname.lst] 
  1228.      
  1229.          Type in a name for the listing file.  If you just
  1230.      press ENTER, the name defaults to that of your source
  1231.      file, with an extension of .LST.
  1232.          
  1233.          The final prompt is:
  1234.          
  1235.          Name for object file? [fname.com]
  1236.          
  1237.          Type in a name for the assembled program.  If you
  1238.      just press ENTER, the name defaults to that of your
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.                                                                       19 
  1260.  
  1261.      source file, with an extension of .COM.
  1262.          
  1263.          Chasm now assembles your program.  A status line is
  1264.      maintained on the screen, showing how many lines have
  1265.      been processed. Chasm makes two passes over your source
  1266.      file, outputting the listing and object code on the
  1267.      second pass.  Be patient, Chasm is written in BASIC,
  1268.      and does a good imitation of  a snail crawling through
  1269.      molasses.
  1270.      
  1271.      
  1272.          ****NOTE: I will send the Golden Bootstrap Award to
  1273.      the first person submitting a complete implementation
  1274.      of Chasm, rewritten in assembly language, and small
  1275.      enough to be assembled by Chasm version 1.0 on a 64K
  1276.      system.
  1277.           
  1278.          When finished, Chasm returns you to DOS, and you
  1279.      see the prompt:
  1280.          
  1281.          A>
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.                                                                       20 
  1326.  
  1327.      X. Error and Diagnostic Messages
  1328.      
  1329.      Error messages generated on pass one appear on the 
  1330.      listing before any source code is printed, and mention
  1331.      the line number to which they refer.  The majority of
  1332.      messages occur during pass two, and will appear in the
  1333.      listing immediately prior to the line which caused the
  1334.      message.
  1335.          
  1336.      Could Use JMPS: Diagnostic.  The specified label
  1337.         requires an offset of less than 128 bytes; specifying
  1338.         the short jump would result in more compact code.
  1339.         The assembled code is correct, however.
  1340.          
  1341.      Data too Long: The value of a immediate byte is
  1342.         found not to be in the range 0-FFH
  1343.          
  1344.      Duplicate Definition of XXX in (linenum): Pass 1
  1345.         error. An attempt was made to define a symbol already
  1346.         present in the symbol table.
  1347.          
  1348.      ENDP without PROC: An ENDP was encountered, but no
  1349.         corresponding PROC was found.
  1350.          
  1351.      EQU Without Label: No symbol was found to equate
  1352.         with the operand
  1353.          
  1354.      Illegal or Undefined Argument for Offset: The
  1355.         argument for the Offset function was not present in
  1356.         the symbol table as a near label or memory location
  1357.         on pass 2.
  1358.      
  1359.      Illegal Reverse Long Jump: Long jumps must in the
  1360.         forward direction, since they are expressed with an
  1361.         unsigned displacement.
  1362.          
  1363.      Missing ENDP: The end of the input file was
  1364.         encountered, and at least one PROC had not been
  1365.         terminated by an ENDP.
  1366.          
  1367.      Phase Error: A near label or memory location is
  1368.         found to have differant values on pass 1 and pass 2.
  1369.         A difficult to debug error: generally the problem is
  1370.         not caused by the statement which received the error
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.                                                                       21 
  1392.  
  1393.         message.
  1394.      
  1395.            The only documented way to generate this error is
  1396.         by using a symbol prior to defining it using EQU. On
  1397.         pass 1, Chasm assumes that unrecognized symbols are
  1398.         either labels or memory addresses which will be
  1399.         defined later in the program.  If the symbol is
  1400.         subsequently defined as immediate data, the location
  1401.         counter may get all messed up.  I would appreciate
  1402.         hearing about any other situations which cause this
  1403.         message to appear.
  1404.      
  1405.      Procedures Nested Too Deeply: Procedures may be
  1406.         nested no more than 10 deep.
  1407.          
  1408.      Specify Word or Byte Operation: Diagnostic. Chasm
  1409.         suggests that the Syntax Error might be resolved by
  1410.         adding the suffix "B" or "W" to the instruction
  1411.         mnemonic.  Most, but not all, ambiguous memory
  1412.         referances are flagged with this diagnostic. 
  1413.        
  1414.      Syntax Error: (OP) (DTYPE) (STYPE).  Chasm was
  1415.         unable to find a version of the instruction (OP)
  1416.         which allows the operand types (DTYPE) and (STYPE).
  1417.         Either the instruction doesn't exist, or it is misspelled, 
  1418.         or it is an inappropriate choice for the given operands.
  1419.         DTYPE and STYPE are numbers which encode Chasm's
  1420.         guess as to what the 1st and 2nd operands might be.
  1421.         The numbers are sums of the types given in the following
  1422.         list: 
  1423.      
  1424.           1 = 8 bit accumulator          2 = 16 bit accumulator
  1425.           4 = 8 bit register             8 = 16 bit register
  1426.          16 = a register or indirect    32 = CS register
  1427.               memory referance
  1428.          64 = other segment register   128 = memory location
  1429.         256 = immediate byte           512 = immediate word
  1430.        1024 = none                    2048 = string
  1431.        4096 = near label              8192 = far label
  1432.       16384 = CL (count) register
  1433.          
  1434.      Too Far For Short Jump: The displacement to the
  1435.         specified label is not in the range -128 to +127.
  1436.          
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.                                                                       22 
  1458.  
  1459.      Too Many User Symbols in (linenum): Pass one error.
  1460.         The symbol table is full.
  1461.          
  1462.      Undefined Operand for EQU: Any operands on an EQU
  1463.         statement must have been previously defined.
  1464.          
  1465.      Undefined Symbol XXX: The symbol XXX was used as an
  1466.         operand, but never appeared as a label, and is not a
  1467.         predefined symbol.
  1468.          
  1469.      Unrecognized Operand XXX: XXX is used in the DB
  1470.         operand list, but is not a string or byte value.
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  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.  
  1521.  
  1522.  
  1523.                                                                       23 
  1524.  
  1525.      XI. Execution of Assembled Programs
  1526.      
  1527.      A. Object code format
  1528.      
  1529.      The object code file produced by CHASM is in the form
  1530.      of a memory image, exactly as will be present in your
  1531.      computer at run time.  No link step is required.
  1532.      Provided that the segment registers are set correctly,
  1533.      the architecture of the 8088 guarantees that code is
  1534.      self-relocating, and will run correctly loaded anywhere
  1535.      in memory. Storing a program as an exact image of
  1536.      memory at run time is called the COM format by IBM.
  1537.      
  1538.      This COM format is *not* that produced by the IBM
  1539.      assembler.  The output of the IBM assembler is in the
  1540.      form of an "object module" suitable for input to the
  1541.      linker.  To the best of my knowlege, the object module
  1542.      is not directly executable, but must first be "filtered"
  1543.      through the linker.  This adds an extra step to the
  1544.      process of producing a working program, but gives you
  1545.      the option of combining multiple object modules into
  1546.      one program.  The resulting linked program is *still*
  1547.      not a memory image, but has a header which is used to
  1548.      perform relocation during loading.  This linked program
  1549.      plus header is called the EXE format by IBM.
  1550.      
  1551.      B. Running Assembled Programs From DOS
  1552.      
  1553.      DOS provides a loader for running machine language
  1554.      programs.  To run a program, you merely type it's name,
  1555.      with or without the extension.  This is what you're
  1556.      doing every time you use a DOS external command such as
  1557.      FORMAT or CHKDSK.  In fact, the COM format is named
  1558.      after "external COMmand".
  1559.      
  1560.      When you type the name, DOS examines the file extension
  1561.      to determine what format the file is in, either COM or
  1562.      EXE.  This is why CHASM defaults to using the extension
  1563.      .com for your object file.  If you plan to run the
  1564.      program from DOS, don't change the extension. 
  1565.      
  1566.      For COM programs, DOS builds a 255 byte long "program
  1567.      segment prefix" and sets the segment registers to point
  1568.      to this PSP.  The contents of the file are then loaded
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.                                                                       24 
  1590.  
  1591.      verbatim right after the PSP, at offset hex 100 in the
  1592.      segment defined by the segment registers.  As soon as
  1593.      loading is complete, your program is executed starting
  1594.      with the instruction at hex 100.  Although you can
  1595.      totally ignore the PSP, you should read pages E-3
  1596.      through E-11 of the DOS manual to see what DOS puts
  1597.      there for you.  It turns out there are some real goodies
  1598.      which your program might want to use.
  1599.      
  1600.      When your program is done, it must transfer control
  1601.      back to DOS, otherwise the 8088 will continue to fetch
  1602.      what it believes are instructions from whatever garbage
  1603.      or bit-hash happens to follow your program in memory.
  1604.      The easiest way to return to DOS is to execute the
  1605.      instruction:
  1606.      
  1607.      INT 20H
  1608.      
  1609.      This is the vectored interrupt reserved by DOS for
  1610.      program termination.
  1611.      
  1612.      While we're on the topic of vectored interrupts, you
  1613.      would be well rewarded to study both the DOS manual and
  1614.      Technical Referance to find out what happens when you
  1615.      execute some of the other interrupts.  Some very useful
  1616.      functions, such as file handling and screen i/o, are
  1617.      available at the machine language level through this
  1618.      mechanism.
  1619.      
  1620.      By changing the interrupt vector for a given function
  1621.      to point to your own code, you can overide the way DOS
  1622.      or the BIOS does something, and do it your way.  This
  1623.      document was produced from Easywriter directly, in
  1624.      standard DOS format, by printing it to disk.  It was
  1625.      not necessary to manually add an end of paragraph
  1626.      marker at the end of each line, and I didn't need to
  1627.      run it through the program TRANSFER which IBM provides.
  1628.      I had changed the vector for printer support to point
  1629.      to some code which sent the output to disk.  Easywriter
  1630.      thought it was using the printer, and formatted
  1631.      everything nicely.
  1632.      
  1633.      C. Debugging Assembled Programs
  1634.      
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.                                                                       25 
  1656.  
  1657.      IBM provides an excellent utility with DOS, called
  1658.      DEBUG.COM.  By specifying your program's name as a
  1659.      parameter when invoking DEBUG, you can observe your
  1660.      program execute with DEBUG's trace and other functions.
  1661.      To debug your program from DOS, type:
  1662.      
  1663.      DEBUG progname.COM
  1664.      
  1665.      DEBUG builds a PSP and loads your program just like DOS
  1666.      does, but you have the added power of the debugging
  1667.      commands to monitor your program while it runs.  See
  1668.      chapter 6 of the DOS manual for more details about
  1669.      using DEBUG.
  1670.      
  1671.      D. Using Assembled Programs in BASIC
  1672.      
  1673.      To incorporate a machine language subroutine in a BASIC
  1674.      program, write it in assembly language, then assemble
  1675.      it with CHASM.  You should read page C-7 of the BASIC
  1676.      manual for some conventions to use in writing your
  1677.      subroutine.  In particular, note that you must declare
  1678.      the routine to CHASM as a FAR procedure using the PROC
  1679.      pseudo-op, and that the last instruction of the routine
  1680.      should be a RET.
  1681.      
  1682.      For short routines, probably the easiest way to get the
  1683.      code into a BASIC program is to just hand copy the
  1684.      object code from the listing into a DATA statement. The
  1685.      BASIC program can then READ the data and POKE it into
  1686.      memory.  An example program to do this is given on page
  1687.      C-6 of the BASIC manual.  An alternative approach would
  1688.      be to store the routine in a string variable, which
  1689.      could later be located with the VARPTR function.
  1690.      
  1691.      You transfer control to your routine with either the
  1692.      USR  function, or the CALL statement.  Syntax for these
  1693.      statements can be found in the BASIC manual.
  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.  
  1719.  
  1720.  
  1721.                                                                       26 
  1722.  
  1723.      XII. Notes for Those Upgrading to This Version of
  1724.           Chasm.
  1725.      
  1726.      Chasm is not yet cast in stone - improvements and
  1727.      corrections are made fairly frequently, based on both
  1728.      my own experiance in using the program, and the
  1729.      comments of outside users.  This section summarizes the
  1730.      changes which have been made since version 1.2 was
  1731.      released.
  1732.      
  1733.      The only change which could invalidate an already
  1734.      correct program involves the short jump instruction.
  1735.      Versions prior to 1.9 represented this instruction with
  1736.      mnemonic JP.  This mnemonic was chosen to be in accord
  1737.      with the output of the unassemble command of DEBUG.
  1738.      Either I simply made a mistake in this regard, or IBM
  1739.      changed the mnemonic in the DEBUG supplied with DOS
  1740.      1.1.  At any rate, DEBUG 1.1 represents the short jump
  1741.      with mnemonic JMPS, and CHASM now follows this syntax.
  1742.      JP is now recognized as an alternate form of
  1743.      instruction JPE (jump on even parity), in accord with
  1744.      The 8086 Book.
  1745.      
  1746.      Version 1.8 added the operand type "character" as a new
  1747.      way to represent immediate data.  A single character
  1748.      enclosed in single quotes (') is equivalent to the
  1749.      numeric value of the ASCII code for the character.  See
  1750.      section V-1-E of this document for details.
  1751.      
  1752.      As of version 1.7, the DS operator works for blocks
  1753.      larger than 255 bytes.  To keep the listing under
  1754.      control, object code generated by DS is no longer shown
  1755.      on the listing.
  1756.      
  1757.      Also corrected in version 1.7, the OFFSET function now
  1758.      works properly in the displacement field of an indirect
  1759.      memory referance.
  1760.      
  1761.      Version 1.6 was a revision of this document.  Some
  1762.      sections were improved slightly, and in response to
  1763.      user requests, a section on execution of assembled
  1764.      programs was added.
  1765.      
  1766.      Version 1.5 corrected an error which generated the
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.                                                                       27 
  1788.  
  1789.      message "Data too Long" if the value FFH was used as 8
  1790.      bit immediate data.
  1791.      
  1792.      The user interface was improved as of version 1.4.
  1793.      Chasm now traps some common input errors such as
  1794.      misspelling a file name, or forgetting to turn on your
  1795.      printer, giving you a second chance rather than just
  1796.      crashing.
  1797.      
  1798.      Version 1.3 involved a speed improvement by a factor of
  1799.      5 over 1.2.  Users should note that a number of copies
  1800.      labeled as version 1.2 actually incorporate this
  1801.      improvement.
  1802.      
  1803.      As can be seen, revisions are made frequently.  It is
  1804.      my policy that after once contributing, users are
  1805.      entitled to all future versions free of charge, with no
  1806.      further donation expected.  Contributing users are
  1807.      encouraged to send a disk and return mailer from time
  1808.      to time, to receive the most current version.  Major
  1809.      improvements will be announced in IPCO INFO and
  1810.      Programmer's Journal.
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.                                                                       28 
  1854.  
  1855.      XIII. Miscellaneous and A Word From Our Sponsor...
  1856.      
  1857.          There is a bewildering array of files on your disk.
  1858.      As you've discovered by now, the file CHASM.DOC is
  1859.      documentation, and need not be present for Chasm to
  1860.      run.  Some of the others may need explanation, however.
  1861.      
  1862.          The actual program is in CHASM.BAS.  To run the
  1863.      program, three other files *must* be present.  You must
  1864.      copy BASIC.COM from your DOS disk to interpret the
  1865.      program.  CHASM.DAT contains data about the various
  1866.      instruction mnemonics Chasm recognizes, and must be
  1867.      present.  The last file needed is CHASM.OVL.  OVL is an
  1868.      empty file, which is merged to fool BASIC into
  1869.      deleting some of the initialization code to make
  1870.      more room for the symbol table.
  1871.      
  1872.         The file CHASM.BAT is a batch file to make it easier
  1873.      to start Chasm from DOS.  With CHASM.BAT, you can just
  1874.      type: chasm.  Without it you'd type: basic chasm/c:0.
  1875.      
  1876.          TCHASM.BAT is a batch file use to breed new CHASM
  1877.      disks, if you want to give a copy to someone else.  It
  1878.      copys the program, documentation, data; the whole
  1879.      works.  Please only distribute the complete CHASM
  1880.      system, as generated by this batch file.
  1881.      
  1882.          CLS.ASM is provided as a sample source file.  You
  1883.      can try out Chasm using CLS as input.
  1884.          
  1885.      Programming Notes:
  1886.          
  1887.          1. Chasm is written in heavilly commented BASIC, so
  1888.             modifications would be easy, if you'd like to
  1889.             customize. I'd like to hear about any improvements
  1890.             people make, for possible inclusion in future
  1891.             releases.
  1892.      
  1893.          2. If you do try to modify Chasm, there is a quirk
  1894.             you should know about.  Most of the
  1895.             initialization code is in a "transient section"
  1896.             which is used once, then deleted to make more
  1897.             room for the symbol table.   Lines 50,000 -
  1898.             65529 are reserved as this transient section.
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.                                                                       29 
  1920.  
  1921.             Note Well: If you run Chasm, then save it to
  1922.             disk, you save the program WITHOUT THE
  1923.             INITIALIZATION CODE.  The resulting program is
  1924.             non-functional.  Be careful! Keep a backup.
  1925.      
  1926.          3. Chasm truncates source lines to about 50
  1927.             characters in the listing, to avoid going over 
  1928.             an 80 charactor line. If your printer has a
  1929.             condensed mode with more than 80 characters/line,
  1930.             provision has been made for a simple
  1931.             customization to make Chasm turn on the
  1932.             special mode before listing, and print as many
  1933.             characters as possible.  The printer will be
  1934.             returned to normal when Chasm finishes.  The
  1935.             modification only affects listings to the
  1936.             printer, not to screen or disk.
  1937.      
  1938.             Find subroutine HEADER in the transient section.
  1939.             After the IF statement under the comment "printer
  1940.             set up?"  you must set the width of device #2 to
  1941.             the number of characters per line in condensed mode
  1942.             with a WIDTH#2 statement, and set the variable LWIDTH
  1943.             to this number minus 1.  Print whatever control
  1944.             sequence turns on your condensed mode, and set the
  1945.             variable PMODEOFF$ to a string which returns the
  1946.             printer to normal.  An example modification is embedded
  1947.             at the correct spot as a series of remarks.
  1948.      
  1949.      Disclaimer:  CHASM is distributed as is, with no guarantee
  1950.                   that it will work correctly in all situations.
  1951.                   I cannot be responsable for any damages 
  1952.                   associated with its use.  Nonetheless, it
  1953.                   is my intention to correct any genuine bugs
  1954.                   which are brought to my attention.  Drop
  1955.                   me a line if you think you've found a 
  1956.                   problem.
  1957.      
  1958.          I am joining the experiment started by the folks at
  1959.      Freeware (tm), by distributing un-protected software,
  1960.      and *encouraging* copying.  The catch, (of course
  1961.      there's a catch) is that I request that all users who
  1962.      think the program is worthwhile send a donation.  The
  1963.      suggested donation is $20, but send what you think the
  1964.      program is worth to *you*.  There is obviously no way I
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.                                                                       30 
  1986.  
  1987.      can enforce payment, but I hope people will recognize
  1988.      the amount of work that went into writing and
  1989.      documenting Chasm, and will make a donation.  If the
  1990.      monetary response is great enough, I will release upgrades to 
  1991.      this program (version 2.0 is already in the works) and
  1992.      other programs of comparible magnitude (future projects
  1993.      include a macro pre-processor to run in 64K for use with 
  1994.      either CHASM or BASIC).  I hope folks find CHASM
  1995.      useful.
  1996.      
  1997.      
  1998.                     David Whitman
  1999.                     Department of Chemistry
  2000.                     Dartmouth College
  2001.                     Hanover, NH 03755
  2002.                     (603) 643-2115
  2003.