home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 276_01 / a684.doc < prev    next >
Encoding:
Text File  |  1989-10-03  |  46.0 KB  |  1,236 lines

  1. /*
  2.     HEADER:        CUG276;
  3.     TITLE:        6804 Cross-Assembler (Portable);
  4.     FILENAME:    A684.DOC;
  5.     VERSION:    0.1;
  6.     DATE:        08/27/1988;
  7.  
  8.     DESCRIPTION:    "This program lets you use your computer to assemble
  9.             code for the Motorola 6804 family microprocessors.
  10.             The program is written in portable C rather than BDS
  11.             C.  All    assembler features are supported except
  12.             relocation linkage, and macros.";
  13.  
  14.     KEYWORDS:    Software Development, Assemblers, Cross-Assemblers,
  15.             Motorola, MC6804;
  16.  
  17.     SYSTEM:        CP/M-80, CP/M-86, HP-UX, MSDOS, PCDOS, QNIX;
  18.     COMPILERS:    Aztec C86, Aztec CII, CI-C86, Eco-C, Eco-C88, HP-UX,
  19.             Lattice C, Microsoft C,    QNIX C;
  20.  
  21.     WARNINGS:    "This program should compile under any full-featured
  22.             C compiler.  Subset compilers such as Toolworks C and
  23.             BDS C pose a problem."
  24.  
  25.     AUTHORS:    William C. Colley III;
  26. */
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.                            6804 Cross-Assembler (Portable)
  42.  
  43.  
  44.                                      Version 0.1
  45.  
  46.  
  47.                    Copyright (c) 1985, 1988 William C. Colley, III
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.                               The manual such as it is.
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.           Legal Note:    This package may be used for any commercial or
  67.                          non-commercial purpose.  It may be copied and
  68.                          distributed freely provided that any fee charged
  69.                          by the distributor of the copy does not exceed the
  70.                          sum of:  1) the cost of the media the copy is
  71.                          written on,  2) any required costs of shipping the
  72.                          copy, and  3) a nominal handling fee.  Any other
  73.                          distribution requires the written permission of
  74.                          the author.  Also, the author's copyright notices
  75.                          shall not be removed from the program source, the
  76.                          program object, or the program documentation.
  77.  
  78.  
  79.  
  80.                                   Table of Contents
  81.  
  82.           1.0  How to Use the Cross-Assembler Package ..................  3
  83.           2.0  Format of Cross-Assembler Source Lines ..................  4
  84.                2.1  Labels .............................................  5
  85.                2.2  Numeric Constants ..................................  5
  86.                2.3  String Constants ...................................  6
  87.                2.4  Expressions ........................................  6
  88.           3.0  Machine Opcodes .........................................  7
  89.                3.1  Opcodes -- No Arguments ............................  7
  90.                3.2  Opcodes -- Relative Branch Instructions ............  8
  91.                3.3  Opcodes -- Long Branch Instructions ................  8
  92.                3.4  Opcodes -- Bit Manipulation Instructions ...........  8
  93.                3.5  Opcodes -- Arithmetic and Logical Instructions .....  8
  94.                3.6  Opcodes -- MVI .....................................  9
  95.                3.7  Opcodes -- Short Direct Addressing .................  9
  96.           4.0  Pseudo Opcodes .......................................... 10
  97.                4.1  Pseudo-ops -- END .................................. 10
  98.                4.2  Pseudo-ops -- EQU .................................. 10
  99.                4.3  Pseudo-ops -- FCB .................................. 10
  100.                4.4  Pseudo-ops -- FCC .................................. 11
  101.                4.5  Pseudo-ops -- FDB .................................. 11
  102.                4.6  Pseudo-ops -- IF, ELSE, ENDIF ...................... 11
  103.                4.7  Pseudo-ops -- INCL ................................. 12
  104.                4.8  Pseudo-ops -- ORG .................................. 12
  105.                4.9  Pseudo-ops -- PAGE ................................. 13
  106.                4.10 Pseudo-ops -- RMB .................................. 13
  107.                4.11 Pseudo-ops -- SET .................................. 13
  108.                4.12 Pseudo-ops -- TITLE ................................ 13
  109.           5.0  Assembly Errors ......................................... 14
  110.                5.1  Error * -- Illegal or Missing Statement ............ 14
  111.                5.2  Error ( -- Parenthesis Imbalance ................... 14
  112.                5.3  Error " -- Missing Quotation Mark .................. 14
  113.                5.4  Error A -- Illegal Addressing Mode ................. 14
  114.                5.5  Error B -- Branch Target Too Distant ............... 15
  115.                5.6  Error D -- Illegal Digit ........................... 15
  116.                5.7  Error E -- Illegal Expression ...................... 15
  117.                5.8  Error I -- IF-ENDIF Imbalance ...................... 15
  118.                5.9  Error L -- Illegal Label ........................... 15
  119.                5.10 Error M -- Multiply Defined Label .................. 16
  120.                5.11 Error O -- Illegal Opcode .......................... 16
  121.                5.12 Error P -- Phasing Error ........................... 16
  122.                5.13 Error S -- Illegal Syntax .......................... 16
  123.                5.14 Error T -- Too Many Arguments ...................... 16
  124.                5.15 Error U -- Undefined Label ......................... 16
  125.                5.16 Error V -- Illegal Value ........................... 17
  126.           6.0  Warning Messages ........................................ 17
  127.                6.1  Warning -- Illegal Option Ignored .................. 17
  128.                6.2  Warning -- -l Option Ignored -- No File Name ....... 17
  129.                6.3  Warning -- -o Option Ignored -- No File Name ....... 17
  130.                6.4  Warning -- Extra Source File Ignored ............... 17
  131.                6.5  Warning -- Extra Listing File Ignored .............. 18
  132.                6.6  Warning -- Extra Object File Ignored ............... 18
  133.  
  134.  
  135.  
  136.  
  137.                                      1
  138.  
  139.  
  140.  
  141.           7.0  Fatal Error Messages .................................... 18
  142.                7.1  Fatal Error -- No Source File Specified ............ 18
  143.                7.2  Fatal Error -- Source File Did Not Open ............ 18
  144.                7.3  Fatal Error -- Listing File Did Not Open ........... 18
  145.                7.4  Fatal Error -- Object File Did Not Open ............ 18
  146.                7.5  Fatal Error -- Error Reading Source File ........... 18
  147.                7.6  Fatal Error -- Disk or Directory Full .............. 18
  148.                7.7  Fatal Error -- File Stack Overflow ................. 19
  149.                7.8  Fatal Error -- If Stack Overflow ................... 19
  150.                7.9  Fatal Error -- Too Many Symbols .................... 19
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  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.                                      2
  199.  
  200.  
  201.  
  202.           1.0  How to Use the Cross-Assembler Package
  203.  
  204.                First, the question, "What does a cross-assembler do?" needs
  205.           to be addressed as there is considerable confusion on this point.
  206.           A cross-assembler is just like any other assembler except that it
  207.           runs on some CPU other than the one for which it assembles code.
  208.           For example, this package assembles 6804 source code into 6804
  209.           object code, but it runs on an 8080, a Z-80, an 8088, or whatever
  210.           other CPU you happen to have a C compiler for.  The reason that
  211.           cross-assemblers are useful is that you probably already have a
  212.           CPU with memory, disk drives, a text editor, an operating system,
  213.           and all sorts of hard-to-build or expensive facilities on hand.
  214.           A cross-assembler allows you to use these facilites to develop
  215.           code for a 6804.
  216.  
  217.           This program requires one input file (your 6804 source code) and
  218.           zero to two output files (the listing and the object).  The input
  219.           file MUST be specified, or the assembler will bomb on a fatal
  220.           error.  The listing and object files are optional.  If no listing
  221.           file is specified, no listing is generated, and if no object file
  222.           is specified, no object is generated.  If the object file is
  223.           specified, the object is written to this file in "Intel
  224.           hexadecimal" format.
  225.  
  226.                The command line for the cross-assembler looks like this:
  227.  
  228.                     A684 source_file { -l list_file } { -o object_file }
  229.  
  230.           where the { } indicates that the specified item is optional.
  231.  
  232.                Some examples are in order:
  233.  
  234.                a684 test684.asm                   source:   test684.asm
  235.                                                   listing:  none
  236.                                                   object:   none
  237.  
  238.                a684 test684.asm -l test684.prn    source:   test684.asm
  239.                                                   listing:  test684.prn
  240.                                                   object:   none
  241.  
  242.                a684 test684.asm -o test684.hex    source:   test684.asm
  243.                                                   listing:  none
  244.                                                   object:   test684.hex
  245.  
  246.                a684 test684.asm -l test684.prn -o test684.hex
  247.                                                   source:   test684.asm
  248.                                                   listing:  test684.prn
  249.                                                   object:   test684.hex
  250.  
  251.                The order in which the source, listing, and object files are
  252.           specified does not matter.  Note that no default file name exten-
  253.           sions are supplied by the assembler as this gives rise to porta-
  254.           bility problems.
  255.  
  256.  
  257.  
  258.  
  259.                                      3
  260.  
  261.  
  262.  
  263.           2.0  Format of Cross-Assembler Source Lines
  264.  
  265.                The source file that the cross-assembler processes into a
  266.           listing and an object is an ASCII text file that you can prepare
  267.           with whatever editor you have at hand.  The most-significant
  268.           (parity) bit of each character is cleared as the character is
  269.           read from disk by the cross-assembler, so editors that set this
  270.           bit (such as WordStar's document mode) should not bother this
  271.           program.  All printing characters, the ASCII TAB character ($09),
  272.           and newline character(s) are processed by the assembler.  All
  273.           other characters are passed through to the listing file, but are
  274.           otherwise ignored.
  275.  
  276.                The source file is divided into lines by newline char-
  277.           acter(s).  The internal buffers of the cross-assembler will
  278.           accommodate lines of up to 255 characters which should be more
  279.           than ample for almost any job.  If you must use longer lines,
  280.           change the constant MAXLINE in file A684.H and recompile the
  281.           cross-assembler.  Otherwise, you will overflow the buffers, and
  282.           the program will mysteriously crash.
  283.  
  284.                Each source line is made up of three fields:  the label
  285.           field, the opcode field, and the argument field.  The label field
  286.           is optional, but if it is present, it must begin in column 1.
  287.           The opcode field is optional, but if it is present, it must not
  288.           begin in column 1.  If both a label and an opcode are present,
  289.           one or more spaces and/or TAB characters must separate the two.
  290.           If the opcode requires arguments, they are placed in the argument
  291.           field which is separated from the opcode field by one or more
  292.           spaces and/or TAB characters.  Finally, an optional comment can
  293.           be added to the end of the line.  This comment must begin with a
  294.           semicolon which signals the assembler to pass the rest of the
  295.           line to the listing and otherwise ignore it.  Thus, the source
  296.           line looks like this:
  297.  
  298.                {label}{ opcode{ arguments}}{;commentary}
  299.  
  300.           where the { } indicates that the specified item is optional.
  301.  
  302.                Some examples are in order:
  303.  
  304.             column 1
  305.                |
  306.                v
  307.                GRONK   LDA   #MAILMSG        ; This line has everything.
  308.                        STA   MAILBOX         ; This line has no label.
  309.                BEEP                          ; This line has no opcode.
  310.                ; This line has no label and no opcode.
  311.  
  312.                ; The previous line has nothing at all.
  313.                        END                   ; This line has no argument.
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.                                      4
  321.  
  322.  
  323.  
  324.           2.1  Labels
  325.  
  326.                A label is any sequence of alphabetic or numeric characters
  327.           starting with an alphabetic.  The legal alphabetics are:
  328.  
  329.                       ! & , . : ? [ \ ] ^ _  ` { | }  ~  A-Z  a-z
  330.  
  331.           The numeric characters are the digits 0-9.  Note that "A" is not
  332.           the same as "a" in a label.  This can explain mysterious U
  333.           (undefined label) errors occurring when a label appears to be
  334.           defined.
  335.  
  336.                A label is permitted on any line except a line where the
  337.           opcode is IF, ELSE, or ENDIF.  The label is assigned the value of
  338.           the assembly program counter before any of the rest of the line
  339.           is processed except when the opcode is EQU, ORG, or SET.
  340.  
  341.                Labels can have the same name as opcodes, but they cannot
  342.           have the same name as operators or registers.  The reserved
  343.           (operator and register) names are:
  344.  
  345.                AND       EQ        GE        GT        HIGH      LE
  346.                LT        LOW       MOD       NE        NOT       OR
  347.                SHL       SHR       X         XOR       Y
  348.  
  349.                If a label is used in an expression before it is assigned a
  350.           value, the label is said to be "forward-referenced."  For
  351.           example:
  352.  
  353.                L1   EQU  L2 + 1   ; L2 is forward-referenced here.
  354.                L2
  355.                L3   EQU  L2 + 1   ; L2 is not forward-referenced here.
  356.  
  357.  
  358.           2.2  Numeric Constants
  359.  
  360.                Numeric constants can be formed in two ways:  the Intel
  361.           convention or the Motorola convention.  The cross-assembler
  362.           supports both.
  363.  
  364.                An Intel-type numeric constant starts with a numeric
  365.           character (0-9), continues with zero or more digits (0-9, A-F),
  366.           and ends with an optional base designator.  The base designators
  367.           are H for hexadecimal, none or D for decimal, O or Q for octal,
  368.           and B for binary.  The hex digits a-f are converted to upper case
  369.           by the assembler.  Note that an Intel-type numeric constant
  370.           cannot begin with A-F as it would be indistinguishable from a
  371.           label.  Thus, all of the following evaluate to 255 (decimal):
  372.  
  373.                      0ffH   255   255D   377O   377Q   11111111B
  374.  
  375.                A Motorola-type numeric constant starts with a base
  376.           designator and continues with a string of one or more digits.
  377.           The base designators are $ for hexadecimal, none for decimal, @
  378.           for octal, and % for binary.  As with Intel-type numeric
  379.  
  380.  
  381.                                      5
  382.  
  383.  
  384.  
  385.           constants, a-f are converted to upper case by the assembler.
  386.           Thus, all of the following evaluate to 255 (decimal):
  387.  
  388.                             $ff   255   @377   %11111111
  389.  
  390.                If a numeric constant has a value that is too large to fit
  391.           into a 16-bit word, it will be truncated on the left to make it
  392.           fit.  Thus, for example, $123456 is truncated to $3456.
  393.  
  394.  
  395.           2.3  String Constants
  396.  
  397.                A string constant is zero or more characters enclosed in
  398.           either single quotes (' ') or double quotes (" ").  Single quotes
  399.           only match single quotes, and double quotes only match double
  400.           quotes, so if you want to put a single quote in a string, you can
  401.           do it like this:  "'".  In all contexts except the FCC statement,
  402.           the first character or two of the string constant are all that
  403.           are used.  The rest is ignored.  Noting that the ASCII codes for
  404.           "A" and "B" are $41 and $42, respectively, will explain the
  405.           following examples:
  406.  
  407.                     "" and ''           evaluate to $0000
  408.                     "A" and 'A'         evaluate to $0041
  409.                     "AB"                evaluates to $4142
  410.  
  411.           Note that the null string "" is legal and evaluates to $0000.
  412.  
  413.  
  414.           2.4  Expressions
  415.  
  416.                An expression is made up of labels, numeric constants, and
  417.           string constants glued together with arithmetic operators,
  418.           logical operators, and parentheses in the usual way that
  419.           algebraic expressions are made.  Operators have the following
  420.           fairly natural order of precedence:
  421.  
  422.                Highest        anything in parentheses
  423.                               unary +, unary -
  424.                               *, /, MOD, SHL, SHR
  425.                               binary +, binary -
  426.                               LT, LE, EQ, GE, GT, NE
  427.                               NOT
  428.                               AND
  429.                               OR, XOR
  430.                Lowest         HIGH, LOW
  431.  
  432.                A few notes about the various operators are in order:
  433.  
  434.                1)   The remainder operator MOD yields the remainder from
  435.                     dividing its left operand by its right operand.
  436.  
  437.                2)   The shifting operators SHL and SHR shift their left
  438.                     operand to the left or right the number of bits
  439.                     specified by their right operand.
  440.  
  441.  
  442.                                      6
  443.  
  444.  
  445.  
  446.  
  447.                3)   The relational operators LT, LE, EQ, GE, GT, and NE can
  448.                     also be written as <, <= or =<, =, >= or =>, and <> or
  449.                     ><, respectively.  They evaluate to $FFFF if the
  450.                     statement is true, 0 otherwise.
  451.  
  452.                4)   The logical opeators NOT, AND, OR, and XOR do bitwise
  453.                     operations on their operand(s).
  454.  
  455.                5)   HIGH and LOW extract the high or low byte, of an
  456.                     expression.
  457.  
  458.                6)   The special symbol * can be used in place of a label or
  459.                     constant to represent the value of the program counter
  460.                     before any of the current line has been processed.
  461.  
  462.                Some examples are in order at this point:
  463.  
  464.                2 + 3 * 4                          evaluates to 14
  465.                (2 + 3) * 4                        evaluates to 20
  466.                NOT %11110000 XOR %00001010        evaluates to %00000101
  467.                HIGH $1234 SHL 1                   evaluates to $0024
  468.                @001 EQ 0                          evaluates to 0
  469.                @001 = 2 SHR 1                     evaluates to $FFFF
  470.  
  471.                All arithmetic is unsigned with overflow from the 16-bit
  472.           word ignored.  Thus:
  473.  
  474.                32768 * 2                          evaluates to 0
  475.  
  476.  
  477.           3.0  Machine Opcodes
  478.  
  479.                The opcodes of the 6805 processor are divided into groups
  480.           below by the type of arguments required in the argument field of
  481.           the source line.  Opcodes that are peculiar to certain processors
  482.           in the family are noted in their sections.  Multiple arguments
  483.           must be separated from one another by commas.
  484.  
  485.  
  486.           3.1  Opcodes -- No Arguments
  487.  
  488.                The following opcodes allow no arguments at all in their
  489.           argument fields:
  490.  
  491.                ASLA      CLRA      CLRX      CLRX      CLRY      COMA
  492.                DECA      DECX      DECY      INCA      INCX      INCY
  493.                NOP       ROLA      RTI       RTS       STOP *    TAX
  494.                TAY       TXA       TYA       WAIT *
  495.  
  496.                     *    Use only with the MC68HC04 processors.
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.                                      7
  504.  
  505.  
  506.  
  507.           3.2  Opcodes -- Relative Branch Instructions
  508.  
  509.                The opcodes in this group come in two flavors:  branch-on-
  510.           flag instructions and branch-on-memory-bit instructions.  The
  511.           branch-on-flag instructions are BCC, BCS, BEQ, BHS, BLO, and BNE.
  512.           Each requires one argument in the range * - 15 through * + 16.
  513.           Values outside that range will cause a B (Branch Target Too
  514.           Distant) error.  For example:
  515.  
  516.                     LOOP                     ;Do some .....
  517.                                              ;             .....stuff.
  518.  
  519.                          BNE       LOOP      ;Now, go do it again, perhaps.
  520.  
  521.                The branch-on-memory-bit instructions are BRCLR and BRSET.
  522.           Each requires three arguments.  The first argument must be in the
  523.           range 0 through 7.  The second argument must be in the range 0
  524.           through $FF.  The third argument must be in the range * - 125
  525.           through * + 128.  Illegal values for either of the first two
  526.           arguments cause a V (Illegal Value) error.  An illegal value for
  527.           the third argument causes a B error.  For example:
  528.  
  529.                          BRCLR     0, PORTA, ZERO
  530.                     ONE                                ;Come here if bit 0
  531.                                                        ;  of location PORTA
  532.                                                        ;  is set.
  533.  
  534.                     ZERO                               ;Come here if the
  535.                                                        ;  bit is clear.
  536.  
  537.  
  538.           3.3  Opcodes -- Long Branch Instructions
  539.  
  540.                The JMP and JSR opcodes require one argument in the range 0
  541.           through $FFF.  An illegal value causes a V error.  For example:
  542.  
  543.                          JSR       PUT_CHAR       ;Jump to character output
  544.                                                   ;  subroutine.
  545.  
  546.  
  547.           3.4  Opcodes -- Bit Manipulation Instructions
  548.  
  549.                The BCLR and BSET opcodes require two arguments.  The first
  550.           argument is in the range 0 through 7.  The second argument is in
  551.           the range 0 through $FF.  An illegal value for either argument
  552.           causes a V error.  For example:
  553.  
  554.                          BCLR      0, PORTB       ;Clear bit 0 of location
  555.                                                   ;  PORTB.
  556.  
  557.  
  558.           3.5  Opcodes -- Arithmetic and Logical Instructions
  559.  
  560.                The opcodes in this group can be used in the following four
  561.           ways:
  562.  
  563.  
  564.                                      8
  565.  
  566.  
  567.  
  568.  
  569.                1)   LDA  #expression    where expression is -128 thru 255
  570.  
  571.                2)   LDA  expression     where expression is 0 thru $FF
  572.  
  573.                3)   LDA  X              (That's right, just the letter X.)
  574.  
  575.                4)   LDA  Y
  576.  
  577.           The opcodes are:
  578.  
  579.                ADD       AND       CMP       DEC *     INC *     LDA
  580.                STA *     SUB
  581.  
  582.                     *    Immediate addressing (LDA  #expression) not
  583.                          allowed.
  584.  
  585.           Illegal argument values cause V errors.
  586.  
  587.  
  588.           3.6  Opcodes -- MVI
  589.  
  590.                The MVI opcode requires two arguments.  The first argument
  591.           is in the range 0 through $FF.  The second argument is in the
  592.           range -128 to 255.  An illegal value for either argument causes a
  593.           V error.  For example:
  594.  
  595.                          MVI       PORTA, $23     ;Move the number $23 into
  596.                                                   ;  location $23.
  597.  
  598.                In addition, two handy short forms of MVI are defined:  LDXI
  599.           and LDYI.  They require only one argument in the range -128 to
  600.           255.  For example:
  601.  
  602.                          LDXI      $23            ;This is the same as.....
  603.                          MVI       $80, $23       ;  .....this, and
  604.  
  605.                          LDYI      $45            ;this is the same as.....
  606.                          MVI       $81, $45       ;  .....this.
  607.  
  608.  
  609.           3.7  Opcodes -- Short Direct Addressing
  610.  
  611.                The DEC, INC, LDA, and STA instructions of the 6804 CPU
  612.           allow a short direct addressing form when accessing locations $80
  613.           through $83.  The short direct instruction is only one byte long
  614.           whereas the normal direct instruction is two bytes long.  There
  615.           is no way to explicitly call for one form of addressing over the
  616.           other.  The assembler will choose short direct addressing if BOTH
  617.           of the following conditions are met:
  618.  
  619.                1)   the required expression contains no forward references,
  620.                     and
  621.  
  622.                2)   the expression evaluates to $80 through $83.
  623.  
  624.  
  625.                                      9
  626.  
  627.  
  628.  
  629.  
  630.           Otherwise, the assembler will choose normal direct addressing.
  631.           Note that this makes it desireable to declare your RAM locations
  632.           at the top of the program so that these locations will not
  633.           generate forward references and foil the assembler's attempts to
  634.           use direct addressing and shrink the object program.
  635.  
  636.  
  637.           4.0  Pseudo Opcodes
  638.  
  639.                Unlike 6804 opcodes, pseudo opcodes (pseudo ops) do not
  640.           represent machine instructions.  They are, rather, directives to
  641.           the assembler.  These directives require various numbers and
  642.           types of arguments.  They will be listed individually below.
  643.  
  644.  
  645.           4.1  Pseudo-ops -- END
  646.  
  647.                The END pseudo-op tells the assembler that the source
  648.           program is over.  Any further lines of the source file are
  649.           ignored and not passed on to the listing.  If an argument is
  650.           added to the END statement, the value of the argument will be
  651.           placed in the execution address slot in the Intel hex object
  652.           file.  The execution address defaults to the program counter
  653.           value at the point where the END was encountered.  Thus, to
  654.           specify that the program starts at label START, the END statement
  655.           would be:
  656.  
  657.                          END       START
  658.  
  659.                If end-of-file is encountered on the source file before an
  660.           END statement is reached, the assembler will add an END statement
  661.           to the listing and flag it with a * (missing statement) error.
  662.  
  663.  
  664.           4.2  Pseudo-ops -- EQU
  665.  
  666.                The EQU pseudo-op is used to assign a specific value to a
  667.           label, thus the label on this line is REQUIRED.  Once the value
  668.           is assigned, it cannot be reassigned by writing the label in
  669.           column 1, by another EQU statement, or by a SET statement.  Thus,
  670.           for example, the following statement assigns the value 2 to the
  671.           label TWO:
  672.  
  673.                TWO       EQU       1 + 1
  674.  
  675.                The expression in the argument field must contain no forward
  676.           references.
  677.  
  678.  
  679.           4.3  Pseudo-ops -- FCB
  680.  
  681.                The FCB (Form Constant Bytes) pseudo-op allows arbitrary
  682.           bytes to be spliced into the object code.  Its argument is a
  683.           chain of zero or more expressions that evaluate to -128 thru 255
  684.  
  685.  
  686.                                      10
  687.  
  688.  
  689.  
  690.           separated by commas.  If a comma occurs with no preceding
  691.           expression, a $00 byte is spliced into the object code.  The
  692.           sequence of bytes $FE $FF, $00, $01, $02 could be spliced into
  693.           the code with the following statement:
  694.  
  695.                          FCB       -2, -1, , 1, 2
  696.  
  697.  
  698.           4.4  Pseudo-ops -- FCC
  699.  
  700.                The FCC (Form Constant Characters) pseudo-op allows
  701.           character strings to be spliced into the object code.  Its
  702.           argument is a chain of zero or more string constants separated by
  703.           blanks, tabs, or commas.  If a comma occurs with no preceding
  704.           string constant, an S (syntax) error results.  The string
  705.           contants are not truncated to two bytes, but are instead copied
  706.           verbatim into the object code.  Null strings result in no bytes
  707.           of code.  The message "Kaboom!!" could be spliced into the code
  708.           with the following statement:
  709.  
  710.                          FCC       "Kaboom!!"     ;This is 8 bytes of code.
  711.  
  712.  
  713.           4.5  Pseudo-ops -- FDB
  714.  
  715.                The FDB (Form Double Bytes) pseudo-op allows 16-bit words to
  716.           be spliced into the object code.  Its argument is a chain of zero
  717.           or more expressions separated by commas.  If a comma occurs with
  718.           no preceding expression, a word of $0000 is spliced into the
  719.           code.  The word is placed into memory high byte in low address,
  720.           low byte in high address as per standard Motorola order.  The
  721.           sequence of bytes $FE $FF $00 $00 $01 $02 could be spliced into
  722.           the code with the following statement:
  723.  
  724.                          FDB       $FEFF, , $0102
  725.  
  726.  
  727.           4.6  Pseudo-ops -- IF, ELSE, ENDIF
  728.  
  729.                These three pseudo-ops allow the assembler to choose whether
  730.           or not to assemble certain blocks of code based on the result of
  731.           an expression.  Code that is not assembled is passed through to
  732.           the listing but otherwise ignored by the assembler.  The IF
  733.           pseudo-op signals the beginning of a conditionally assembled
  734.           block.  It requires one argument that may contain no forward
  735.           references.  If the value of the argument is non-zero, the block
  736.           is assembled.  Otherwise, the block is ignored.  The ENDIF
  737.           pseudo-op signals the end of the conditionally assembled block.
  738.           For example:
  739.  
  740.                          IF   EXPRESSION     ;This whole thing generates
  741.                          FCB  $01, $02, $03  ;  no code whatsoever if
  742.                          ENDIF               ;  EXPRESSION is zero.
  743.  
  744.           The ELSE pseudo-op allows the assembly of either one of two
  745.  
  746.  
  747.                                      11
  748.  
  749.  
  750.  
  751.           blocks, but not both.  The following two sequences are
  752.           equivalent:
  753.  
  754.                          IF   EXPRESSION
  755.                          ... some stuff ...
  756.                          ELSE
  757.                          ... some more stuff ...
  758.                          ENDIF
  759.  
  760.                TEMP_LAB  SET  EXPRESSION
  761.                          IF   TEMP_LAB NE 0
  762.                          ... some stuff ...
  763.                          ENDIF
  764.                          IF   TEMP_LAB EQ 0
  765.                          ... some more stuff ...
  766.                          ENDIF
  767.  
  768.                The pseudo-ops in this group do NOT permit labels to exist
  769.           on the same line as the status of the label (ignored or not)
  770.           would be ambiguous.
  771.  
  772.                All IF statements (even those in ignored conditionally
  773.           assembled blocks) must have corresponding ENDIF statements and
  774.           all ELSE and ENDIF statements must have a corresponding IF
  775.           statement.
  776.  
  777.                IF blocks can be nested up to 16 levels deep before the
  778.           assembler dies of a fatal error.  This should be adequate for any
  779.           conceivable job, but if you need more, change the constant
  780.           IFDEPTH in file A684.H and recompile the assembler.
  781.  
  782.  
  783.           4.7  Pseudo-ops -- INCL
  784.  
  785.                The INCL pseudo-op is used to splice the contents of another
  786.           file into the current file at assembly time.  The name of the
  787.           file to be INCLuded is specified as a normal string constant, so
  788.           the following line would splice the contents of file "const.def"
  789.           into the source code stream:
  790.  
  791.                          INCL      "const.def"
  792.  
  793.                INCLuded files may, in turn, INCLude other files until four
  794.           files are open simultaneously.  This limit should be enough for
  795.           any conceivable job, but if you need more, change the constant
  796.           FILES in file A685.H and recompile the assembler.
  797.  
  798.  
  799.           4.8  Pseudo-ops -- ORG
  800.  
  801.                The ORG pseudo-op is used to set the assembly program
  802.           counter to a particular value.  The expression that defines this
  803.           value may contain no forward references.  The default initial
  804.           value of the assembly program counter is $0000.  The following
  805.           statement would change the assembly program counter to $F000:
  806.  
  807.  
  808.                                      12
  809.  
  810.  
  811.  
  812.  
  813.                          ORG       $F000
  814.  
  815.                If a label is present on the same line as an ORG statement,
  816.           it is assigned the new value of the assembly program counter.
  817.  
  818.  
  819.           4.9  Pseudo-ops -- PAGE
  820.  
  821.                The PAGE pseudo-op always causes an immediate page ejection
  822.           in the listing by inserting a form feed ('\f') character before
  823.           the next line.  If an argument is specified, the argument
  824.           expression specifies the number of lines per page in the listing.
  825.           Legal values for the expression are any number except 1 and 2.  A
  826.           value of 0 turns the listing pagination off.  Thus, the following
  827.           statement cause a page ejection and would divide the listing into
  828.           60-line pages:
  829.  
  830.                          PAGE      60
  831.  
  832.  
  833.           4.10 Pseudo-ops -- RMB
  834.  
  835.                The RMB (Reserve Memory Bytes) pseudo-op is used to reserve
  836.           a block of storage for program variables, or whatever.  This
  837.           storage is not initialized in any way, so its value at run time
  838.           will usually be random.  The argument expression (which may
  839.           contain no forward references) is added to the assembly program
  840.           counter.  The following statement would reserve 10 bytes of
  841.           storage called "STORAGE":
  842.  
  843.                STORAGE   RMB       10
  844.  
  845.  
  846.           4.11 Pseudo-ops -- SET
  847.  
  848.                The SET pseudo-op functions like the EQU pseudo-op except
  849.           that the SET statement can reassign the value of a label that has
  850.           already been assigned by another SET statement.  Like the EQU
  851.           statement, the argument expression may contain no forward
  852.           references.  A label defined by a SET statement cannot be
  853.           redefined by writing it in column 1 or with an EQU statement.
  854.           The following series of statements would set the value of label
  855.           "COUNT" to 1, 2, then 3:
  856.  
  857.                COUNT     SET       1
  858.                COUNT     SET       2
  859.                COUNT     SET       3
  860.  
  861.  
  862.           4.12 Pseudo-ops -- TITLE
  863.  
  864.                The TITLE pseudo-op sets the running title for the listing.
  865.           The argument field is required and must be a string constant,
  866.           though the null string ("") is legal.  This title is printed
  867.  
  868.  
  869.                                      13
  870.  
  871.  
  872.  
  873.           after every page ejection in the listing, therefore, if page
  874.           ejections have not been forced by the PAGE pseudo-op, the title
  875.           will never be printed.  The following statement would print the
  876.           title "Random Bug Generator -- Ver 3.14159" at the top of every
  877.           page of the listing:
  878.  
  879.                          TITLE     "Random Bug Generator -- Ver 3.14159"
  880.  
  881.  
  882.           5.0  Assembly Errors
  883.  
  884.                When a source line contains an illegal construct, the line
  885.           is flagged in the listing with a single-letter code describing
  886.           the error.  The meaning of each code is listed below.  In
  887.           addition, a count of the number of lines with errors is kept and
  888.           printed on the C "stderr" device (by default, the console) after
  889.           the END statement is processed.  If more than one error occurs in
  890.           a given line, only the first is reported.  For example, the
  891.           illegal label "=$#*'(" would generate the following listing line:
  892.  
  893.                L  0000   C3 12 34      =$#*'(     CPX       $1234
  894.  
  895.  
  896.           5.1  Error * -- Illegal or Missing Statement
  897.  
  898.                This error occurs when either:
  899.  
  900.                1)   the assembler reaches the end of the source file
  901.                     without seeing an END statement, or
  902.  
  903.                2)   an END statement is encountered in an INCLude file.
  904.  
  905.                If you are "sure" that the END statement is present when the
  906.           assembler thinks that it is missing, it probably is in the
  907.           ignored section of an IF block.  If the END statement is missing,
  908.           supply it.  If the END statement is in an INCLude file, delete
  909.           it.
  910.  
  911.  
  912.           5.2  Error ( -- Parenthesis Imbalance
  913.  
  914.                For every left parenthesis, there must be a right paren-
  915.           thesis.  Count them.
  916.  
  917.  
  918.           5.3  Error " -- Missing Quotation Mark
  919.  
  920.                Strings have to begin and end with either " or '.  Remember
  921.           that " only matches " while ' only matches '.
  922.  
  923.  
  924.           5.4  Error A -- Illegal Addressing Mode
  925.  
  926.                This error occurs if the immediate designator # is used with
  927.           an opcode that does not permit immediate addressing.
  928.  
  929.  
  930.                                      14
  931.  
  932.  
  933.  
  934.  
  935.  
  936.           5.5  Error B -- Branch Target Too Distant
  937.  
  938.                The 6804 relative branch instructions will only reach a
  939.           short distance from the first byte of the instruction.  If this
  940.           error occurs, the source code will have to be rearranged to
  941.           shorten the distance to the branch target address or a long
  942.           branch instruction that will reach anywhere (JMP) will have to be
  943.           used.
  944.  
  945.  
  946.           5.6  Error D -- Illegal Digit
  947.  
  948.                This error occurs if a digit greater than or equal to the
  949.           base of a numeric constant is found.  For example, a 2 in a
  950.           binary number would cause a D error.  Especially, watch for 8 or
  951.           9 in an octal number.
  952.  
  953.  
  954.           5.7  Error E -- Illegal Expression
  955.  
  956.                This error occurs because of:
  957.  
  958.                1)   a missing expression where one is required
  959.  
  960.                2)   a unary operator used as a binary operator or vice-
  961.                     versa
  962.  
  963.                3)   a missing binary operator
  964.  
  965.                4)   a SHL or SHR count that is not 0 thru 15
  966.  
  967.  
  968.           5.8  Error I -- IF-ENDIF Imbalance
  969.  
  970.                For every IF there must be a corresponding ENDIF.  If this
  971.           error occurs on an ELSE or ENDIF statement, the corresponding IF
  972.           is missing.  If this error occurs on an END statement, one or
  973.           more ENDIF statements are missing.
  974.  
  975.  
  976.           5.9  Error L -- Illegal Label
  977.  
  978.                This error occurs because of:
  979.  
  980.                1)   a non-alphabetic in column 1
  981.  
  982.                2)   a reserved word used as a label
  983.  
  984.                3)   a missing label on an EQU or SET statement
  985.  
  986.                4)   a label on an IF, ELSE, or ENDIF statement
  987.  
  988.  
  989.  
  990.  
  991.                                      15
  992.  
  993.  
  994.  
  995.           5.10 Error M -- Multiply Defined Label
  996.  
  997.                This error occurs because of:
  998.  
  999.                1)   a label defined in column 1 or with the EQU statement
  1000.                     being redefined
  1001.  
  1002.                2)   a label defined by a SET statement being redefined
  1003.                     either in column 1 or with the EQU statement
  1004.  
  1005.                3)   the value of the label changing between assembly passes
  1006.  
  1007.  
  1008.           5.11 Error O -- Illegal Opcode
  1009.  
  1010.                The opcode field of a source line may contain only a valid
  1011.           machine opcode, a valid pseudo-op, or nothing at all.  Anything
  1012.           else causes this error.
  1013.  
  1014.  
  1015.           5.12 Error P -- Phasing Error
  1016.  
  1017.                This error occurs because of:
  1018.  
  1019.                1)   a forward reference in a EQU, ORG, RMB, or SET
  1020.                     statement
  1021.  
  1022.                2)   a label disappearing between assembly passes
  1023.  
  1024.  
  1025.           5.13 Error S -- Illegal Syntax
  1026.  
  1027.                This error means that an argument field is scrambled.  Sort
  1028.           the mess out and reassemble.
  1029.  
  1030.  
  1031.           5.14 Error T -- Too Many Arguments
  1032.  
  1033.                This error occurs if there are more items (expressions,
  1034.           register designators, etc.) in the argument field than the opcode
  1035.           or pseudo-op requires.  The assembler ignores the extra items but
  1036.           issues this error in case something is really mangled.
  1037.  
  1038.  
  1039.           5.15 Error U -- Undefined Label
  1040.  
  1041.                This error occurs if a label is referenced in an expression
  1042.           but not defined anywhere in the source program.  If you are
  1043.           "sure" you have defined the label, note that upper and lower case
  1044.           letters in labels are different.  Defining "LABEL" does not
  1045.           define "Label."
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.                                      16
  1053.  
  1054.  
  1055.  
  1056.           5.16 Error V -- Illegal Value
  1057.  
  1058.                This error occurs because:
  1059.  
  1060.                1)   the first argument of a bit manipulation instruction or
  1061.                     branch-on-bit instruction is not 0 thru 7, or
  1062.  
  1063.                2)   the second argument of a bit manipulation instruction
  1064.                     or branch-on-bit instruction, or the first argument of
  1065.                     an arithmetic and logical instruction instruction is
  1066.                     not 0 thru 255, or
  1067.  
  1068.                3)   an immediate value is not -128 thru 255, or
  1069.  
  1070.                4)   the argument of a JMP or JSR instruction is not 0 thru
  1071.                     $FFF, or
  1072.  
  1073.                4)   an FCB argument is not -128 thru 255, or
  1074.  
  1075.                5)   an INCL argument refers to a file that does not exist.
  1076.  
  1077.  
  1078.           6.0  Warning Messages
  1079.  
  1080.                Some errors that occur during the parsing of the cross-
  1081.           assembler command line are non-fatal.  The cross-assembler flags
  1082.           these with a message on the C "stdout" device (by default, the
  1083.           console) beginning with the word "Warning."  The messages are
  1084.           listed below:
  1085.  
  1086.  
  1087.           6.1  Warning -- Illegal Option Ignored
  1088.  
  1089.                The only options that the cross-assembler knows are -l and
  1090.           -o.  Any other command line argument beginning with - will draw
  1091.           this error.
  1092.  
  1093.  
  1094.           6.2  Warning -- -l Option Ignored -- No File Name
  1095.           6.3  Warning -- -o Option Ignored -- No File Name
  1096.  
  1097.                The -l and -o options require a file name to tell the
  1098.           assembler where to put the listing file or object file.  If this
  1099.           file name is missing, the option is ignored.
  1100.  
  1101.  
  1102.           6.4  Warning -- Extra Source File Ignored
  1103.  
  1104.                The cross-assembler will only assemble one file at a time,
  1105.           so source file names after the first are ignored.  To assemble a
  1106.           second file, invoke the assembler again.  Note that under CP/M-
  1107.           80, the old trick of reexecuting a core image will NOT work as
  1108.           the initialized data areas are not reinitialized prior to the
  1109.           second run.
  1110.  
  1111.  
  1112.  
  1113.                                      17
  1114.  
  1115.  
  1116.  
  1117.  
  1118.           6.5  Warning -- Extra Listing File Ignored
  1119.           6.6  Warning -- Extra Object File Ignored
  1120.  
  1121.                The cross-assembler will only generate one listing and one
  1122.           object file per assembly run, so -l and -o options after the
  1123.           first are ignored.
  1124.  
  1125.  
  1126.           7.0  Fatal Error Messages
  1127.  
  1128.                Several errors that occur during the parsing of the cross-
  1129.           assembler command line or during the assembly run are fatal.  The
  1130.           cross-assembler flags these with a message on the C "stdout"
  1131.           device (by default, the console) beginning with the words "Fatal
  1132.           Error."  The messages are explained below:
  1133.  
  1134.  
  1135.           7.1  Fatal Error -- No Source File Specified
  1136.  
  1137.                This one is self-explanatory.  The assembler does not know
  1138.           what to assemble.
  1139.  
  1140.  
  1141.           7.2  Fatal Error -- Source File Did Not Open
  1142.  
  1143.                The assembler could not open the source file.  The most
  1144.           likely cause is that the source file as specified on the command
  1145.           line does not exist.  On larger systems, there could also be
  1146.           priviledge violations.  Rarely, a read error in the disk
  1147.           directory could cause this error.
  1148.  
  1149.  
  1150.           7.3  Fatal Error -- Listing File Did Not Open
  1151.           7.4  Fatal Error -- Object File Did Not Open
  1152.  
  1153.                This error indicates either a defective listing or object
  1154.           file name or a full disk directory.  Correct the file name or
  1155.           make more room on the disk.
  1156.  
  1157.  
  1158.           7.5  Fatal Error -- Error Reading Source File
  1159.  
  1160.                This error generally indicates a read error in the disk data
  1161.           space.  Use your backup copy of the source file (You do have one,
  1162.           don't you?) to recreate the mangled file and reassemble.
  1163.  
  1164.  
  1165.           7.6  Fatal Error -- Disk or Directory Full
  1166.  
  1167.                This one is self-explanatory.  Some more space must be found
  1168.           either by deleting files or by using a disk with more room on it.
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.                                      18
  1175.  
  1176.  
  1177.  
  1178.           7.7  Fatal Error -- File Stack Overflow
  1179.  
  1180.                This error occurs if you exceed the INCLude file limit of
  1181.           four files open simultaneously.  This limit can be increased by
  1182.           increasing the constant FILES in file A684.H and recompiling the
  1183.           cross-assembler.
  1184.  
  1185.  
  1186.           7.8  Fatal Error -- If Stack Overflow
  1187.  
  1188.                This error occurs if you exceed the nesting limit of 16 IF
  1189.           blocks.  This limit can be increased by increasing the constant
  1190.           IFDEPTH in file A684.H and recompiling the cross-assembler.
  1191.  
  1192.  
  1193.           7.9  Fatal Error -- Too Many Symbols
  1194.  
  1195.                Congratulations!  You have run out of memory.  The space for
  1196.           the cross-assembler's symbol table is allocated at run-time using
  1197.           the C library function alloc(), so the cross-assembler will use
  1198.           all available memory.  The only solutions to this problem are to
  1199.           lessen the number of labels in the source program, to use a
  1200.           larger memory model (MSDOS/PCDOS systems only), or to add more
  1201.           memory to your machine.
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.                                      19
  1236.