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

  1. /*
  2.     HEADER:        CUG267;
  3.     TITLE:        2650 Cross-Assembler (Portable);
  4.     FILENAME:    A26.DOC;
  5.     VERSION:    0.1;
  6.     DATE:        08/27/1988;
  7.     SEE-ALSO:    A26.H;
  8.     AUTHORS:    William C. Colley, III;
  9. */
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.                          2650 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 ...................................  5
  81.              2.4  Expressions ........................................  6
  82.         3.0  Machine Opcodes .........................................  7
  83.              3.1  Opcodes -- No Arguments ............................  8
  84.              3.2  Opcodes -- Register Operations .....................  8
  85.              3.3  Opcodes -- Register-to-Register Operations .........  8
  86.              3.4  Opcodes -- Register Immediate Operations ...........  8
  87.              3.5  Opcodes -- Register Relative Operations ............  9
  88.              3.6  Opcodes -- Register Absolute Operations ............  9
  89.              3.7  Opcodes -- Zero-Relative Branches ..................  9
  90.              3.8  Opcodes -- Conditional Relative Branches ........... 10
  91.              3.9  Opcodes -- Conditional Absolute Branches ........... 10
  92.              3.10 Opcodes -- Register Relative Branches .............. 10
  93.              3.11 Opcodes -- Register Absolute Branches .............. 10
  94.              3.12 Opcodes -- Indexed Branches ........................ 11
  95.              3.13 Opcodes -- Conditional Returns ..................... 11
  96.         4.0  Pseudo Opcodes .......................................... 11
  97.              4.1  Pseudo-ops -- ACON ................................. 11
  98.              4.2  Pseudo-ops -- DATA ................................. 11
  99.              4.3  Pseudo-ops -- EJE .................................. 12
  100.              4.4  Pseudo-ops -- END .................................. 12
  101.              4.5  Pseudo-ops -- EQU .................................. 12
  102.              4.6  Pseudo-ops -- IF, ELSE, ENDI ....................... 13
  103.              4.7  Pseudo-ops -- INCL ................................. 13
  104.              4.8  Pseudo-ops -- ORG .................................. 14
  105.              4.9  Pseudo-ops -- RES .................................. 14
  106.              4.10 Pseudo-ops -- SET .................................. 14
  107.              4.11 Pseudo-ops -- TITL ................................. 14
  108.         5.0  Assembly Errors ......................................... 15
  109.              5.1  Error * -- Missing Statement ....................... 15
  110.              5.2  Error ( -- Parenthesis Imbalance ................... 15
  111.              5.3  Error " -- Missing Quotation Mark .................. 15
  112.              5.4  Error A -- Address Can't Be Reached ................ 15
  113.              5.5  Error C -- Illegal Condition Code .................. 16
  114.              5.6  Error D -- Illegal Digit ........................... 16
  115.              5.7  Error E -- Illegal Expression ...................... 16
  116.              5.8  Error F -- Control Flow Error ...................... 16
  117.              5.9  Error I -- IF-ENDIF Imbalance ...................... 16
  118.              5.10 Error L -- Illegal Label ........................... 17
  119.              5.11 Error M -- Multiply Defined Label .................. 17
  120.              5.12 Error O -- Illegal Opcode .......................... 17
  121.              5.13 Error P -- Phasing Error ........................... 17
  122.              5.14 Error R -- Illegal Register ........................ 17
  123.              5.15 Error S -- Illegal Syntax .......................... 18
  124.              5.16 Error T -- Too Many Arguments ...................... 18
  125.              5.17 Error U -- Undefined Label ......................... 18
  126.              5.18 Error V -- Illegal Value ........................... 18
  127.  
  128.  
  129.  
  130.  
  131.                                         1
  132.  
  133.  
  134.  
  135.         6.0  Warning Messages ........................................ 18
  136.              6.1  Warning -- Illegal Option Ignored .................. 18
  137.              6.2  Warning -- -l Option Ignored -- No File Name ....... 19
  138.              6.3  Warning -- -o Option Ignored -- No File Name ....... 19
  139.              6.4  Warning -- Extra Source File Ignored ............... 19
  140.              6.5  Warning -- Extra Listing File Ignored .............. 19
  141.              6.6  Warning -- Extra Object File Ignored ............... 19
  142.         7.0  Fatal Error Messages .................................... 19
  143.              7.1  Fatal Error -- No Source File Specified ............ 19
  144.              7.2  Fatal Error -- Source File Did Not Open ............ 19
  145.              7.3  Fatal Error -- Listing File Did Not Open ........... 20
  146.              7.4  Fatal Error -- Object File Did Not Open ............ 20
  147.              7.5  Fatal Error -- Error Reading Source File ........... 20
  148.              7.6  Fatal Error -- Disk or Directory Full .............. 20
  149.              7.7  Fatal Error -- File Stack Overflow ................. 20
  150.              7.8  Fatal Error -- If Stack Overflow ................... 20
  151.              7.9  Fatal Error -- Too Many Symbols .................... 20
  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 2650 source code into 2650 
  203.         object code, but it runs on a Z-80, an 8088, a 68000, or whatever 
  204.         other CPU you happen to have a C compiler for.  The reason that 
  205.         cross-assemblers are useful is that you probably already have a 
  206.         CPU with memory, disk drives, a text editor, an operating system, 
  207.         and all sorts of hard-to-build or expensive facilities on hand.  
  208.         A cross-assembler allows you to use these facilites to develop 
  209.         code for an 2650.
  210.  
  211.              This program requires one input file (your 2650 source code) 
  212.         and zero to two output files (the listing and the object).  The 
  213.         input file MUST be specified, or the assembler will bomb on a 
  214.         fatal error.  The listing and object files are optional.  If no 
  215.         listing file is specified, no listing is generated, and if no 
  216.         object file is specified, no object is generated.  If the object 
  217.         file is specified, the object is written to this file in "Intel 
  218.         hexadecimal" format.
  219.  
  220.              The command line for the cross-assembler looks like this:
  221.  
  222.                   A26 source_file { >list_file } { -o object_file }
  223.  
  224.         where the { } indicates that the specified item is optional.
  225.  
  226.              Some examples are in order:
  227.  
  228.              a26 test26.asm                          source:   test26.asm
  229.                                                      listing:  none
  230.                                                      object:   none
  231.  
  232.              a26 test26.asm -l test26.prn            source:   test26.asm
  233.                                                      listing:  test26.prn
  234.                                                      object:   none
  235.  
  236.              a26 test26.asm -o test26.hex            source:   test26.asm
  237.                                                      listing:  none
  238.                                                      object:   test26.hex
  239.  
  240.              a26 test26.asm -l test26.prn -o test26.hex
  241.                                                      source:   test26.asm
  242.                                                      listing:  test26.prn
  243.                                                      object:   test26.hex
  244.  
  245.              The order in which the source, listing, and object files are 
  246.         specified does not matter.  Note that no default file name exten-
  247.         sions are supplied by the assembler as this gives rise to porta-
  248.         bility problems.
  249.  
  250.  
  251.  
  252.  
  253.                                         3
  254.  
  255.  
  256.  
  257.         2.0  Format of Cross-Assembler Source Lines
  258.  
  259.              The source file that the cross-assembler processes into a 
  260.         listing and an object is an ASCII text file that you can prepare 
  261.         with whatever editor you have at hand.  The most-significant 
  262.         (parity) bit of each character is cleared as the character is 
  263.         read from disk by the cross-assembler, so editors that set this 
  264.         bit (such as WordStar's document mode) should not bother this 
  265.         program.  All printing characters, the ASCII TAB character (09H), 
  266.         and newline character(s) are processed by the assembler.  All 
  267.         other characters are passed through to the listing file, but are 
  268.         otherwise ignored.
  269.  
  270.              The source file is divided into lines by newline char-
  271.         acter(s).  The internal buffers of the cross-assembler will 
  272.         accommodate lines of up to 255 characters which should be more 
  273.         than ample for almost any job.  If you must use longer lines, 
  274.         change the constant MAXLINE in file A26.H and recompile the 
  275.         cross-assembler.  Otherwise, you will overflow the buffers, and 
  276.         the program will mysteriously crash.
  277.  
  278.              Each source line is made up of three fields:  the label 
  279.         field, the opcode field, and the argument field.  The label field 
  280.         is optional, but if it is present, it must begin in column 1.  
  281.         The opcode field is optional, but if it is present, it must not 
  282.         begin in column 1.  If both a label and an opcode are present, 
  283.         one or more spaces and/or TAB characters must separate the two.  
  284.         If the opcode requires arguments, they are placed in the argument 
  285.         field which is separated from the opcode field by one or more 
  286.         spaces and/or TAB characters.  Finally, an optional comment can 
  287.         be added to the end of the line.  This comment must begin with a 
  288.         semicolon which signals the assembler to pass the rest of the 
  289.         line to the listing and otherwise ignore it.  Thus, the source 
  290.         line looks like this:
  291.  
  292.              {label}{ opcode{ arguments}}{;commentary}
  293.  
  294.         where the { } indicates that the specified item is optional.
  295.  
  296.              Some examples are in order:
  297.  
  298.           column 1
  299.              |
  300.              v
  301.              GRONK   STRA,R0   *PTR,R3,+   ; This line has everything.
  302.                      LODA,R0   *PTR,R3     ; This line has no label.
  303.              BEEP                          ; This line has no opcode.
  304.              ; This line has no label and no opcode.
  305.  
  306.              ; The previous line has nothing at all.
  307.                      END                   ; This line has no argument.
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.                                         4
  315.  
  316.  
  317.  
  318.         2.1  Labels
  319.  
  320.              A label is any sequence of alphabetic or numeric characters 
  321.         starting with an alphabetic.  The legal alphabetics are:
  322.  
  323.               ! # $ % & , . : ?  @ [ \ ] ^ _  ` { | }  ~  A-Z  a-z
  324.  
  325.         The numeric characters are the digits 0-9.  Note that "A" is not 
  326.         the same as "a" in a label.  This can explain mysterious U 
  327.         (undefined label) errors occurring when a label appears to be 
  328.         defined.
  329.  
  330.              A label is permitted on any line except a line where the 
  331.         opcode is IF, ELSE, or ENDI.  The label is assigned the value of 
  332.         the assembly program counter before any of the rest of the line 
  333.         is processed except when the opcode is EQU, ORG, or SET.
  334.  
  335.              Labels can have the same name as opcodes, but they cannot
  336.         have the same name as operators or registers.  The reserved 
  337.         (operator and register) names are:
  338.  
  339.              $         AND       EQ        GE        GT        HIGH
  340.              LE        LT        LOW       MOD       NE        NOT
  341.              OR        SHL       SHR       XOR
  342.  
  343.              If a label is used in an expression before it is assigned a 
  344.         value, the label is said to be "forward-referenced."  For 
  345.         example:
  346.  
  347.              L1   EQU  L2 + 1   ; L2 is forward-referenced here.
  348.              L2
  349.              L3   EQU  L2 + 1   ; L2 is not forward-referenced here.
  350.  
  351.  
  352.         2.2  Numeric Constants
  353.  
  354.              Numeric constants are formed according to the Intel 
  355.         convention.  A numeric constant starts with a numeric character 
  356.         (0-9), continues with zero or more digits (0-9, A-F), and ends 
  357.         with an optional base designator.  The base designators are H for 
  358.         hexadecimal, none or D for decimal, O or Q for octal, and B for 
  359.         binary.  The hex digits a-f are converted to upper case by the 
  360.         assembler.  Note that a numeric constant cannot begin with A-F as 
  361.         it would be indistinguishable from a label.  Thus, all of the 
  362.         following evaluate to 255 (decimal):
  363.  
  364.                    0ffH   255   255D   377O   377Q   11111111B
  365.  
  366.  
  367.         2.3  String Constants
  368.  
  369.              A string constant is zero or more characters enclosed in 
  370.         either single quotes (' ') or double quotes (" ").  Single quotes 
  371.         only match single quotes, and double quotes only match double 
  372.         quotes, so if you want to put a single quote in a string, you can 
  373.  
  374.  
  375.                                         5
  376.  
  377.  
  378.  
  379.         do it like this:  "'".  In all contexts except the DATA 
  380.         statement, the first character or two of the string constant are 
  381.         all that are used.  The rest is ignored.  Noting that the ASCII 
  382.         codes for "A" and "B" are 41H and 42H, respectively, will explain 
  383.         the following examples:
  384.  
  385.                   "" and ''           evaluate to 0000H
  386.                   "A" and 'A'         evaluate to 0041H
  387.                   "AB"                evaluates to 4142H
  388.  
  389.         Note that the null string "" is legal and evaluates to 0000H.
  390.  
  391.  
  392.         2.4  Expressions
  393.  
  394.              An expression is made up of labels, numeric constants, and 
  395.         string constants glued together with arithmetic operators, 
  396.         logical operators, and parentheses in the usual way that 
  397.         algebraic expressions are made.  Operators have the following 
  398.         fairly natural order of precedence:
  399.  
  400.              Highest        anything in parentheses
  401.                             unary +, unary -
  402.                             *, /, MOD, SHL, SHR
  403.                             binary +, binary -
  404.                             LT, LE, EQ, GE, GT, NE
  405.                             NOT
  406.                             AND
  407.                             OR, XOR
  408.              Lowest         HIGH, LOW
  409.  
  410.              A few notes about the various operators are in order:
  411.  
  412.              1)   The remainder operator MOD yields the remainder from 
  413.                   dividing its left operand by its right operand.
  414.  
  415.              2)   The shifting operators SHL and SHR shift their left 
  416.                   operand to the left or right the number of bits 
  417.                   specified by their right operand.
  418.  
  419.              3)   The relational operators LT, LE, EQ, GE, GT, and NE can 
  420.                   also be written as <, <= or =<, =, >= or =>, and <> or 
  421.                   ><, respectively.  They evaluate to 0FFFFH if the 
  422.                   statement is true, 0 otherwise.
  423.  
  424.              4)   The logical opeators NOT, AND, OR, and XOR do bitwise 
  425.                   operations on their operand(s).
  426.  
  427.              5)   HIGH and LOW extract the high or low byte, of an 
  428.                   expression.
  429.  
  430.              6)   The special symbol $ can be used in place of a label or 
  431.                   constant to represent the value of the program counter 
  432.                   before any of the current line has been processed.
  433.  
  434.  
  435.  
  436.                                         6
  437.  
  438.  
  439.  
  440.              Some examples are in order at this point:
  441.  
  442.              2 + 3 * 4                          evaluates to 14
  443.              (2 + 3) * 4                        evaluates to 20
  444.              NOT 11110000B XOR 00001010B        evaluates to 00000101B
  445.              HIGH 1234H SHL 1                   evaluates to 0024H
  446.              001Q EQ 0                          evaluates to 0
  447.              001Q = 2 SHR 1                     evaluates to 0FFFFH
  448.  
  449.              All arithmetic is unsigned with overflow from the 16-bit 
  450.         word ignored.  Thus:
  451.  
  452.              32768 * 2                          evaluates to 0
  453.  
  454.  
  455.         3.0  Machine Opcodes
  456.  
  457.              The opcodes of the 2650 processor are divided into groups 
  458.         below by the type of arguments required in the argument field of 
  459.         the source line.  If an opcode requires multiple arguments, these 
  460.         must be placed in the argument field in order and separated by 
  461.         commas.
  462.  
  463.              The following shorthand notations are used in the succeeding 
  464.         sections of the manual:
  465.  
  466.              CC        a label or numeric constant with a value from 0 to 
  467.                        3 that specifies the condition under which the 
  468.                        branch is or is not taken.
  469.  
  470.              Rn        a label or numeric constant with a value from 0 to 
  471.                        3 that specifies which register the operation 
  472.                        applies to.
  473.  
  474.              immed     an expression that has a value in the range -128 
  475.                        to 255.
  476.  
  477.              mask      an expression that has a value in the range 0 to 
  478.                        255.
  479.  
  480.              rel       an expression that evaluates to an address in the 
  481.                        range -62 to +65 bytes from the beginning of the 
  482.                        current instruction.  Bear in mind that 2650 
  483.                        address calculations are done modulo 8192 and that 
  484.                        the upper two address bits are unchanged by the 
  485.                        computation.  Therefore, the target address must 
  486.                        be on the same 8K byte page as the instruction.
  487.  
  488.              zrel      same as rel above except that the allowable range 
  489.                        is -64 to +63 bytes from location 0.  The upper 
  490.                        two address bits are set to 0 during the address 
  491.                        computation, so the address must be on 8K byte 
  492.                        page 0.
  493.  
  494.              abs_13    an expression that evaluates to an address on the 
  495.  
  496.  
  497.                                         7
  498.  
  499.  
  500.  
  501.                        same 8K byte page as the current instruction.
  502.  
  503.              abs_15    an expression that evaluates to an address 
  504.                        anywhere in the range 0 to 7FFFH.
  505.  
  506.              [ ]       Optional items are enclosed in square brackets.
  507.  
  508.              +         either a + sign or a - sign.
  509.  
  510.  
  511.         3.1  Opcodes -- No Arguments
  512.  
  513.              The following opcodes allow no arguments at all in their 
  514.         argument fields:
  515.  
  516.              HALT      LPSL      LPSU      NOP       SPSL      SPSU
  517.  
  518.  
  519.         3.2  Opcodes -- Register Operations
  520.  
  521.              The opcodes in this group go like this:
  522.  
  523.                   DAR,Rn                   RRR,Rn
  524.                   REDC,Rn                  WRTC,Rn
  525.                   REDD,Rn                  WRTD,Rn
  526.                   RRL,Rn
  527.  
  528.  
  529.         3.3  Opcodes -- Register-to-Register Operations
  530.  
  531.              The opcodes in this group operate between a specified 
  532.         register and R0.  They go like this:
  533.  
  534.                   ADDZ      Rn
  535.                   ANDZ      Rn        ;ANDZ R0 will cause an R error
  536.                                       ;  since 040H is the opcode for
  537.                                       ;  HALT.
  538.                   COMZ      Rn
  539.                   EORZ      Rn
  540.                   IORZ      Rn
  541.                   LODZ      Rn        ;LODZ R0 is converted to IORZ R0
  542.                                       ;  since opcode 00H is illegal.
  543.                   STRZ      Rn        ;STRZ R0 will cause an R error
  544.                                       ;  since 0C0H is the opcode for
  545.                                       ;  NOP.          
  546.                   SUBZ      Rn
  547.  
  548.  
  549.         3.4  Opcodes -- Register Immediate Operations
  550.  
  551.              The opcodes in this group operate between a specified 
  552.         register and an immediate value found in the second byte of the 
  553.         instruction.  They go like this:
  554.  
  555.                   ADDI,Rn   immed
  556.  
  557.  
  558.                                         8
  559.  
  560.  
  561.  
  562.                   ANDI,Rn   immed
  563.                   COMI,Rn   immed
  564.                   CPSL      mask           ;These two operate on the
  565.                   CPSU      mask           ;  program status register.
  566.                   EORI,Rn   immed
  567.                   IORI,Rn   immed
  568.                   LODI,Rn   immed
  569.                   PPSL      mask           ;These two operate on the
  570.                   PPSU      mask           ;  program status register.
  571.                   SUBI,Rn   immed
  572.                   TMI,Rn    mask
  573.                   TPSL      mask           ;These two operate on the
  574.                   TPSU      mask           ;  program status register.
  575.  
  576.              Two other opcodes have a similar syntax, though the 
  577.         immediate operand is used as the address of an I/O port instead 
  578.         of as a data byte.  The opcodes go like this:
  579.  
  580.                   REDE,Rn   port           ;port is an expression with a
  581.                   WRTE,Rn   port           ;  value between 0 and 255.
  582.  
  583.  
  584.         3.5  Opcodes -- Register Relative Operations
  585.  
  586.              The opcodes in this group operate between a specified 
  587.         register and a memory location specified with PC-relative 
  588.         addressing.  The opcodes go like this:
  589.  
  590.                   ADDR,Rn   [*]rel         IORR,Rn   [*]rel
  591.                   ANDR,Rn   [*]rel         LODR,Rn   [*]rel
  592.                   COMR,Rn   [*]rel         STRR,Rn   [*]rel
  593.                   EORR,Rn   [*]rel         SUBR,Rn   [*]rel
  594.  
  595.  
  596.         3.6  Opcodes -- Register Absolute Operations
  597.  
  598.              The opcodes in this group operate between a specified 
  599.         register and a memory location on the same page as the 
  600.         instruction using absolute addressing.  The opcodes are:
  601.  
  602.                   ADDA      ANDA      COMA      EORA      IORA
  603.                   LODA      STRA      SUBA
  604.  
  605.              The syntax allows two choices:
  606.  
  607.                   1)   ADDA,Rn        [*]abs_13
  608.  
  609.                   2)   ADDA,R0        [*]abs_13[,Rn[,+]]
  610.  
  611.  
  612.         3.7  Opcodes -- Zero-Relative Branches
  613.  
  614.              The opcodes ZBRR and ZBSR branch to a location on 8K byte 
  615.         page 0 that is -64 to +63 bytes from location 0.  The syntax foes 
  616.         like this:
  617.  
  618.  
  619.                                         9
  620.  
  621.  
  622.  
  623.  
  624.                   ZBRR      [*]zrel
  625.  
  626.  
  627.         3.8  Opcodes -- Conditional Relative Branches
  628.  
  629.              The conditional relative branch opcodes branch to a location 
  630.         -62 to +65 bytes from the first byte of the instruction.  Bear in 
  631.         mind that this arithmetic is done modulo 8K with the upper two 
  632.         address bits unchanged.  The instructions are:
  633.  
  634.                   BCFR,CC   [*]rel         ;CC = 3 will cause a C error
  635.                                            ;  since 9BH is the opcode for
  636.                                            ;  ZBRR.
  637.                   BCTR,CC   [*]rel
  638.                   BSFR,CC   [*]rel         ;CC = 3 will cause a C error
  639.                                            ;  since 0BBH is the opcode
  640.                                            ;  for ZBSR.
  641.                   BSTR,CC   [*]rel
  642.  
  643.  
  644.         3.9  Opcodes -- Conditional Absolute Branches
  645.  
  646.              The conditional absolute branch opcodes branch to a location 
  647.         anywhere in the machine's 32K byte address space.  The 
  648.         instructions are:
  649.  
  650.                   BCFA,CC   [*]abs_15      ;CC = 3 will cause a C error
  651.                                            ;  since 9FH is the opcode for
  652.                                            ;  BXA.
  653.                   BCTA,CC   [*]abs_15
  654.                   BSFA,CC   [*]abs_15      ;CC = 3 will cause a C error
  655.                                            ;  since 0BFH is the opcode
  656.                                            ;  for BSXA.
  657.                   BSTA,CC   [*]abs_15
  658.  
  659.  
  660.         3.10 Opcodes -- Register Relative Branches
  661.  
  662.              The register relative branch opcodes branch to a location 
  663.         -62 to +65 bytes from the first byte of the instruction.  Bear in 
  664.         mind that this arithmetic is done modulo 8K with the upper two 
  665.         address bits unchanged.  The instructions are:
  666.  
  667.                   BDRR,Rn   [*]rel         BRNR,Rn   [*]rel
  668.                   BIRR,Rn   [*]rel         BSNR,Rn   [*]rel
  669.  
  670.  
  671.         3.11 Opcodes -- Conditional Absolute Branches
  672.  
  673.              The conditional absolute branch opcodes branch to a location 
  674.         anywhere in the machine's 32K byte address space.  The 
  675.         instructions are:
  676.  
  677.                   BDRA,Rn   [*]abs_15      BRNA,Rn   [*]abs_15
  678.  
  679.  
  680.                                        10
  681.  
  682.  
  683.  
  684.                   BIRA,Rn   [*]abs_15      BSNA,Rn   [*]abs_15
  685.  
  686.  
  687.         3.12 Opcodes -- Indexed Branches
  688.  
  689.              The indexed branch opcodes branch to a location anywhere in 
  690.         the machine's 32K address space indexed on the contents of R3.  
  691.         The instructions go like this:
  692.  
  693.                   BSXA      [*]abs_15,R3
  694.                   BXA       [*]abs_15,R3
  695.  
  696.  
  697.         3.13 Opcodes -- Conditional Returns
  698.  
  699.              The conditional return instructions return from subroutine 
  700.         if a specified condition is met.  The instructions are:
  701.  
  702.                   RETC,CC                  RETE,CC
  703.  
  704.  
  705.         4.0  Pseudo Opcodes
  706.  
  707.              Unlike 2650 opcodes, pseudo opcodes (pseudo-ops) do not 
  708.         represent machine instructions.  They are, rather, directives to 
  709.         the assembler.  These directives require various numbers and 
  710.         types of arguments.  They will be listed individually below.
  711.  
  712.  
  713.         4.1  Pseudo-ops -- ACON
  714.  
  715.              The DW pseudo-op allows 15-bit words to be spliced into the 
  716.         object code.  Its argument is a chain of zero or more expressions 
  717.         separated by commas.  If a comma occurs with no preceding 
  718.         expression, a word of 0000H is spliced into the code.  The word 
  719.         is placed into memory low byte in low address, high byte in high 
  720.         address as per standard Intel order.  The sequence of bytes 
  721.         07FH, 0FFH, 00H, 00H, 01H, 02H could be spliced into the code 
  722.         with the following statement:
  723.  
  724.                        ACON      07FFFH, , 0102H
  725.  
  726.  
  727.         4.2  Pseudo-ops -- DATA
  728.  
  729.              The DATA pseudo-op allows arbitrary bytes to be spliced into 
  730.         the object code.  Its argument is a chain of zero or more 
  731.         expressions that evaluate to -128 through 255 separated by 
  732.         commas.  If a comma occurs with no preceding expression, a 00H 
  733.         byte is spliced into the object code.  The sequence of bytes 
  734.         0FEH, 0FFH, 00H, 01H, 02H could be spliced into the code with the 
  735.         following statement:
  736.  
  737.                        DATA      -2, -1, , 1, 2
  738.  
  739.  
  740.  
  741.                                        11
  742.  
  743.  
  744.  
  745.              String constants are handled differently in DATA statements 
  746.         than in other places.  If a string constant is written with no 
  747.         other arithmetic done on it, the string constant is not truncated 
  748.         to two bytes.  Instead, the entire string is be spliced into the 
  749.         object code.  For example:
  750.  
  751.                        DATA      "Kaboom!!", 0DH, 0AH     ;This is 10
  752.                                                           ;bytes of code.
  753.  
  754.  
  755.         4.3  Pseudo-ops -- EJE
  756.  
  757.              The EJE pseudo-op always causes an immediate page ejection 
  758.         in the listing by inserting a form feed ('\f') character before 
  759.         the next line.  If an argument is specified, the argument 
  760.         expression specifies the number of lines per page in the listing.  
  761.         Legal values for the expression are any number except 1 and 2.  A 
  762.         value of 0 turns the listing pagination off.  Thus, the following 
  763.         statement cause a page ejection and would divide the listing into 
  764.         60-line pages:
  765.  
  766.                        PAGE      60
  767.  
  768.  
  769.         4.4  Pseudo-ops -- END
  770.  
  771.              The END pseudo-op tells the assembler that the source 
  772.         program is over.  Any further lines of the source file are 
  773.         ignored and not passed on to the listing.  If an argument is 
  774.         added to the END statement, the value of the argument will be 
  775.         placed in the execution address slot in the Intel hex object 
  776.         file.  The execution address defaults to the program counter 
  777.         value at the point where the END was encountered.  Thus, to 
  778.         specify that the program starts at label START, the END statement 
  779.         would be:
  780.  
  781.                        END       START
  782.  
  783.              If end-of-file is encountered on the source file before an 
  784.         END statement is reached, the assembler will add an END statement 
  785.         to the listing and flag it with a * (missing statement) error.
  786.  
  787.  
  788.         4.5  Pseudo-ops -- EQU
  789.  
  790.              The EQU pseudo-op is used to assign a specific value to a 
  791.         label, thus the label on this line is REQUIRED.  Once the value 
  792.         is assigned, it cannot be reassigned by writing the label in 
  793.         column 1, by another EQU statement, or by a SET statement.  Thus, 
  794.         for example, the following statement assigns the value 2 to the 
  795.         label TWO:
  796.  
  797.              TWO       EQU       1 + 1
  798.  
  799.              The expression in the argument field must contain no forward 
  800.  
  801.  
  802.                                        12
  803.  
  804.  
  805.  
  806.         references.
  807.  
  808.  
  809.         4.6  Pseudo-ops -- IF, ELSE, ENDI
  810.  
  811.              These three pseudo-ops allow the assembler to choose whether 
  812.         or not to assemble certain blocks of code based on the result of 
  813.         an expression.  Code that is not assembled is passed through to 
  814.         the listing but otherwise ignored by the assembler.  The IF 
  815.         pseudo-op signals the beginning of a conditionally assembled 
  816.         block.  It requires one argument that may contain no forward 
  817.         references.  If the value of the argument is non-zero, the block 
  818.         is assembled.  Otherwise, the block is ignored.  The ENDI pseudo-
  819.         op signals the end of the conditionally assembled block.  For 
  820.         example:
  821.  
  822.                        IF   EXPRESSION     ;This whole thing generates
  823.                        DB   01H, 02H, 03H  ;  no code whatsoever if
  824.                        ENDI                ;  EXPRESSION is zero.
  825.  
  826.         The ELSE pseudo-op allows the assembly of either one of two 
  827.         blocks, but not both.  The following two sequences are 
  828.         equivalent:
  829.  
  830.                        IF   EXPRESSION
  831.                        ... some stuff ...
  832.                        ELSE
  833.                        ... some more stuff ...
  834.                        ENDI
  835.  
  836.              TEMP_LAB  SET  EXPRESSION
  837.                        IF   TEMP_LAB NE 0
  838.                        ... some stuff ...
  839.                        ENDI
  840.                        IF   TEMP_LAB EQ 0
  841.                        ... some more stuff ...
  842.                        ENDI
  843.  
  844.              The pseudo-ops in this group do NOT permit labels to exist 
  845.         on the same line as the status of the label (ignored or not) 
  846.         would be ambiguous.
  847.  
  848.              All IF statements (even those in ignored conditionally 
  849.         assembled blocks) must have corresponding ENDI statements and all 
  850.         ELSE and ENDI statements must have a corresponding IF statement.
  851.  
  852.              IF blocks can be nested up to 16 levels deep before the 
  853.         assembler dies of a fatal error.  This should be adequate for any 
  854.         conceivable job, but if you need more, change the constant 
  855.         IFDEPTH in file A26.H and recompile the assembler.
  856.  
  857.  
  858.         4.7  Pseudo-ops -- INCL
  859.  
  860.              The INCL pseudo-op is used to splice the contents of another 
  861.  
  862.  
  863.                                        13
  864.  
  865.  
  866.  
  867.         file into the current file at assembly time.  The name of the 
  868.         file to be INCLuded is specified as a normal string constant, so 
  869.         the following line would splice the contents of file "const.def" 
  870.         into the source code stream:
  871.  
  872.                        INCL      "const.def"
  873.  
  874.              INCLuded files may, in turn, INCLude other files until four 
  875.         files are open simultaneously.  This limit should be enough for 
  876.         any conceivable job, but if you need more, change the constant 
  877.         FILES in file A26.H and recompile the assembler.
  878.  
  879.  
  880.         4.8  Pseudo-ops -- ORG
  881.  
  882.              The ORG pseudo-op is used to set the assembly program 
  883.         counter to a particular value.  The expression that defines this 
  884.         value may contain no forward references.  The default initial 
  885.         value of the assembly program counter is 0000H.  The following 
  886.         statement would change the assembly program counter to 0F000H:
  887.  
  888.                        ORG       0F000H
  889.  
  890.              If a label is present on the same line as an ORG statement, 
  891.         it is assigned the new value of the assembly program counter.
  892.  
  893.  
  894.         4.9  Pseudo-ops -- RES
  895.  
  896.              The RES pseudo-op is used to reserve a block of storage for 
  897.         program variables, or whatever.  This storage is not initialized 
  898.         in any way, so its value at run time will usually be random.  The 
  899.         argument expression (which may contain no forward references) is 
  900.         added to the assembly program counter.  The following statement 
  901.         would reserve 10 bytes of storage called "STORAGE":
  902.  
  903.              STORAGE   RES       10
  904.  
  905.  
  906.         4.10 Pseudo-ops -- SET
  907.  
  908.              The SET pseudo-op functions like the EQU pseudo-op except 
  909.         that the SET statement can reassign the value of a label that has 
  910.         already been assigned by another SET statement.  Like the EQU 
  911.         statement, the argument expression may contain no forward 
  912.         references.  A label defined by a SET statement cannot be 
  913.         redefined by writing it in column 1 or with an EQU statement.  
  914.         The following series of statements would set the value of label 
  915.         "COUNT" to 1, 2, then 3:
  916.  
  917.              COUNT     SET       1
  918.              COUNT     SET       2
  919.              COUNT     SET       3
  920.  
  921.  
  922.  
  923.  
  924.                                        14
  925.  
  926.  
  927.  
  928.         4.11 Pseudo-ops -- TITL
  929.  
  930.              The TITL pseudo-op sets the running title for the listing.  
  931.         The argument field is required and must be a string constant, 
  932.         though the null string ("") is legal.  This title is printed 
  933.         after every page ejection in the listing, therefore, if page 
  934.         ejections have not been forced by the PAGE pseudo-op, the title 
  935.         will never be printed.  The following statement would print the 
  936.         title "Random Bug Generator -- Ver 3.14159" at the top of every 
  937.         page of the listing:
  938.  
  939.                        TITL      "Random Bug Generator -- Ver 3.14159"
  940.  
  941.  
  942.         5.0  Assembly Errors
  943.  
  944.              When a source line contains an illegal construct, the line 
  945.         is flagged in the listing with a single-letter code describing 
  946.         the error.  The meaning of each code is listed below.  In 
  947.         addition, a count of the number of lines with errors is kept and 
  948.         printed on the C "stderr" device (by default, the console) after 
  949.         the END statement is processed.  If more than one error occurs in 
  950.         a given line, only the first is reported.  For example, the 
  951.         illegal label "=$#*'(" would generate the following listing line:
  952.  
  953.              L  0000   FF 00 00      =$#*'(     LDA       R0
  954.  
  955.  
  956.         5.1  Error * -- Illegal or Missing Statement
  957.  
  958.              This error occurs when either:
  959.  
  960.              1)   the assembler reaches the end of the source file 
  961.                   without seeing an END statement, or
  962.  
  963.              2)   an END statement is encountered in an INCLude file.
  964.  
  965.              If you are "sure" that the END statement is present when the 
  966.         assembler thinks that it is missing, it probably is in the 
  967.         ignored section of an IF block.  If the END statement is missing, 
  968.         supply it.  If the END statement is in an INCLude file, delete 
  969.         it.
  970.  
  971.  
  972.         5.2  Error ( -- Parenthesis Imbalance
  973.  
  974.              For every left parenthesis, there must be a right paren-
  975.         thesis.  Count them.
  976.  
  977.  
  978.         5.3  Error " -- Missing Quotation Mark
  979.  
  980.              Strings have to begin and end with either " or '.  Remember 
  981.         that " only matches " while ' only matches '.
  982.  
  983.  
  984.  
  985.                                        15
  986.  
  987.  
  988.  
  989.  
  990.         5.4  Error A -- Address Can't Be Reached
  991.  
  992.              This error occurs under the following conditions:
  993.  
  994.              1)   an absolute branch address is > 07FFFH, or
  995.  
  996.              2)   an absolute operand address references a different 8K 
  997.                   byte page than the instruction is on, or
  998.  
  999.              3)   a zero-relative address references a location outside 
  1000.                   the ranges 0000H - 003FH and 01FC0H - 1FFFH, or
  1001.  
  1002.              4)   a relative address references a location outside the 
  1003.                   range -62 to +65 bytes from the beginning of the 
  1004.                   instruction or on a different 8K byte page than the 
  1005.                   instruction.
  1006.  
  1007.  
  1008.         5.5  Error C -- Illegal Condition Code
  1009.  
  1010.              This error occurs if a condition code outside the range 0 - 
  1011.         3 is specified or if a condition code of 3 is specified for the 
  1012.         instructions BCFA, BCFR, BSFA, and BSFR.
  1013.  
  1014.  
  1015.         5.6  Error D -- Illegal Digit
  1016.  
  1017.              This error occurs if a digit greater than or equal to the 
  1018.         base of a numeric constant is found.  For example, a 2 in a 
  1019.         binary number would cause a D error.  Especially, watch for 8 or 
  1020.         9 in an octal number.
  1021.  
  1022.  
  1023.         5.7  Error E -- Illegal Expression
  1024.  
  1025.              This error occurs because of:
  1026.  
  1027.              1)   a missing expression where one is required
  1028.  
  1029.              2)   a unary operator used as a binary operator or vice-
  1030.                   versa
  1031.  
  1032.              3)   a missing binary operator
  1033.  
  1034.              4)   a SHL or SHR count that is not 0 thru 15
  1035.  
  1036.  
  1037.         5.8  Error F -- Control Flow Error
  1038.  
  1039.              This error occurs if the flow of control is going to cross 
  1040.         the boundary between two 8K byte pages.  The 2650 CPU's program 
  1041.         counter only increments in its low 13 bits, so such an 
  1042.         instruction cannot be fetched by the machine.
  1043.  
  1044.  
  1045.  
  1046.                                        16
  1047.  
  1048.  
  1049.  
  1050.  
  1051.         5.9  Error I -- IF-ENDI Imbalance
  1052.  
  1053.              For every IF there must be a corresponding ENDI.  If this 
  1054.         error occurs on an ELSE or ENDI statement, the corresponding IF 
  1055.         is missing.  If this error occurs on an END statement, one or 
  1056.         more ENDI statements are missing.
  1057.  
  1058.  
  1059.         5.10 Error L -- Illegal Label
  1060.  
  1061.              This error occurs because of:
  1062.  
  1063.              1)   a non-alphabetic in column 1
  1064.  
  1065.              2)   a reserved word used as a label
  1066.  
  1067.              3)   a missing label on an EQU or SET statement
  1068.  
  1069.              4)   a label on an IF, ELSE, or ENDI statement
  1070.  
  1071.  
  1072.         5.11 Error M -- Multiply Defined Label
  1073.  
  1074.              This error occurs because of:
  1075.  
  1076.              1)   a label defined in column 1 or with the EQU statement 
  1077.                   being redefined
  1078.  
  1079.              2)   a label defined by a SET statement being redefined 
  1080.                   either in column 1 or with the EQU statement
  1081.  
  1082.              3)   the value of the label changing between assembly passes
  1083.  
  1084.  
  1085.         5.12 Error O -- Illegal Opcode
  1086.  
  1087.              The opcode field of a source line may contain only a valid 
  1088.         machine opcode, a valid pseudo-op, or nothing at all.  Anything 
  1089.         else causes this error.
  1090.  
  1091.  
  1092.         5.13 Error P -- Phasing Error
  1093.  
  1094.              This error occurs because of:
  1095.  
  1096.              1)   a forward reference in a DS, EQU, ORG, or SET statement
  1097.  
  1098.              2)   a label disappearing between assembly passes
  1099.  
  1100.  
  1101.         5.14 Error R -- Illegal Register
  1102.  
  1103.              This error occurs under the following conditions:
  1104.  
  1105.  
  1106.  
  1107.                                        17
  1108.  
  1109.  
  1110.  
  1111.              1)   a register other than 0 - 3 is specified, or
  1112.  
  1113.              2)   R0 was specified in the instruction ANDZ or STRZ.
  1114.  
  1115.  
  1116.         5.15 Error S -- Illegal Syntax
  1117.  
  1118.              This error means that an argument field is scrambled.  Sort 
  1119.         the mess out and reassemble.
  1120.  
  1121.  
  1122.         5.13 Error T -- Too Many Arguments
  1123.  
  1124.              This error occurs if there are more items (expressions, 
  1125.         register designators, etc.) in the argument field than the opcode 
  1126.         or pseudo-op requires.  The assembler ignores the extra items but 
  1127.         issues this error in case something is really mangled.
  1128.  
  1129.  
  1130.         5.14 Error U -- Undefined Label
  1131.  
  1132.              This error occurs if a label is referenced in an expression 
  1133.         but not defined anywhere in the source program.  If you are 
  1134.         "sure" you have defined the label, note that upper and lower case 
  1135.         letters in labels are different.  Defining "LABEL" does not 
  1136.         define "Label."
  1137.  
  1138.  
  1139.         5.15 Error V -- Illegal Value
  1140.  
  1141.              This error occurs because:
  1142.  
  1143.              1)   an immediate value is not -128 thru 255, or
  1144.  
  1145.              2)   a DATA argument is not -128 thru 255, or
  1146.  
  1147.              3)   an I/O port number is not 0 thru 255, or
  1148.  
  1149.              4)   a bit mask is not 0 thru 255, or
  1150.  
  1151.              5)   an ACON argument is not 0 thru 7FFFH, or
  1152.  
  1153.              6)   an EJE argument is 1 or 2, or
  1154.  
  1155.              7)   an INCL argument refers to a file that does not exist.
  1156.  
  1157.  
  1158.         6.0  Warning Messages
  1159.  
  1160.              Some errors that occur during the parsing of the cross-
  1161.         assembler command line are non-fatal.  The cross-assembler flags 
  1162.         these with a message on the C "stdout" device (by default, the 
  1163.         console) beginning with the word "Warning."  The messages are 
  1164.         listed below:
  1165.  
  1166.  
  1167.  
  1168.                                        18
  1169.  
  1170.  
  1171.  
  1172.  
  1173.         6.1  Warning -- Illegal Option Ignored
  1174.  
  1175.              The only options that the cross-assembler knows are -l and  
  1176.         -o.  Any other command line argument beginning with - will draw 
  1177.         this error.
  1178.  
  1179.  
  1180.         6.2  Warning -- -l Option Ignored -- No File Name
  1181.         6.3  Warning -- -o Option Ignored -- No File Name
  1182.  
  1183.              The -l and -o options require a file name to tell the 
  1184.         assembler where to put the listing file or object file.  If this 
  1185.         file name is missing, the option is ignored.
  1186.  
  1187.  
  1188.         6.4  Warning -- Extra Source File Ignored
  1189.  
  1190.              The cross-assembler will only assemble one file at a time, 
  1191.         so source file names after the first are ignored.  To assemble a 
  1192.         second file, invoke the assembler again.  Note that under CP/M-
  1193.         80, the old trick of reexecuting a core image will NOT work as 
  1194.         the initialized data areas are not reinitialized prior to the 
  1195.         second run.
  1196.  
  1197.  
  1198.         6.5  Warning -- Extra Listing File Ignored
  1199.         6.6  Warning -- Extra Object File Ignored
  1200.  
  1201.              The cross-assembler will only generate one listing and 
  1202.         object file per assembly run, so -l and -o options after the 
  1203.         first are ignored.
  1204.  
  1205.  
  1206.         7.0  Fatal Error Messages
  1207.  
  1208.              Several errors that occur during the parsing of the cross-
  1209.         assembler command line or during the assembly run are fatal.  The 
  1210.         cross-assembler flags these with a message on the C "stdout" 
  1211.         device (by default, the console) beginning with the words "Fatal 
  1212.         Error."  The messages are explained below:
  1213.  
  1214.  
  1215.         7.1  Fatal Error -- No Source File Specified
  1216.  
  1217.              This one is self-explanatory.  The assembler does not know 
  1218.         what to assemble.
  1219.  
  1220.  
  1221.         7.2  Fatal Error -- Source File Did Not Open
  1222.  
  1223.              The assembler could not open the source file.  The most 
  1224.         likely cause is that the source file as specified on the command 
  1225.         line does not exist.  On larger systems, there could also be 
  1226.         priviledge violations.  Rarely, a read error in the disk 
  1227.  
  1228.  
  1229.                                        19
  1230.  
  1231.  
  1232.  
  1233.         directory could cause this error.
  1234.  
  1235.  
  1236.         7.3  Fatal Error -- Listing File Did Not Open
  1237.         7.4  Fatal Error -- Object File Did Not Open
  1238.  
  1239.              This error indicates either a defective listing or object 
  1240.         file name or a full disk directory.  Correct the file name or 
  1241.         make more room on the disk.
  1242.  
  1243.  
  1244.         7.5  Fatal Error -- Error Reading Source File
  1245.  
  1246.              This error generally indicates a read error in the disk data 
  1247.         space.  Use your backup copy of the source file (You do have one, 
  1248.         don't you?) to recreate the mangled file and reassemble.
  1249.  
  1250.  
  1251.         7.6  Fatal Error -- Disk or Directory Full
  1252.  
  1253.              This one is self-explanatory.  Some more space must be found 
  1254.         either by deleting files or by using a disk with more room on it.
  1255.  
  1256.  
  1257.         7.7  Fatal Error -- File Stack Overflow
  1258.  
  1259.              This error occurs if you exceed the INCLude file limit of 
  1260.         four files open simultaneously.  This limit can be increased by 
  1261.         increasing the constant FILES in file A26.H and recompiling the 
  1262.         cross-assembler.
  1263.  
  1264.  
  1265.         7.8  Fatal Error -- If Stack Overflow
  1266.  
  1267.              This error occurs if you exceed the nesting limit of 16 IF 
  1268.         blocks.  This limit can be increased by increasing the constant 
  1269.         IFDEPTH in file A26.H and recompiling the cross-assembler.
  1270.  
  1271.  
  1272.         7.9  Fatal Error -- Too Many Symbols
  1273.  
  1274.              Congratulations!  You have run out of memory.  The space for 
  1275.         the cross-assembler's symbol table is allocated at run-time using 
  1276.         the C library function calloc(), so the cross-assembler will use 
  1277.         all available memory.  The only solutions to this problem are to 
  1278.         lessen the number of labels in the source program or to add more 
  1279.         memory.
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.                                        20
  1291.