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

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