home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 149_01 / a685.doc < prev    next >
Text File  |  1989-01-13  |  45KB  |  1,240 lines

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