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

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