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

  1. /*
  2.     HEADER:        CUG242;
  3.     TITLE:        8051 Cross-Assembler (Portable);
  4.     FILENAME:    A51.DOC;
  5.     VERSION:    0.4;
  6.     DATE:        11/09/1988;
  7.     SEE-ALSO:    A51.H;
  8.     AUTHORS:    William C. Colley III;
  9. */
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.                          8051 Cross-Assembler (Portable)
  25.  
  26.  
  27.                                    Version 0.4
  28.  
  29.  
  30.                  Copyright (c) 1985,1987 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.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.                                 Table of Contents
  75.  
  76.         1.0  How to Use the Cross-Assembler Package ..................  3
  77.         2.0  Format of Cross-Assembler Source Lines ..................  4
  78.              2.1  Labels .............................................  5
  79.              2.2  Numeric Constants ..................................  6
  80.              2.3  String Constants ...................................  6
  81.              2.4  Expressions ........................................  6
  82.              2.5  Bit Expressions ....................................  7
  83.         3.0  Machine Opcodes .........................................  8
  84.              3.1  Opcodes -- No Arguments ............................  8
  85.              3.2  Opcodes -- One Argument ............................  8
  86.              3.3  Opcodes -- Two Arguments in Order ..................  9
  87.              3.4  Opcodes -- Two Arguments in Either Order ...........  9
  88.              3.5  Opcodes -- Three Arguments in Order ................  9
  89.              3.6  Opcodes -- Relative Branches .......................  9
  90.              3.7  Opcodes -- Absolute Branches .......................  9
  91.              3.8  Opcodes -- Long Branches ........................... 10
  92.              3.9  Opcodes -- MOV ..................................... 10
  93.         4.0  Pseudo Opcodes .......................................... 10
  94.              4.1  Pseudo-ops -- BIT .................................. 10
  95.              4.2  Pseudo-ops -- DB ................................... 10
  96.              4.3  Pseudo-ops -- DS ................................... 11
  97.              4.4  Pseudo-ops -- DW ................................... 11
  98.              4.5  Pseudo-ops -- END .................................. 11
  99.              4.6  Pseudo-ops -- EQU .................................. 12
  100.              4.7  Pseudo-ops -- IF, ELSE, ENDIF ...................... 12
  101.              4.8  Pseudo-ops -- INCL ................................. 13
  102.              4.9  Pseudo-ops -- ORG .................................. 13
  103.              4.10 Pseudo-ops -- PAGE ................................. 13
  104.              4.11 Pseudo-ops -- REG .................................. 14
  105.              4.12 Pseudo-ops -- SET .................................. 14
  106.              4.13 Pseudo-ops -- TITL ................................. 14
  107.         5.0  Assembly Errors ......................................... 14
  108.              5.1  Error * -- Missing Statement ....................... 15
  109.              5.2  Error ( -- Parenthesis Imbalance ................... 15
  110.              5.3  Error " -- Missing Quotation Mark .................. 15
  111.              5.4  Error B -- Branch Target Out of Bounds ............. 15
  112.              5.5  Error D -- Illegal Digit ........................... 15
  113.              5.6  Error E -- Illegal Expression ...................... 16
  114.              5.7  Error I -- IF-ENDIF Imbalance ...................... 16
  115.              5.8  Error L -- Illegal Label ........................... 16
  116.              5.9  Error M -- Multiply Defined Label .................. 16
  117.              5.10 Error O -- Illegal Opcode .......................... 16
  118.              5.11 Error P -- Phasing Error ........................... 17
  119.              5.12 Error S -- Illegal Syntax .......................... 17
  120.              5.13 Error T -- Too Many Arguments ...................... 17
  121.              5.14 Error U -- Undefined Label ......................... 17
  122.              5.15 Error V -- Illegal Value ........................... 17
  123.         6.0  Warning Messages ........................................ 17
  124.              6.1  Warning -- Illegal Option Ignored .................. 18
  125.              6.2  Warning -- -l Option Ignored -- No File Name ....... 18
  126.              6.3  Warning -- -o Option Ignored -- No File Name ....... 18
  127.              6.4  Warning -- Extra Source File Ignored ............... 18
  128.              6.5  Warning -- Extra Listing File Ignored .............. 18
  129.  
  130.  
  131.                                         1
  132.  
  133.  
  134.  
  135.              6.6  Warning -- Extra Object File Ignored ............... 18
  136.         7.0  Fatal Error Messages .................................... 18
  137.              7.1  Fatal Error -- No Source File Specified ............ 18
  138.              7.2  Fatal Error -- Source File Did Not Open ............ 18
  139.              7.3  Fatal Error -- Listing File Did Not Open ........... 19
  140.              7.4  Fatal Error -- Object File Did Not Open ............ 19
  141.              7.5  Fatal Error -- Error Reading Source File ........... 19
  142.              7.6  Fatal Error -- Disk or Directory Full .............. 19
  143.              7.7  Fatal Error -- File Stack Overflow ................. 19
  144.              7.8  Fatal Error -- If Stack Overflow ................... 19
  145.              7.9  Fatal Error -- Too Many Symbols .................... 19
  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.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.                                         2
  193.  
  194.  
  195.  
  196.         1.0  How to Use the Cross-Assembler Package
  197.  
  198.              First, the question, "What does a cross-assembler do?" needs 
  199.         to be addressed as there is considerable confusion on this point.  
  200.         A cross-assembler is just like any other assembler except that it 
  201.         runs on some CPU other than the one for which it assembles code.  
  202.         For example, this package assembles 8051 source code into 8051
  203.         object code, but it runs on an 8080, a Z-80, an 8088, or whatever 
  204.         other CPU you happen to have a C compiler for.  The reason that 
  205.         cross-assemblers are useful is that you probably already have a 
  206.         CPU with memory, disk drives, a text editor, an operating system, 
  207.         and all sorts of hard-to-build or expensive facilities on hand.  
  208.         A cross-assembler allows you to use these facilites to develop 
  209.         code for an 8051.
  210.  
  211.         This program requires one input file (your 8051 source code) and 
  212.         zero to two output files (the listing and the object).  The input 
  213.         file MUST be specified, or the assembler will bomb on a fatal 
  214.         error.  The listing and object files are optional.  If no listing 
  215.         file is specified, no listing is generated, and if no object file 
  216.         is specified, no object is generated.  If the object file is 
  217.         specified, the object is written to this file in "Intel 
  218.         hexadecimal" format.
  219.  
  220.              The command line for the cross-assembler looks like this:
  221.  
  222.                   A51 source_file { >list_file } { -o object_file }
  223.  
  224.         where the { } indicates that the specified item is optional.
  225.  
  226.              Some examples are in order:
  227.  
  228.              a51 test51.asm                          source:   test51.asm
  229.                                                      listing:  none
  230.                                                      object:   none
  231.  
  232.              a51 test51.asm -l test51.prn            source:   test51.asm
  233.                                                      listing:  test51.prn
  234.                                                      object:   none
  235.  
  236.              a51 test51.asm -o test51.hex            source:   test51.asm
  237.                                                      listing:  none
  238.                                                      object:   test51.hex
  239.  
  240.              a51 test51.asm -l test51.prn -o test51.hex
  241.                                                      source:   test51.asm
  242.                                                      listing:  test51.prn
  243.                                                      object:   test51.hex
  244.  
  245.              The order in which the source, listing, and object files are 
  246.         specified does not matter.  Note that no default file name exten-
  247.         sions are supplied by the assembler as this gives rise to porta-
  248.         bility problems.
  249.  
  250.  
  251.  
  252.  
  253.                                         3
  254.  
  255.  
  256.  
  257.         2.0  Format of Cross-Assembler Source Lines
  258.  
  259.              The source file that the cross-assembler processes into a 
  260.         listing and an object is an ASCII text file that you can prepare 
  261.         with whatever editor you have at hand.  The most-significant 
  262.         (parity) bit of each character is cleared as the character is 
  263.         read from disk by the cross-assembler, so editors that set this 
  264.         bit (such as WordStar's document mode) should not bother this 
  265.         program.  All printing characters, the ASCII TAB character (09H), 
  266.         and newline character(s) are processed by the assembler.  All 
  267.         other characters are passed through to the listing file, but are 
  268.         otherwise ignored.
  269.  
  270.              The source file is divided into lines by newline char-
  271.         acter(s).  The internal buffers of the cross-assembler will 
  272.         accommodate lines of up to 255 characters which should be more 
  273.         than ample for almost any job.  If you must use longer lines, 
  274.         change the constant MAXLINE in file A51.H and recompile the 
  275.         cross-assembler.  Otherwise, you will overflow the buffers, and 
  276.         the program will mysteriously crash.
  277.  
  278.              Each source line is made up of three fields:  the label 
  279.         field, the opcode field, and the argument field.  The label field 
  280.         is optional, but if it is present, it must begin in column 1.  
  281.         The opcode field is optional, but if it is present, it must not 
  282.         begin in column 1.  If both a label and an opcode are present, 
  283.         one or more spaces and/or TAB characters must separate the two.  
  284.         If the opcode requires arguments, they are placed in the argument 
  285.         field which is separated from the opcode field by one or more 
  286.         spaces and/or TAB characters.  Finally, an optional comment can 
  287.         be added to the end of the line.  This comment must begin with a 
  288.         semicolon which signals the assembler to pass the rest of the 
  289.         line to the listing and otherwise ignore it.  Thus, the source 
  290.         line looks like this:
  291.  
  292.              {label}{ opcode{ arguments}}{;commentary}
  293.  
  294.         where the { } indicates that the specified item is optional.
  295.  
  296.              Some examples are in order:
  297.  
  298.           column 1
  299.              |
  300.              v
  301.              GRONK   DJNZ  R1, LOOP        ; This line has everything.
  302.                      INC   R1              ; This line has no label.
  303.              BEEP                          ; This line has no opcode.
  304.              ; This line has no label and no opcode.
  305.  
  306.              ; The previous line has nothing at all.
  307.                      END                   ; This line has no argument.
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.                                         4
  315.  
  316.  
  317.  
  318.         2.1  Labels
  319.  
  320.              A label is any sequence of alphabetic or numeric characters 
  321.         starting with an alphabetic.  The legal alphabetics are:
  322.  
  323.                    ! $ % & : ? [ \ ] ^ _  ` { | }  ~  A-Z  a-z
  324.  
  325.         The numeric characters are the digits 0-9.  Note that "A" is not 
  326.         the same as "a" in a label.  This can explain mysterious U 
  327.         (undefined label) errors occurring when a label appears to be 
  328.         defined.
  329.  
  330.              A label is permitted on any line except a line where the 
  331.         opcode is IF, ELSE, or ENDIF.  The label is assigned the value of 
  332.         the assembly program counter before any of the rest of the line 
  333.         is processed except when the opcode is BIT, EQU, ORG, REG, or 
  334.         SET.
  335.  
  336.              Labels can have the same name as opcodes, but they cannot
  337.         have the same name as pre-defined bit variables, operators, 
  338.         registers, or pre-defined byte addresses.  The reserved names 
  339.         are:
  340.  
  341.              Pre-defined bit variables:
  342.  
  343.              AC        CY        EA        ES        ET0       ET1
  344.              EX0       EX1       F0        IE0       IE1       IT0
  345.              IT1       OV        P         PS        PT0       PT1
  346.              PX0       PX1       RS0       RS1       RB8       REN
  347.              RI        SM0       SM1       SM2       TB8       TF0
  348.              TF1       TI        TR0       TR1
  349.  
  350.              Operators:
  351.  
  352.              AND       EQ        GE        GT        HIGH      LE
  353.              LOW       LT        MOD       NE        NOT       OR
  354.              SHL       SHR       XOR
  355.  
  356.              Registers:
  357.  
  358.              A         AB        C         DPTR      PC        R0
  359.              R1        R2        R3        R4        R5        R6
  360.              R7
  361.  
  362.              Pre-defined byte addresses:
  363.  
  364.              $         ACC       B         DPH       DPL       IE
  365.              IP        P0        P1        P2        P3        PCON
  366.              PSW       SBUF      SCON      SP        TCON      TH0
  367.              TH1       TL0       TL1       TMOD
  368.  
  369.              If a label is used in an expression before it is assigned a 
  370.         value, the label is said to be "forward-referenced."  For 
  371.         example:
  372.  
  373.  
  374.  
  375.                                         5
  376.  
  377.  
  378.  
  379.              L1   EQU  L2 + 1   ; L2 is forward-referenced here.
  380.              L2
  381.              L3   EQU  L2 + 1   ; L2 is not forward-referenced here.
  382.  
  383.  
  384.         2.2  Numeric Constants
  385.  
  386.              Numeric constants are formed according to the Intel 
  387.         convention.  A numeric constant starts with a numeric character 
  388.         (0-9), continues with zero or more digits (0-9, A-F), and ends 
  389.         with an optional base designator.  The base designators are H for 
  390.         hexadecimal, none or D for decimal, O or Q for octal, and B for 
  391.         binary.  The hex digits a-f are converted to upper case by the 
  392.         assembler.  Note that a numeric constant cannot begin with A-F as 
  393.         it would be indistinguishable from a label.  Thus, all of the 
  394.         following evaluate to 255 (decimal):
  395.  
  396.                    0ffH   255   255D   377O   377Q   11111111B
  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 DB 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.  
  435.  
  436.                                         6
  437.  
  438.  
  439.  
  440.              Lowest         HIGH, LOW
  441.  
  442.              A few notes about the various operators are in order:
  443.  
  444.              1)   The remainder operator MOD yields the remainder from 
  445.                   dividing its left operand by its right operand.
  446.  
  447.              2)   The shifting operators SHL and SHR shift their left 
  448.                   operand to the left or right the number of bits 
  449.                   specified by their right operand.
  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 0FFFFH 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 1234H SHL 1                   evaluates to $0024
  472.              001Q EQ 0                          evaluates to 0
  473.              001Q = 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.         2.5  Bit Expressions
  482.  
  483.              Byte addresses are specified by expressions as described 
  484.         above.  Bit addresses are specified by a special type of 
  485.         expression which can take the following three forms:
  486.  
  487.              1)   bit_variable
  488.  
  489.                        Bit variables are declared with the BIT pseudo-op.  
  490.                   A number of bit variables are pre-defined by the 
  491.                   assembler such as OV for the overflow flag (bit 2 of 
  492.                   location 0E0H).
  493.  
  494.              2)   expression_1 . expression_2
  495.  
  496.  
  497.                                         7
  498.  
  499.  
  500.  
  501.  
  502.                        This yields the bit address of bit expression_2 of 
  503.                   location expression_1.  expression_1 must in the range 
  504.                   20H - 2FH or an even multiple of 8 in the range 80H - 
  505.                   0FFH.  expression_2 must be in the range 0 - 7.  An 
  506.                   illegal value in either expression will cause a V 
  507.                   (value) error.
  508.  
  509.              3)   expression
  510.  
  511.                        An expression can also specify a bit address by 
  512.                   itself.
  513.  
  514.  
  515.         3.0  Machine Opcodes
  516.  
  517.              The opcodes of the 8051 processor are divided into groups 
  518.         below by the type of arguments required in the argument field of 
  519.         the source line.  If an opcode requires multiple arguments, these 
  520.         must be placed in the argument field in order (unless otherwise 
  521.         specified) and separated by commas.  Some shorthand notations 
  522.         will be used.  They are:
  523.  
  524.              #imm means     immediate value (e.g. #012H) in the range
  525.                                  -128 to +255
  526.              bit  means     bit expression as described in section 2.5
  527.              dir  means     byte address in the range 0 - 0FFH
  528.              rel  means     byte address as described in section 3.6
  529.              Rn   means     R0, R1, R2, R3, R4, R5, R6, or R7
  530.  
  531.  
  532.         3.1  Opcodes -- No Arguments
  533.  
  534.              The following opcodes allow no arguments at all in their 
  535.         argument fields:
  536.  
  537.                        NOP       RET       RETI
  538.  
  539.  
  540.         3.2  Opcodes -- One Argument
  541.  
  542.              The following opcodes require one argument.  The allowable 
  543.         argument values for each opcode are listed below:
  544.  
  545.              Argument Value(s)             Opcode(s)
  546.  
  547.              A                             DA, RL, RLC, RR, RRC, SWAP
  548.              AB                            DIV, MUL
  549.              dir                           POP, PUSH
  550.              A, Rn, @R0, @R1, or dir       DEC
  551.              A, DPTR, Rn, @R0, @R1, or dir INC
  552.              C, or bit                     SETB
  553.              A, C, or bit                  CLR, CPL
  554.              @A + DPTR                     JMP
  555.  
  556.  
  557.  
  558.                                         8
  559.  
  560.  
  561.  
  562.  
  563.         3.3  Opcodes -- Two Arguments in Order
  564.  
  565.              The following opcodes require two arguments in the specified 
  566.         order:
  567.  
  568.              Argument 1          Argument 2               Opcode(s)
  569.  
  570.              A                   @A + DPTR or @A + PC     MOVC
  571.              A                   @R0 or @R1               XCHD
  572.              A                   dir, Rn, @R0, or @R1     XCH
  573.              A                   dir, #imm, Rn, @R0,      ADD, ADDC, ANL,
  574.                                    or @R1                   ORL, SUBB, XRL
  575.              dir                 A, or #imm               ANL, ORL, XRL
  576.              C                   bit, or /bit             ANL, ORL
  577.              bit                 rel                      JB, JBC, JNB
  578.              Rn, or @Rn          rel                      DJNZ
  579.  
  580.  
  581.         3.4  Opcodes -- Two Arguments in Either Order
  582.  
  583.              The following opcodes require two arguments in either order:
  584.  
  585.              Argument 1          Argument 2               Opcode
  586.  
  587.              A                   @DPTR, @R0, or @R1       MOVX
  588.  
  589.  
  590.         3.5  Opcodes -- Three Arguments in Order
  591.  
  592.              The CJNE opcode requires three arguments in order.  Two sets 
  593.         of arguments are allowed as follows:
  594.  
  595.              Argument 1          Argument 2          Argument 3
  596.  
  597.              A                   dir or #imm         rel
  598.              Rn, @R0, or @R1     #imm                rel
  599.  
  600.  
  601.         3.6  Opcodes -- Relative Branches
  602.  
  603.              The opcodes in this group require one argument.  It is an 
  604.         arithmetic expression that evaluates to an address in the range 
  605.         -128 to +127 bytes from the address of the first byte of the NEXT 
  606.         instruction.  The opcodes are:
  607.  
  608.              JC        JNC       JNZ       JZ        SJMP
  609.  
  610.  
  611.         3.7  Opcodes -- Absolute Branches
  612.  
  613.              These opcodes require one argument.  It is an arithmetic 
  614.         expression that evaluates to an address on the same 2K page as 
  615.         the NEXT instruction.  The opcodes are:
  616.  
  617.  
  618.  
  619.                                         9
  620.  
  621.  
  622.  
  623.                        ACALL               AJMP
  624.  
  625.  
  626.         3.8  Opcodes -- Long Branches
  627.  
  628.              The following opcodes require one argument that is an 
  629.         arithmetic expression with any value.
  630.  
  631.                        LCALL               LJMP
  632.  
  633.  
  634.         3.9  Opcodes -- MOV
  635.  
  636.              The MOV opcode requires two arguments.  The following table 
  637.         has the allowable combinations marked with an X:
  638.  
  639.               First                 Second Argument
  640.              Argument       A  #imm  dir  Rn  @R0  @R1  bit  C
  641.                 A                X    X   X    X    X
  642.                dir          X    X    X   X    X    X
  643.                 Rn          X    X    X
  644.                @R0          X    X    X
  645.                @R1          X    X    X
  646.                bit                                           X
  647.                 C                                        X
  648.               DPTR               *
  649.  
  650.              * = The immediate value in this case (only) is not 
  651.                  restricted to the range -128 to +255.
  652.  
  653.  
  654.         4.0  Pseudo Opcodes
  655.  
  656.              Unlike 8051 opcodes, pseudo opcodes (pseudo-ops) do not 
  657.         represent machine instructions.  They are, rather, directives to 
  658.         the assembler.  These directives require various numbers and 
  659.         types of arguments.  They will be listed individually below.
  660.  
  661.  
  662.         4.1  Pseudo-ops -- BIT
  663.  
  664.              The BIT pseudo-op allows the user to create bit variables.  
  665.         It takes the following form:
  666.  
  667.              label     BIT       bit_expression
  668.  
  669.         The label is mandatory.  If it is missing, the assembler will 
  670.         generate an L (label) error.
  671.  
  672.  
  673.         4.2  Pseudo-ops -- DB
  674.  
  675.              The DB pseudo-op allows arbitrary bytes to be spliced into 
  676.         the object code.  Its argument is a chain of zero or more 
  677.         expressions that evaluate to -128 through 255 separated by 
  678.  
  679.  
  680.                                        10
  681.  
  682.  
  683.  
  684.         commas.  If a comma occurs with no preceding expression, a 00H 
  685.         byte is spliced into the object code.  The sequence of bytes 
  686.         0FEH, 0FFH, 00H, 01H, 02H could be spliced into the code with the 
  687.         following statement:
  688.  
  689.                        DB        -2, -1, , 1, 2
  690.  
  691.         A special case exists here.  If a string constant is entered with 
  692.         no arithmetic done on it, then the entire string is spliced into 
  693.         the code stream.  Thus, the sequence of bytes 002H, 043H, 041H, 
  694.         054H, 044H could be spliced into the code with the following 
  695.         statement:
  696.  
  697.                        DB        1 + 1, "CAT", "C" + 1
  698.  
  699.  
  700.         4.3  Pseudo-ops -- DS
  701.  
  702.              The DS pseudo-op is used to reserve a block of storage for 
  703.         program variables, or whatever.  This storage is not initialized 
  704.         in any way, so its value at run time will usually be random.  The 
  705.         argument expression (which may contain no forward references) is 
  706.         added to the assembly program counter.  The following statement 
  707.         would reserve 10 bytes of storage called "STORAGE":
  708.  
  709.              STORAGE   DS        10
  710.  
  711.  
  712.         4.4  Pseudo-ops -- DW
  713.  
  714.              The DW pseudo-op allows 16-bit words to be spliced into the 
  715.         object code.  Its argument is a chain of zero or more expressions 
  716.         separated by commas.  If a comma occurs with no preceding 
  717.         expression, a word of 0000H is spliced into the code.  The word 
  718.         is placed into memory high byte in low address, low byte in high 
  719.         address -- the opposite of standard Intel order.  The sequence of
  720.         bytes 0FFH, 0FEH, 00H, 00H, 01H, 02H could be spliced into the
  721.         code with the following statement:
  722.  
  723.                        DW        0FFFEH, , 0102H
  724.  
  725.  
  726.         4.5  Pseudo-ops -- END
  727.  
  728.              The END pseudo-op tells the assembler that the source 
  729.         program is over.  Any further lines of the source file are 
  730.         ignored and not passed on to the listing.  If an argument is 
  731.         added to the END statement, the value of the argument will be 
  732.         placed in the execution address slot in the Intel hex object 
  733.         file.  The execution address defaults to the program counter 
  734.         value at the point where the END was encountered.  Thus, to 
  735.         specify that the program starts at label START, the END statement 
  736.         would be:
  737.  
  738.                        END       START
  739.  
  740.  
  741.                                        11
  742.  
  743.  
  744.  
  745.  
  746.              If end-of-file is encountered on the source file before an 
  747.         END statement is reached, the assembler will add an END statement 
  748.         to the listing and flag it with a * (missing statement) error.
  749.  
  750.  
  751.         4.6  Pseudo-ops -- EQU
  752.  
  753.              The EQU pseudo-op is used to assign a specific value to a 
  754.         label, thus the label on this line is REQUIRED.  Once the value 
  755.         is assigned, it cannot be reassigned by writing the label in 
  756.         column 1, by another EQU statement by a REG statement, or by a 
  757.         SET statement.  Thus, for example, the following statement 
  758.         assigns the value 2 to the label TWO:
  759.  
  760.              TWO       EQU       1 + 1
  761.  
  762.              The expression in the argument field must contain no forward 
  763.         references.
  764.  
  765.  
  766.         4.7  Pseudo-ops -- IF, ELSE, ENDIF
  767.  
  768.              These three pseudo-ops allow the assembler to choose whether 
  769.         or not to assemble certain blocks of code based on the result of 
  770.         an expression.  Code that is not assembled is passed through to 
  771.         the listing but otherwise ignored by the assembler.  The IF 
  772.         pseudo-op signals the beginning of a conditionally assembled 
  773.         block.  It requires one argument that may contain no forward 
  774.         references.  If the value of the argument is non-zero, the block 
  775.         is assembled.  Otherwise, the block is ignored.  The ENDIF 
  776.         pseudo-op signals the end of the conditionally assembled block.  
  777.         For example:
  778.  
  779.                        IF   EXPRESSION     ;This whole thing generates
  780.                        DB   01H, 02H, 03H  ;  no code whatsoever if
  781.                        ENDIF               ;  EXPRESSION is zero.
  782.  
  783.         The ELSE pseudo-op allows the assembly of either one of two 
  784.         blocks, but not both.  The following two sequences are 
  785.         equivalent:
  786.  
  787.                        IF   EXPRESSION
  788.                        ... some stuff ...
  789.                        ELSE
  790.                        ... some more stuff ...
  791.                        ENDIF
  792.  
  793.              TEMP_LAB  SET  EXPRESSION
  794.                        IF   TEMP_LAB NE 0
  795.                        ... some stuff ...
  796.                        ENDIF
  797.                        IF   TEMP_LAB EQ 0
  798.                        ... some more stuff ...
  799.                        ENDIF
  800.  
  801.  
  802.                                        12
  803.  
  804.  
  805.  
  806.  
  807.              The pseudo-ops in this group do NOT permit labels to exist 
  808.         on the same line as the status of the label (ignored or not) 
  809.         would be ambiguous.
  810.  
  811.              All IF statements (even those in ignored conditionally 
  812.         assembled blocks) must have corresponding ENDIF statements and 
  813.         all ELSE and ENDIF statements must have a corresponding IF 
  814.         statement.
  815.  
  816.              IF blocks can be nested up to 16 levels deep before the 
  817.         assembler dies of a fatal error.  This should be adequate for any 
  818.         conceivable job, but if you need more, change the constant 
  819.         IFDEPTH in file A51.H and recompile the assembler.
  820.  
  821.  
  822.         4.8  Pseudo-ops -- INCL
  823.  
  824.              The INCL pseudo-op is used to splice the contents of another 
  825.         file into the current file at assembly time.  The name of the 
  826.         file to be INCLuded is specified as a normal string constant, so 
  827.         the following line would splice the contents of file "const.def" 
  828.         into the source code stream:
  829.  
  830.                        INCL      "const.def"
  831.  
  832.              INCLuded files may, in turn, INCLude other files until four 
  833.         files are open simultaneously.  This limit should be enough for 
  834.         any conceivable job, but if you need more, change the constant 
  835.         FILES in file A51.H and recompile the assembler.
  836.  
  837.  
  838.         4.9  Pseudo-ops -- ORG
  839.  
  840.              The ORG pseudo-op is used to set the assembly program 
  841.         counter to a particular value.  The expression that defines this 
  842.         value may contain no forward references.  The default initial 
  843.         value of the assembly program counter is 0000H.  The following 
  844.         statement would change the assembly program counter to 0F000H:
  845.  
  846.                        ORG       0F000H
  847.  
  848.              If a label is present on the same line as an ORG statement, 
  849.         it is assigned the new value of the assembly program counter.
  850.  
  851.  
  852.         4.10 Pseudo-ops -- PAGE
  853.  
  854.              The PAGE pseudo-op always causes an immediate page ejection 
  855.         in the listing by inserting a form feed ('\f') character before 
  856.         the next line.  If an argument is specified, the argument 
  857.         expression specifies the number of lines per page in the listing.  
  858.         Legal values for the expression are any number except 1 and 2.  A 
  859.         value of 0 turns the listing pagination off.  Thus, the following 
  860.         statement cause a page ejection and would divide the listing into 
  861.  
  862.  
  863.                                        13
  864.  
  865.  
  866.  
  867.         60-line pages:
  868.  
  869.                        PAGE      60
  870.  
  871.  
  872.         4.11 Pseudo-ops -- REG
  873.  
  874.              The REG pseudo-op functions like the EQU pseudo-op except 
  875.         that the argument must be a register -- i.e. R0 - R7 or another 
  876.         label defined with the REG pseudo-op.  A label defined with REG 
  877.         can be used anywhere that R0 - R7 is called for.  This includes 
  878.         forms like @LABEL.  Like the EQU statement, the argument 
  879.         expression must contain no forward references.  A label defined 
  880.         with the REG statement cannot be redefined by writing it in 
  881.         column 1, by an EQU statement, by another REG statement, or by a 
  882.         SET statement.  The following pair of statements will assemble to 
  883.         a "MOV @R0, A" instruction:
  884.  
  885.              TEMP      REG       R0
  886.                        MOV       @TEMP, A
  887.  
  888.  
  889.         4.12 Pseudo-ops -- SET
  890.  
  891.              The SET pseudo-op functions like the EQU pseudo-op except 
  892.         that the SET statement can reassign the value of a label that has 
  893.         already been assigned by another SET statement.  Like the EQU 
  894.         statement, the argument expression may contain no forward 
  895.         references.  A label defined by a SET statement cannot be 
  896.         redefined by writing it in column 1 or with an EQU statement.  
  897.         The following series of statements would set the value of label 
  898.         "COUNT" to 1, 2, then 3:
  899.  
  900.              COUNT     SET       1
  901.              COUNT     SET       2
  902.              COUNT     SET       3
  903.  
  904.  
  905.         4.13 Pseudo-ops -- TITL
  906.  
  907.              The TITL pseudo-op sets the running title for the listing.  
  908.         The argument field is required and must be a string constant, 
  909.         though the null string ("") is legal.  This title is printed 
  910.         after every page ejection in the listing, therefore, if page 
  911.         ejections have not been forced by the PAGE pseudo-op, the title 
  912.         will never be printed.  The following statement would print the 
  913.         title "Random Bug Generator -- Ver 3.14159" at the top of every 
  914.         page of the listing:
  915.  
  916.                        TITL      "Random Bug Generator -- Ver 3.14159"
  917.  
  918.  
  919.         5.0  Assembly Errors
  920.  
  921.              When a source line contains an illegal construct, the line 
  922.  
  923.  
  924.                                        14
  925.  
  926.  
  927.  
  928.         is flagged in the listing with a single-letter code describing 
  929.         the error.  The meaning of each code is listed below.  In 
  930.         addition, a count of the number of lines with errors is kept and 
  931.         printed on the C "stderr" device (by default, the console) after 
  932.         the END statement is processed.  If more than one error occurs in 
  933.         a given line, only the first is reported.  For example, the 
  934.         illegal label "=$#*'(" would generate the following listing line:
  935.  
  936.              L  0000   FF 00 00      =$#*'(     LDA       R0
  937.  
  938.  
  939.         5.1  Error * -- Illegal or Missing Statement
  940.  
  941.              This error occurs when either:
  942.  
  943.              1)   the assembler reaches the end of the source file 
  944.                   without seeing an END statement, or
  945.  
  946.              2)   an END statement is encountered in an INCLude file.
  947.  
  948.              If you are "sure" that the END statement is present when the 
  949.         assembler thinks that it is missing, it probably is in the 
  950.         ignored section of an IF block.  If the END statement is missing, 
  951.         supply it.  If the END statement is in an INCLude file, delete 
  952.         it.
  953.  
  954.  
  955.         5.2  Error ( -- Parenthesis Imbalance
  956.  
  957.              For every left parenthesis, there must be a right paren-
  958.         thesis.  Count them.
  959.  
  960.  
  961.         5.3  Error " -- Missing Quotation Mark
  962.  
  963.              Strings have to begin and end with either " or '.  Remember 
  964.         that " only matches " while ' only matches '.
  965.  
  966.  
  967.         5.4  Error B -- Branch Target Out of Bounds
  968.  
  969.              The 8051 relative branch instructions will only reach 
  970.         addresses that are within -128 and +127 bytes of the first byte 
  971.         of the next instruction.  The 8051 absolute branch instructions 
  972.         will only reach addresses on the same 2K page as the next 
  973.         instruction.  If this error occurs, the source code will have to 
  974.         be rearranged to bring the branch target within range or a long 
  975.         branch instruction that will reach anywhere will have to be used.
  976.  
  977.  
  978.         5.5  Error D -- Illegal Digit
  979.  
  980.              This error occurs if a digit greater than or equal to the 
  981.         base of a numeric constant is found.  For example, a 2 in a 
  982.         binary number would cause a D error.  Especially, watch for 8 or 
  983.  
  984.  
  985.                                        15
  986.  
  987.  
  988.  
  989.         9 in an octal number.
  990.  
  991.  
  992.         5.6  Error E -- Illegal Expression
  993.  
  994.              This error occurs because of:
  995.  
  996.              1)   a missing expression where one is required
  997.  
  998.              2)   a unary operator used as a binary operator or vice-
  999.                   versa
  1000.  
  1001.              3)   a missing binary operator
  1002.  
  1003.              4)   a SHL or SHR count that is not 0 thru 15
  1004.  
  1005.  
  1006.         5.7  Error I -- IF-ENDIF Imbalance
  1007.  
  1008.              For every IF there must be a corresponding ENDIF.  If this 
  1009.         error occurs on an ELSE or ENDIF statement, the corresponding IF 
  1010.         is missing.  If this error occurs on an END statement, one or 
  1011.         more ENDIF statements are missing.
  1012.  
  1013.  
  1014.         5.8  Error L -- Illegal Label
  1015.  
  1016.              This error occurs because of:
  1017.  
  1018.              1)   a non-alphabetic in column 1
  1019.  
  1020.              2)   a reserved word used as a label
  1021.  
  1022.              3)   a missing label on a BIT, EQU, REG, or SET statement
  1023.  
  1024.              4)   a label on an IF, ELSE, or ENDIF statement
  1025.  
  1026.  
  1027.         5.9  Error M -- Multiply Defined Label
  1028.  
  1029.              This error occurs because of:
  1030.  
  1031.              1)   a label defined in column 1 or with the EQU statement 
  1032.                   being redefined
  1033.  
  1034.              2)   a label defined by a SET statement being redefined 
  1035.                   either in column 1 or with the EQU statement
  1036.  
  1037.              3)   the value of the label changing between assembly passes
  1038.  
  1039.  
  1040.         5.10 Error O -- Illegal Opcode
  1041.  
  1042.              The opcode field of a source line may contain only a valid 
  1043.         machine opcode, a valid pseudo-op, or nothing at all.  Anything 
  1044.  
  1045.  
  1046.                                        16
  1047.  
  1048.  
  1049.  
  1050.         else causes this error.
  1051.  
  1052.  
  1053.         5.11 Error P -- Phasing Error
  1054.  
  1055.              This error occurs because of:
  1056.  
  1057.              1)   a forward reference in a BLK, CPU, EQU, ORG, or SET 
  1058.                   statement
  1059.  
  1060.              2)   a label disappearing between assembly passes
  1061.  
  1062.  
  1063.         5.12 Error S -- Illegal Syntax
  1064.  
  1065.              This error means that an argument field is scrambled.  Sort 
  1066.         the mess out and reassemble.  In particular, look for use of 
  1067.         registers that don't apply to a particular opcode, missing 
  1068.         commas, and the like.
  1069.  
  1070.  
  1071.         5.13 Error T -- Too Many Arguments
  1072.  
  1073.              This error occurs if there are more items (expressions, 
  1074.         register designators, etc.) in the argument field than the opcode 
  1075.         or pseudo-op requires.  The assembler ignores the extra items but 
  1076.         issues this error in case something is really mangled.
  1077.  
  1078.  
  1079.         5.14 Error U -- Undefined Label
  1080.  
  1081.              This error occurs if a label is referenced in an expression 
  1082.         but not defined anywhere in the source program.  If you are 
  1083.         "sure" you have defined the label, note that upper and lower case 
  1084.         letters in labels are different.  Defining "LABEL" does not 
  1085.         define "Label."
  1086.  
  1087.  
  1088.         5.15 Error V -- Illegal Value
  1089.  
  1090.              This error occurs because:
  1091.  
  1092.              1)   an immediate value is not -128 thru 255, or
  1093.  
  1094.              2)   a direct address is not 0 thru 255, or
  1095.  
  1096.              3)   a bit expression contains an illegal address or bit 
  1097.                   number, or
  1098.  
  1099.              4)   a DB argument is not -128 thru 255, or
  1100.  
  1101.              5)   an INCL argument refers to a file that does not exist.
  1102.  
  1103.  
  1104.         6.0  Warning Messages
  1105.  
  1106.  
  1107.                                        17
  1108.  
  1109.  
  1110.  
  1111.  
  1112.              Some errors that occur during the parsing of the cross-
  1113.         assembler command line are non-fatal.  The cross-assembler flags 
  1114.         these with a message on the C "stdout" device (by default, the 
  1115.         console) beginning with the word "Warning."  The messages are 
  1116.         listed below:
  1117.  
  1118.  
  1119.         6.1  Warning -- Illegal Option Ignored
  1120.  
  1121.              The only options that the cross-assembler knows are -l and  
  1122.         -o.  Any other command line argument beginning with - will draw 
  1123.         this error.
  1124.  
  1125.  
  1126.         6.2  Warning -- -l Option Ignored -- No File Name
  1127.         6.3  Warning -- -o Option Ignored -- No File Name
  1128.  
  1129.              The -l and -o options require a file name to tell the 
  1130.         assembler where to put the listing file or object file.  If this 
  1131.         file name is missing, the option is ignored.
  1132.  
  1133.  
  1134.         6.4  Warning -- Extra Source File Ignored
  1135.  
  1136.              The cross-assembler will only assemble one file at a time, 
  1137.         so source file names after the first are ignored.  To assemble a 
  1138.         second file, invoke the assembler again.  Note that under CP/M-
  1139.         80, the old trick of reexecuting a core image will NOT work as 
  1140.         the initialized data areas are not reinitialized prior to the 
  1141.         second run.
  1142.  
  1143.  
  1144.         6.5  Warning -- Extra Listing File Ignored
  1145.         6.6  Warning -- Extra Object File Ignored
  1146.  
  1147.              The cross-assembler will only generate one listing and 
  1148.         object file per assembly run, so -l and -o options after the 
  1149.         first are ignored.
  1150.  
  1151.  
  1152.         7.0  Fatal Error Messages
  1153.  
  1154.              Several errors that occur during the parsing of the cross-
  1155.         assembler command line or during the assembly run are fatal.  The 
  1156.         cross-assembler flags these with a message on the C "stdout" 
  1157.         device (by default, the console) beginning with the words "Fatal 
  1158.         Error."  The messages are explained below:
  1159.  
  1160.  
  1161.         7.1  Fatal Error -- No Source File Specified
  1162.  
  1163.              This one is self-explanatory.  The assembler does not know 
  1164.         what to assemble.
  1165.  
  1166.  
  1167.  
  1168.                                        18
  1169.  
  1170.  
  1171.  
  1172.  
  1173.         7.2  Fatal Error -- Source File Did Not Open
  1174.  
  1175.              The assembler could not open the source file.  The most 
  1176.         likely cause is that the source file as specified on the command 
  1177.         line does not exist.  On larger systems, there could also be 
  1178.         priviledge violations.  Rarely, a read error in the disk 
  1179.         directory could cause this error.
  1180.  
  1181.  
  1182.         7.3  Fatal Error -- Listing File Did Not Open
  1183.         7.4  Fatal Error -- Object File Did Not Open
  1184.  
  1185.              This error indicates either a defective listing or object 
  1186.         file name or a full disk directory.  Correct the file name or 
  1187.         make more room on the disk.
  1188.  
  1189.  
  1190.         7.5  Fatal Error -- Error Reading Source File
  1191.  
  1192.              This error generally indicates a read error in the disk data 
  1193.         space.  Use your backup copy of the source file (You do have one, 
  1194.         don't you?) to recreate the mangled file and reassemble.
  1195.  
  1196.  
  1197.         7.6  Fatal Error -- Disk or Directory Full
  1198.  
  1199.              This one is self-explanatory.  Some more space must be found 
  1200.         either by deleting files or by using a disk with more room on it.
  1201.  
  1202.  
  1203.         7.7  Fatal Error -- File Stack Overflow
  1204.  
  1205.              This error occurs if you exceed the INCLude file limit of 
  1206.         four files open simultaneously.  This limit can be increased by 
  1207.         increasing the constant FILES in file A51.H and recompiling the 
  1208.         cross-assembler.
  1209.  
  1210.  
  1211.         7.8  Fatal Error -- If Stack Overflow
  1212.  
  1213.              This error occurs if you exceed the nesting limit of 16 IF 
  1214.         blocks.  This limit can be increased by increasing the constant 
  1215.         IFDEPTH in file A51.H and recompiling the cross-assembler.
  1216.  
  1217.  
  1218.         7.9  Fatal Error -- Too Many Symbols
  1219.  
  1220.              Congratulations!  You have run out of memory.  The space for 
  1221.         the cross-assembler's symbol table is allocated at run-time using 
  1222.         the C library function malloc(), so the cross-assembler will use 
  1223.         all available memory.  The only solutions to this problem are to 
  1224.         lessen the number of labels in the source program or to add more 
  1225.         memory.
  1226.  
  1227.  
  1228.  
  1229.                                        19
  1230. verflow
  1231.  
  1232.              This error occurs if you exceed the INCLude file limit of 
  1233.         four fi