home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 219_01 / a48.doc < prev    next >
Encoding:
Text File  |  1989-01-13  |  44.9 KB  |  1,176 lines

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