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