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

  1. /*
  2.     HEADER:        CUG149;
  3.     TITLE:        6801 Cross-Assembler (Portable);
  4.     FILENAME:    A68.DOC;
  5.     VERSION:    3.5;
  6.     DATE:        08/27/1988;
  7.  
  8.     DESCRIPTION:    "This program lets you use your computer to assemble
  9.             code for the Motorola 6800, 6801, 6802, 6803, 6808,
  10.             and 68701 microprocessors.  The program is written in
  11.             portable C rather than BDS C.  All assembler features
  12.             are supported except relocation, linkage, and macros.";
  13.  
  14.     KEYWORDS:    Software Development, Assemblers, Cross-Assemblers,
  15.             Motorola, MC6800, MC6801;
  16.  
  17.     SEE-ALSO:    CUG113, 6800 Cross-Assembler;
  18.  
  19.     SYSTEM:        CP/M-80, CP/M-86, HP-UX, MSDOS, PCDOS, QNIX;
  20.     COMPILERS:    Aztec C86, Aztec CII, CI-C86, Eco-C, Eco-C88, HP-UX,
  21.             Lattice C, Microsoft C,    QNIX C;
  22.  
  23.     WARNINGS:    "This program has compiled successfully on 2 UNIX
  24.             compilers, 5 MSDOS compilers, and 2 CP/M compilers.
  25.             A port to BDS C would be extremely difficult, but see
  26.             volume CUG113.  A port to Toolworks C is untried."
  27.  
  28.     AUTHORS:    William C. Colley III;
  29. */
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.                       6800/6801 Cross-Assembler (Portable)
  46.  
  47.  
  48.                                    Version 3.5
  49.  
  50.  
  51.                     Copyright (c) 1985 William C. Colley, III
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.                             The manual such as it is.
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.         Legal Note:    This package may be used for any commercial or 
  71.                        non-commercial purpose.  It may be copied and 
  72.                        distributed freely provided that any fee charged 
  73.                        by the distributor of the copy does not exceed the 
  74.                        sum of:  1) the cost of the media the copy is 
  75.                        written on,  2) any required costs of shipping the 
  76.                        copy, and  3) a nominal handling fee.  Any other 
  77.                        distribution requires the written permission of 
  78.                        the author.  Also, the author's copyright notices 
  79.                        shall not be removed from the program source, the 
  80.                        program object, or the program documentation.
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.                 Note to Users of Previous Versions of the Package
  96.  
  97.              This version of the 6800/6801 Cross-Assembler package is a 
  98.         total rewrite of the old BDS C version.  During the recoding, a 
  99.         few new "bells and whistles" found their way into the program.  
  100.         They are:
  101.  
  102.              1)   Labels can now be as long as an entire line, and all 
  103.                   characters are significant.  In older versions, only 8 
  104.                   characters were significant.
  105.  
  106.              2)   Listing control has been added to the output routine.  
  107.                   The listing can be broken up into pages and a running 
  108.                   header can be added to the top of each page.  See the 
  109.                   TITL and PAGE pseudo-ops for details.
  110.  
  111.              3)   Default extensions for the source, list, and object 
  112.                   (hex) files are no longer supplied.
  113.  
  114.              4)   Include files are now supported and may be nested.
  115.  
  116.              Alas, as the sage says, "There ain't no such thing as a free 
  117.         lunch."  Massive internal changes had to be made to divorce the 
  118.         program from the CP/M-80 environment.  These changes, the fact 
  119.         that full-featured, 8-bit C compilers generate less efficient 
  120.         code than BDS C, and the fact that I have leaned on the over-
  121.         powered, slow library function printf() heavily have caused the 
  122.         package to run about a factor of 4 slower than the older 
  123.         versions.  The package also takes 3-6K more disk space to store 
  124.         than it used to take.
  125.  
  126.              On the plus side, however, the code is written in "portable" 
  127.         C, so all of the UNIX users, and the new crop of IBM-PC users 
  128.         should be able to compile and run the package almost without 
  129.         modification.  The internal structure of the package is cleaner 
  130.         than ever, so it should be very easy to hack on and turn into 
  131.         cross-assemblers for other 8-bit processors.  Finally, the source 
  132.         code has shrivelled almost to nothing since many tasks have been 
  133.         off-loaded onto standard library functions, so the need to 
  134.         "squeeze" the source code is gone.
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.                                 Table of Contents
  157.  
  158.         1.0  How to Use the Cross-Assembler Package ..................  3
  159.         2.0  Format of Cross-Assembler Source Lines ..................  4
  160.              2.1  Labels .............................................  5
  161.              2.2  Numeric Constants ..................................  5
  162.              2.3  String Constants ...................................  6
  163.              2.4  Expressions ........................................  6
  164.         3.0  Machine Opcodes .........................................  7
  165.              3.1  Opcodes -- No Arguments ............................  8
  166.              3.2  Opcodes -- One Register Argument ...................  8
  167.              3.3  Opcodes -- One Memory Argument .....................  8
  168.              3.4  Opcodes -- One Register or Memory Argument .........  8
  169.              3.5  Opcodes -- One Memory or Immediate Argument ........  8
  170.              3.6  Opcodes -- Two Arguments ...........................  9
  171.              3.7  Opcodes -- Relative Branches .......................  9
  172.              3.8  Opcodes -- Direct Addressing .......................  9
  173.         4.0  Pseudo Opcodes .......................................... 10
  174.              4.1  Pseudo-ops -- CPU .................................. 10
  175.              4.2  Pseudo-ops -- END .................................. 10
  176.              4.3  Pseudo-ops -- EQU .................................. 10
  177.              4.4  Pseudo-ops -- FCB .................................. 11
  178.              4.5  Pseudo-ops -- FCC .................................. 11
  179.              4.6  Pseudo-ops -- FDB .................................. 11
  180.              4.7  Pseudo-ops -- IF, ELSE, ENDI ....................... 11
  181.              4.8  Pseudo-ops -- INCL ................................. 12
  182.              4.9  Pseudo-ops -- ORG .................................. 13
  183.              4.10 Pseudo-ops -- PAGE ................................. 13
  184.              4.11 Pseudo-ops -- RMB .................................. 13
  185.              4.12 Pseudo-ops -- SET .................................. 13
  186.              4.13 Pseudo-ops -- TITL ................................. 14
  187.         5.0  Assembly Errors ......................................... 14
  188.              5.1  Error * -- Illegal or Missing Statement ............ 14
  189.              5.2  Error ( -- Parenthesis Imbalance ................... 15
  190.              5.3  Error " -- Missing Quotation Mark .................. 15
  191.              5.4  Error A -- Illegal Addressing Mode ................. 15
  192.              5.5  Error B -- Branch Target Too Distant ............... 15
  193.              5.6  Error D -- Illegal Digit ........................... 15
  194.              5.7  Error E -- Illegal Expression ...................... 15
  195.              5.8  Error I -- IF-ENDI Imbalance ....................... 16
  196.              5.9  Error L -- Illegal Label ........................... 16
  197.              5.10 Error M -- Multiply Defined Label .................. 16
  198.              5.11 Error O -- Illegal Opcode .......................... 16
  199.              5.12 Error P -- Phasing Error ........................... 16
  200.              5.13 Error R -- Illegal Register ........................ 17
  201.              5.14 Error S -- Illegal Syntax .......................... 17
  202.              5.15 Error T -- Too Many Arguments ...................... 17
  203.              5.16 Error U -- Undefined Label ......................... 17
  204.              5.17 Error V -- Illegal Value ........................... 17
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.                                         1
  214.  
  215.  
  216.  
  217.         6.0  Warning Messages ........................................ 17
  218.              6.1  Warning -- Illegal Option Ignored .................. 18
  219.              6.2  Warning -- -l Option Ignored -- No File Name ....... 18
  220.              6.3  Warning -- -o Option Ignored -- No File Name ....... 18
  221.              6.4  Warning -- Extra Source File Ignored ............... 18
  222.              6.5  Warning -- Extra Listing File Ignored .............. 18
  223.              6.6  Warning -- Extra Object File Ignored ............... 18
  224.         7.0  Fatal Error Messages .................................... 18
  225.              7.1  Fatal Error -- No Source File Specified ............ 18
  226.              7.2  Fatal Error -- Source File Did Not Open ............ 18
  227.              7.3  Fatal Error -- Listing File Did Not Open ........... 19
  228.              7.4  Fatal Error -- Object File Did Not Open ............ 19
  229.              7.5  Fatal Error -- Error Reading Source File ........... 19
  230.              7.6  Fatal Error -- Disk or Directory Full .............. 19
  231.              7.7  Fatal Error -- File Stack Overflow ................. 19
  232.              7.8  Fatal Error -- If Stack Overflow ................... 19
  233.              7.9  Fatal Error -- Too Many Symbols .................... 19
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.                                         2
  275.  
  276.  
  277.  
  278.         1.0  How to Use the Cross-Assembler Package
  279.  
  280.              First, the question, "What does a cross-assembler do?" needs 
  281.         to be addressed as there is considerable confusion on this point.  
  282.         A cross-assembler is just like any other assembler except that it 
  283.         runs on some CPU other than the one for which it assembles code.  
  284.         For example, this package assembles 6801 source code into 6801 
  285.         object code, but it runs on an 8080, a Z-80, an 8088, or whatever 
  286.         other CPU you happen to have a C compiler for.  The reason that 
  287.         cross-assemblers are useful is that you probably already have a 
  288.         CPU with memory, disk drives, a text editor, an operating system, 
  289.         and all sorts of hard-to-build or expensive facilities on hand.  
  290.         A cross-assembler allows you to use these facilites to develop 
  291.         code for a 6801.
  292.  
  293.         This program requires one input file (your 6801 source code) and 
  294.         zero to two output files (the listing and the object).  The input 
  295.         file MUST be specified, or the assembler will bomb on a fatal 
  296.         error.  The listing and object files are optional.  If no listing 
  297.         file is specified, no listing is generated, and if no object file 
  298.         is specified, no object is generated.  If the object file is 
  299.         specified, the object is written to this file in "Intel 
  300.         hexadecimal" format.
  301.  
  302.              The command line for the cross-assembler looks like this:
  303.  
  304.                   A68 source_file { -l list_file } { -o object_file }
  305.  
  306.         where the { } indicates that the specified item is optional.
  307.  
  308.              Some examples are in order:
  309.  
  310.              a68 test68.asm                          source:   test68.asm
  311.                                                      listing:  none
  312.                                                      object:   none
  313.  
  314.              a68 test68.asm -l test68.prn            source:   test68.asm
  315.                                                      listing:  test68.prn
  316.                                                      object:   none
  317.  
  318.              a68 test68.asm -o test68.hex            source:   test68.asm
  319.                                                      listing:  none
  320.                                                      object:   test68.hex
  321.  
  322.              a68 test68.asm -l test68.prn -o test68.hex
  323.                                                      source:   test68.asm
  324.                                                      listing:  test68.prn
  325.                                                      object:   test68.hex
  326.  
  327.              The order in which the source, listing, and object files are 
  328.         specified does not matter.  Note that no default file name exten-
  329.         sions are supplied by the assembler as this gives rise to porta-
  330.         bility problems.
  331.  
  332.  
  333.  
  334.  
  335.                                         3
  336.  
  337.  
  338.  
  339.         2.0  Format of Cross-Assembler Source Lines
  340.  
  341.              The source file that the cross-assembler processes into a 
  342.         listing and an object is an ASCII text file that you can prepare 
  343.         with whatever editor you have at hand.  The most-significant 
  344.         (parity) bit of each character is cleared as the character is 
  345.         read from disk by the cross-assembler, so editors that set this 
  346.         bit (such as WordStar's document mode) should not bother this 
  347.         program.  All printing characters, the ASCII TAB character ($09), 
  348.         and newline character(s) are processed by the assembler.  All 
  349.         other characters are passed through to the listing file, but are 
  350.         otherwise ignored.
  351.  
  352.              The source file is divided into lines by newline char-
  353.         acter(s).  The internal buffers of the cross-assembler will 
  354.         accommodate lines of up to 255 characters which should be more 
  355.         than ample for almost any job.  If you must use longer lines, 
  356.         change the constant MAXLINE in file A68.H and recompile the 
  357.         cross-assembler.  Otherwise, you will overflow the buffers, and 
  358.         the program will mysteriously crash.
  359.  
  360.              Each source line is made up of three fields:  the label 
  361.         field, the opcode field, and the argument field.  The label field 
  362.         is optional, but if it is present, it must begin in column 1.  
  363.         The opcode field is optional, but if it is present, it must not 
  364.         begin in column 1.  If both a label and an opcode are present, 
  365.         one or more spaces and/or TAB characters must separate the two.  
  366.         If the opcode requires arguments, they are placed in the argument 
  367.         field which is separated from the opcode field by one or more 
  368.         spaces and/or TAB characters.  Finally, an optional comment can 
  369.         be added to the end of the line.  This comment must begin with a 
  370.         semicolon which signals the assembler to pass the rest of the 
  371.         line to the listing and otherwise ignore it.  Thus, the source 
  372.         line looks like this:
  373.  
  374.              {label}{ opcode{ arguments}}{;commentary}
  375.  
  376.         where the { } indicates that the specified item is optional.
  377.  
  378.              Some examples are in order:
  379.  
  380.           column 1
  381.              |
  382.              v
  383.              GRONK   LDAA  X, OFFSET       ; This line has everything.
  384.                      STAA  MAILBOX         ; This line has no label.
  385.              BEEP                          ; This line has no opcode.
  386.              ; This line has no label and no opcode.
  387.  
  388.              ; The previous line has nothing at all.
  389.                      END                   ; This line has no argument.
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.                                         4
  397.  
  398.  
  399.  
  400.         2.1  Labels
  401.  
  402.              A label is any sequence of alphabetic or numeric characters 
  403.         starting with an alphabetic.  The legal alphabetics are:
  404.  
  405.                     ! & , . : ? [ \ ] ^ _  ` { | }  ~  A-Z  a-z
  406.  
  407.         The numeric characters are the digits 0-9.  Note that "A" is not 
  408.         the same as "a" in a label.  This can explain mysterious U 
  409.         (undefined label) errors occurring when a label appears to be 
  410.         defined.
  411.  
  412.              A label is permitted on any line except a line where the 
  413.         opcode is IF, ELSE, or ENDIF.  The label is assigned the value of 
  414.         the assembly program counter before any of the rest of the line 
  415.         is processed except when the opcode is EQU, ORG, or SET.
  416.  
  417.              Labels can have the same name as opcodes, but they cannot
  418.         have the same name as operators or registers.  The reserved 
  419.         (operator and register) names are:
  420.  
  421.              A         B         AND       EQ        GE        GT
  422.              HIGH      LE        LT        LOW       MOD       NE
  423.              NOT       OR        SHL       SHR       X         XOR
  424.  
  425.              If a label is used in an expression before it is assigned a 
  426.         value, the label is said to be "forward-referenced."  For 
  427.         example:
  428.  
  429.              L1   EQU  L2 + 1   ; L2 is forward-referenced here.
  430.              L2
  431.              L3   EQU  L2 + 1   ; L2 is not forward-referenced here.
  432.  
  433.  
  434.         2.2  Numeric Constants
  435.  
  436.              Numeric constants can be formed in two ways:  the Intel 
  437.         convention or the Motorola convention.  The cross-assembler 
  438.         supports both.
  439.  
  440.              An Intel-type numeric constant starts with a numeric 
  441.         character (0-9), continues with zero or more digits (0-9, A-F), 
  442.         and ends with an optional base designator.  The base designators 
  443.         are H for hexadecimal, none or D for decimal, O or Q for octal, 
  444.         and B for binary.  The hex digits a-f are converted to upper case 
  445.         by the assembler.  Note that an Intel-type numeric constant 
  446.         cannot begin with A-F as it would be indistinguishable from a 
  447.         label.  Thus, all of the following evaluate to 255 (decimal):
  448.  
  449.                    0ffH   255   255D   377O   377Q   11111111B
  450.  
  451.              A Motorola-type numeric constant starts with a base 
  452.         designator and continues with a string of one or more digits.  
  453.         The base designators are $ for hexadecimal, none for decimal, @ 
  454.         for octal, and % for binary.  As with Intel-type numeric 
  455.  
  456.  
  457.                                         5
  458.  
  459.  
  460.  
  461.         constants, a-f are converted to upper case by the assembler.  
  462.         Thus, all of the following evaluate to 255 (decimal):
  463.  
  464.                           $ff   255   @377   %11111111
  465.  
  466.              If a numeric constant has a value that is too large to fit 
  467.         into a 16-bit word, it will be truncated on the left to make it 
  468.         fit.  Thus, for example, $123456 is truncated to $3456.
  469.  
  470.  
  471.         2.3  String Constants
  472.  
  473.              A string constant is zero or more characters enclosed in 
  474.         either single quotes (' ') or double quotes (" ").  Single quotes 
  475.         only match single quotes, and double quotes only match double 
  476.         quotes, so if you want to put a single quote in a string, you can 
  477.         do it like this:  "'".  In all contexts except the FCC statement, 
  478.         the first character or two of the string constant are all that 
  479.         are used.  The rest is ignored.  Noting that the ASCII codes for 
  480.         "A" and "B" are $41 and $42, respectively, will explain the 
  481.         following examples:
  482.  
  483.                   "" and ''           evaluate to $0000
  484.                   "A" and 'A'         evaluate to $0041
  485.                   "AB"                evaluates to $4142
  486.  
  487.         Note that the null string "" is legal and evaluates to $0000.
  488.  
  489.  
  490.         2.4  Expressions
  491.  
  492.              An expression is made up of labels, numeric constants, and 
  493.         string constants glued together with arithmetic operators, 
  494.         logical operators, and parentheses in the usual way that 
  495.         algebraic expressions are made.  Operators have the following 
  496.         fairly natural order of precedence:
  497.  
  498.              Highest        anything in parentheses
  499.                             unary +, unary -
  500.                             *, /, MOD, SHL, SHR
  501.                             binary +, binary -
  502.                             LT, LE, EQ, GE, GT, NE
  503.                             NOT
  504.                             AND
  505.                             OR, XOR
  506.              Lowest         HIGH, LOW
  507.  
  508.              A few notes about the various operators are in order:
  509.  
  510.              1)   The remainder operator MOD yields the remainder from 
  511.                   dividing its left operand by its right operand.
  512.  
  513.              2)   The shifting operators SHL and SHR shift their left 
  514.                   operand to the left or right the number of bits 
  515.                   specified by their right operand.
  516.  
  517.  
  518.                                         6
  519.  
  520.  
  521.  
  522.  
  523.              3)   The relational operators LT, LE, EQ, GE, GT, and NE can 
  524.                   also be written as <, <= or =<, =, >= or =>, and <> or 
  525.                   ><, respectively.  They evaluate to $FFFF if the 
  526.                   statement is true, 0 otherwise.
  527.  
  528.              4)   The logical opeators NOT, AND, OR, and XOR do bitwise 
  529.                   operations on their operand(s).
  530.  
  531.              5)   HIGH and LOW extract the high or low byte, of an 
  532.                   expression.
  533.  
  534.              6)   The special symbol * can be used in place of a label or 
  535.                   constant to represent the value of the program counter 
  536.                   before any of the current line has been processed.
  537.  
  538.              Some examples are in order at this point:
  539.  
  540.              2 + 3 * 4                          evaluates to 14
  541.              (2 + 3) * 4                        evaluates to 20
  542.              NOT %11110000 XOR %00001010        evaluates to %00000101
  543.              HIGH $1234 SHL 1                   evaluates to $0024
  544.              @001 EQ 0                          evaluates to 0
  545.              @001 = 2 SHR 1                     evaluates to $FFFF
  546.  
  547.              All arithmetic is unsigned with overflow from the 16-bit 
  548.         word ignored.  Thus:
  549.  
  550.              32768 * 2                          evaluates to 0
  551.  
  552.  
  553.         3.0  Machine Opcodes
  554.  
  555.              The opcodes of the 6800 and 6801 processors are divided into 
  556.         groups below by the type of arguments required in the argument 
  557.         field of the source line.  Opcodes that are peculiar to the 6801 
  558.         are marked with an asterisk.  A few notes on the source line 
  559.         syntax are in order at this point:
  560.  
  561.              1)   Arguments can be supplied in any order.  Thus, for 
  562.                   example, the following two source lines are equivalent:
  563.  
  564.                        LABEL     ADD A     X, 0      ;Mumble.
  565.                        LABEL     ADD A     0, X      ;Mumble.
  566.  
  567.              2)   Multiple arguments may be separated from one another by 
  568.                   spaces, tabs, or commas except that an expression must 
  569.                   be separated from a following argument by a comma.
  570.  
  571.              3)   In the indexed addressing mode, the expression giving 
  572.                   the offset may be omitted.  The default offset is 0.
  573.  
  574.              4)   The register designators A and B may be appended to the 
  575.                   opcode itself.  Thus, for example, the following two 
  576.                   source lines are equivalent:
  577.  
  578.  
  579.                                         7
  580.  
  581.  
  582.  
  583.  
  584.                        LABEL     CLRA                ;Mumble.
  585.                        LABEL     CLR       A         ;Mumble.
  586.  
  587.  
  588.  
  589.         3.1  Opcodes -- No Arguments
  590.  
  591.              The following opcodes allow no arguments at all in their 
  592.         argument fields:
  593.  
  594.              ABA       ABX *     ASLD *    CBA       CLC       CLI
  595.              CLV       DAA       DES       DEX       INS       INX
  596.              LSLD *    LSRD *    MUL *     NOP       PSHX *    PULX *
  597.              RTI       RTS       SBA       SEC       SEI       SEV
  598.              SWI       TAB       TAP       TBA       TPA       TSX
  599.              TXS       WAI
  600.  
  601.  
  602.         3.2  Opcodes -- One Register Argument
  603.  
  604.              The following opcodes require one argument that is either 
  605.         one of the register specifiers A or B:
  606.  
  607.              PSH       PUL
  608.  
  609.  
  610.         3.3  Opcodes -- One Memory Argument
  611.  
  612.              The opcodes in this group require one argument from the 
  613.         following list:
  614.  
  615.              1)   X, expression  where expression is 0 thru 255
  616.  
  617.              2)   expression     where expression is arbitrary
  618.  
  619.         The opcodes are:
  620.  
  621.              JMP       JSR       STD *     STS       STX
  622.  
  623.  
  624.         3.4  Opcodes -- One Register or Memory Argument
  625.  
  626.              The opcodes in this group require one argument as per the 
  627.         previous group or one of the register specifiers A or B.  The 
  628.         opcodes are:
  629.  
  630.              ASL       ASR       CLR       COM       DEC       INC
  631.              LSL       LSR       NEG       ROL       ROR       TST
  632.  
  633.  
  634.         3.5  Opcodes -- One Memory or Immediate Argument
  635.  
  636.              The opcodes in this group require one argument from the 
  637.         following list:
  638.  
  639.  
  640.                                         8
  641.  
  642.  
  643.  
  644.  
  645.              1)   X, expression  where expression is 0-255
  646.  
  647.              2)   #expression    where expression is arbitrary
  648.  
  649.              3)   expression     where expression is arbitrary
  650.  
  651.         The opcodes are:
  652.  
  653.              ADDD *    CPX       LDD *     LDS       LDX       SUBD *
  654.  
  655.  
  656.         3.6  Opcodes -- Two Arguments
  657.  
  658.              The opcodes in this group require one of the register 
  659.         specifiers A or B in addition to an argument from the following 
  660.         list:
  661.  
  662.              1)   X, expression  where expression is 0-255
  663.  
  664.              2)   #expression    where expression is -128 thru 255 (not 
  665.                                  permitted with opcode STA)
  666.  
  667.              3)   expression     where expression is arbitrary
  668.  
  669.         The opcodes are:
  670.  
  671.              ADC       ADD       AND       BIT       CMP       EOR
  672.              LDA       ORA       SBC       STA       SUB
  673.  
  674.  
  675.         3.7  Opcodes -- Relative Branches
  676.  
  677.              The opcodes in this group require one argument that is an 
  678.         expression whose value is in the range *-126 thru *+129.  The 
  679.         opcodes are:
  680.  
  681.              BCC       BCS       BEQ       BGE       BGT       BHI
  682.              BHS       BLE       BLO       BLS       BLT       BMI
  683.              BNE       BPL       BRA       BRN *     BSR       BVC
  684.              BVS
  685.  
  686.  
  687.         3.8  Opcodes -- Direct Addressing
  688.  
  689.              Many opcodes of the 6800 and 6801 CPUs allow both one-byte 
  690.         direct (or zero-page) addressing and two-byte extended 
  691.         addressing.  There is no way to explicitly call for one form of 
  692.         addressing over the other.  The assembler will choose direct 
  693.         addressing if ALL of the following conditions are met:
  694.  
  695.              1)   The required expression contains no forward references.
  696.  
  697.              2)   The expression evaluates to 0-255.
  698.  
  699.  
  700.  
  701.                                         9
  702.  
  703.  
  704.  
  705.              3)   The opcode allows direct addressing.
  706.  
  707.         Otherwise, the assembler will choose extended addressing.  Note 
  708.         that this makes it desireable to declare your zero-page RAM 
  709.         locations at the top of the program so that these locations will 
  710.         not generate forward references and foil the assembler's attempts 
  711.         to use direct addressing and shrink the object program.
  712.  
  713.  
  714.         4.0  Pseudo Opcodes
  715.  
  716.              Unlike 6800/6801 opcodes, pseudo opcodes (pseudo ops) do not 
  717.         represent machine instructions.  They are, rather, directives to 
  718.         the assembler.  These directives require various numbers and 
  719.         types of arguments.  They will be listed individually below.
  720.  
  721.  
  722.         4.1  Pseudo-ops -- CPU
  723.  
  724.              By default, the assembler does not recognize the additional 
  725.         opcodes of the 6801 CPU.  This prevents the assembler from 
  726.         generating invalid 6800 object code.  The additional 6801 opcodes 
  727.         are turned on and off by this pseudo-op which requires one 
  728.         argument whose value is either 6800 or 6801 (decimal).  Thus:
  729.  
  730.                        CPU       6800      ;turns additional opcodes off
  731.                        CPU       6801      ;turns additional opcodes on
  732.  
  733.  
  734.         4.2  Pseudo-ops -- END
  735.  
  736.              The END pseudo-op tells the assembler that the source 
  737.         program is over.  Any further lines of the source file are 
  738.         ignored and not passed on to the listing.  If an argument is 
  739.         added to the END statement, the value of the argument will be 
  740.         placed in the execution address slot in the Intel hex object 
  741.         file.  The execution address defaults to the program counter 
  742.         value at the point where the END was encountered.  Thus, to 
  743.         specify that the program starts at label START, the END statement 
  744.         would be:
  745.  
  746.                        END       START
  747.  
  748.              If end-of-file is encountered on the source file before an 
  749.         END statement is reached, the assembler will add an END statement 
  750.         to the listing and flag it with a * (missing statement) error.
  751.  
  752.  
  753.         4.3  Pseudo-ops -- EQU
  754.  
  755.              The EQU pseudo-op is used to assign a specific value to a 
  756.         label, thus the label on this line is REQUIRED.  Once the value 
  757.         is assigned, it cannot be reassigned by writing the label in 
  758.         column 1, by another EQU statement, or by a SET statement.  Thus, 
  759.         for example, the following statement assigns the value 2 to the 
  760.  
  761.  
  762.                                        10
  763.  
  764.  
  765.  
  766.         label TWO:
  767.  
  768.              TWO       EQU       1 + 1
  769.  
  770.              The expression in the argument field must contain no forward 
  771.         references.
  772.  
  773.  
  774.         4.4  Pseudo-ops -- FCB
  775.  
  776.              The FCB (Form Constant Bytes) pseudo-op allows arbitrary 
  777.         bytes to be spliced into the object code.  Its argument is a 
  778.         chain of zero or more expressions that evaluate to -128 thru 255 
  779.         separated by commas.  If a comma occurs with no preceding 
  780.         expression, a $00 byte is spliced into the object code.  The 
  781.         sequence of bytes $FE $FF, $00, $01, $02 could be spliced into 
  782.         the code with the following statement:
  783.  
  784.                        FCB       -2, -1, , 1, 2
  785.  
  786.  
  787.         4.5  Pseudo-ops -- FCC
  788.  
  789.              The FCC (Form Constant Characters) pseudo-op allows 
  790.         character strings to be spliced into the object code.  Its 
  791.         argument is a chain of zero or more string constants separated by 
  792.         blanks, tabs, or commas.  If a comma occurs with no preceding 
  793.         string constant, an S (syntax) error results.  The string 
  794.         contants are not truncated to two bytes, but are instead copied 
  795.         verbatim into the object code.  Null strings result in no bytes 
  796.         of code.  The message "Kaboom!!" could be spliced into the code 
  797.         with the following statement:
  798.  
  799.                        FCC       "Kaboom!!"     ;This is 8 bytes of code.
  800.  
  801.  
  802.         4.6  Pseudo-ops -- FDB
  803.  
  804.              The FDB (Form Double Bytes) pseudo-op allows 16-bit words to 
  805.         be spliced into the object code.  Its argument is a chain of zero 
  806.         or more expressions separated by commas.  If a comma occurs with 
  807.         no preceding expression, a word of $0000 is spliced into the 
  808.         code.  The word is placed into memory high byte in low address, 
  809.         low byte in high address as per standard Motorola order.  The 
  810.         sequence of bytes $FE $FF $00 $00 $01 $02 could be spliced into 
  811.         the code with the following statement:
  812.  
  813.                        FDB       $FEFF, , $0102
  814.  
  815.  
  816.         4.7  Pseudo-ops -- IF, ELSE, ENDI
  817.  
  818.              These three pseudo-ops allow the assembler to choose whether 
  819.         or not to assemble certain blocks of code based on the result of 
  820.         an expression.  Code that is not assembled is passed through to 
  821.  
  822.  
  823.                                        11
  824.  
  825.  
  826.  
  827.         the listing but otherwise ignored by the assembler.  The IF 
  828.         pseudo-op signals the beginning of a conditionally assembled 
  829.         block.  It requires one argument that may contain no forward 
  830.         references.  If the value of the argument is non-zero, the block 
  831.         is assembled.  Otherwise, the block is ignored.  The ENDI pseudo-
  832.         op signals the end of the conditionally assembled block.  For 
  833.         example:
  834.  
  835.                        IF   EXPRESSION     ;This whole thing generates
  836.                        FCB  $01, $02, $03  ;  no code whatsoever if
  837.                        ENDI                ;  EXPRESSION is zero.
  838.  
  839.         The ELSE pseudo-op allows the assembly of either one of two 
  840.         blocks, but not both.  The following two sequences are 
  841.         equivalent:
  842.  
  843.                        IF   EXPRESSION
  844.                        ... some stuff ...
  845.                        ELSE
  846.                        ... some more stuff ...
  847.                        ENDI
  848.  
  849.              TEMP_LAB  SET  EXPRESSION
  850.                        IF   TEMP_LAB NE 0
  851.                        ... some stuff ...
  852.                        ENDI
  853.                        IF   TEMP_LAB EQ 0
  854.                        ... some more stuff ...
  855.                        ENDI
  856.  
  857.              The pseudo-ops in this group do NOT permit labels to exist 
  858.         on the same line as the status of the label (ignored or not) 
  859.         would be ambiguous.
  860.  
  861.              All IF statements (even those in ignored conditionally 
  862.         assembled blocks) must have corresponding ENDI statements and all 
  863.         ELSE and ENDI statements must have a corresponding IF statement.
  864.  
  865.              IF blocks can be nested up to 16 levels deep before the 
  866.         assembler dies of a fatal error.  This should be adequate for any 
  867.         conceivable job, but if you need more, change the constant 
  868.         IFDEPTH in file A68.H and recompile the assembler.
  869.  
  870.  
  871.         4.8  Pseudo-ops -- INCL
  872.  
  873.              The INCL pseudo-op is used to splice the contents of another 
  874.         file into the current file at assembly time.  The name of the 
  875.         file to be INCLuded is specified as a normal string constant, so 
  876.         the following line would splice the contents of file "const.def" 
  877.         into the source code stream:
  878.  
  879.                        INCL      "const.def"
  880.  
  881.  
  882.  
  883.  
  884.                                        12
  885.  
  886.  
  887.  
  888.              INCLuded files may, in turn, INCLude other files until four 
  889.         files are open simultaneously.  This limit should be enough for 
  890.         any conceivable job, but if you need more, change the constant 
  891.         FILES in file A68.H and recompile the assembler.  
  892.  
  893.  
  894.         4.9  Pseudo-ops -- ORG
  895.  
  896.              The ORG pseudo-op is used to set the assembly program 
  897.         counter to a particular value.  The expression that defines this 
  898.         value may contain no forward references.  The default initial 
  899.         value of the assembly program counter is $0000.  The following 
  900.         statement would change the assembly program counter to $F000:
  901.  
  902.                        ORG       $F000
  903.  
  904.              If a label is present on the same line as an ORG statement, 
  905.         it is assigned the new value of the assembly program counter.
  906.  
  907.  
  908.         4.10 Pseudo-ops -- PAGE
  909.  
  910.              The PAGE pseudo-op always causes an immediate page ejection 
  911.         in the listing by inserting a form feed ('\f') character before 
  912.         the next line.  If an argument is specified, the argument 
  913.         expression specifies the number of lines per page in the listing.  
  914.         Legal values for the expression are any number except 1 and 2.  A 
  915.         value of 0 turns the listing pagination off.  Thus, the following 
  916.         statement cause a page ejection and would divide the listing into 
  917.         60-line pages:
  918.  
  919.                        PAGE      60
  920.  
  921.  
  922.         4.11 Pseudo-ops -- RMB
  923.  
  924.              The RMB (Reserve Memory Bytes) pseudo-op is used to reserve 
  925.         a block of storage for program variables, or whatever.  This 
  926.         storage is not initialized in any way, so its value at run time 
  927.         will usually be random.  The argument expression (which may
  928.         contain no forward references) is added to the assembly program 
  929.         counter.  The following statement would reserve 10 bytes of 
  930.         storage called "STORAGE":
  931.  
  932.              STORAGE   RMB       10
  933.  
  934.  
  935.         4.12 Pseudo-ops -- SET
  936.  
  937.              The SET pseudo-op functions like the EQU pseudo-op except 
  938.         that the SET statement can reassign the value of a label that has 
  939.         already been assigned by another SET statement.  Like the EQU 
  940.         statement, the argument expression may contain no forward 
  941.         references.  A label defined by a SET statement cannot be 
  942.         redefined by writing it in column 1 or with an EQU statement.  
  943.  
  944.  
  945.                                        13
  946.  
  947.  
  948.  
  949.         The following series of statements would set the value of label 
  950.         "COUNT" to 1, 2, then 3:
  951.  
  952.              COUNT     SET       1
  953.              COUNT     SET       2
  954.              COUNT     SET       3
  955.  
  956.  
  957.         4.13 Pseudo-ops -- TITL
  958.  
  959.              The TITL pseudo-op sets the running title for the listing.  
  960.         The argument field is required and must be a string constant, 
  961.         though the null string ("") is legal.  This title is printed 
  962.         after every page ejection in the listing, therefore, if page 
  963.         ejections have not been forced by the PAGE pseudo-op, the title 
  964.         will never be printed.  The following statement would print the 
  965.         title "Random Bug Generator -- Ver 3.14159" at the top of every 
  966.         page of the listing:
  967.  
  968.                        TITL      "Random Bug Generator -- Ver 3.14159"
  969.  
  970.  
  971.         5.0  Assembly Errors
  972.  
  973.              When a source line contains an illegal construct, the line 
  974.         is flagged in the listing with a single-letter code describing 
  975.         the error.  The meaning of each code is listed below.  In 
  976.         addition, a count of the number of lines with errors is kept and 
  977.         printed on the C "stderr" device (by default, the console) after 
  978.         the END statement is processed.  If more than one error occurs in 
  979.         a given line, only the first is reported.  For example, the 
  980.         illegal label "=$#*'(" would generate the following listing line:
  981.  
  982.              L  0000   FF 00 00      =$#*'(     CPX       #0
  983.  
  984.  
  985.         5.1  Error * -- Illegal or Missing Statement
  986.  
  987.              This error occurs when either:
  988.  
  989.              1)   the assembler reaches the end of the source file 
  990.                   without seeing an END statement, or
  991.  
  992.              2)   an END statement is encountered in an INCLude file.
  993.  
  994.              If you are "sure" that the END statement is present when the 
  995.         assembler thinks that it is missing, it probably is in the 
  996.         ignored section of an IF block.  If the END statement is missing, 
  997.         supply it.  If the END statement is in an INCLude file, delete 
  998.         it.
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.                                        14
  1007.  
  1008.  
  1009.  
  1010.         5.2  Error ( -- Parenthesis Imbalance
  1011.  
  1012.              For every left parenthesis, there must be a right paren-
  1013.         thesis.  Count them.
  1014.  
  1015.  
  1016.         5.3  Error " -- Missing Quotation Mark
  1017.  
  1018.              Strings have to begin and end with either " or '.  Remember 
  1019.         that " only matches " while ' only matches '.
  1020.  
  1021.  
  1022.         5.4  Error A -- Illegal Addressing Mode
  1023.  
  1024.              This error occurs if the index register designator X is used 
  1025.         with a machine opcode that does not permit indexed addressing or 
  1026.         if the immediate designator # is used with an opcode that does 
  1027.         not permit immediate addressing.
  1028.  
  1029.  
  1030.         5.5  Error B -- Branch Target Too Distant
  1031.  
  1032.              The 6800 relative branch instructions will only reach -126 
  1033.         to +129 bytes from the first byte of the branch instruction.  If 
  1034.         this error occurs, the source code will have to be rearranged to 
  1035.         shorten the distance to the branch target address or a long 
  1036.         branch instruction that will reach anywhere (JMP or JSR) will 
  1037.         have to be used.
  1038.  
  1039.  
  1040.         5.6  Error D -- Illegal Digit
  1041.  
  1042.              This error occurs if a digit greater than or equal to the 
  1043.         base of a numeric constant is found.  For example, a 2 in a 
  1044.         binary number would cause a D error.  Especially, watch for 8 or 
  1045.         9 in an octal number.
  1046.  
  1047.  
  1048.         5.7  Error E -- Illegal Expression
  1049.  
  1050.              This error occurs because of:
  1051.  
  1052.              1)   a missing expression where one is required
  1053.  
  1054.              2)   a unary operator used as a binary operator or vice-
  1055.                   versa
  1056.  
  1057.              3)   a missing binary operator
  1058.  
  1059.              4)   a SHL or SHR count that is not 0 thru 15
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.                                        15
  1068.  
  1069.  
  1070.  
  1071.         5.8  Error I -- IF-ENDI Imbalance
  1072.  
  1073.              For every IF there must be a corresponding ENDI.  If this 
  1074.         error occurs on an ELSE or ENDI statement, the corresponding IF 
  1075.         is missing.  If this error occurs on an END statement, one or 
  1076.         more ENDI statements are missing.
  1077.  
  1078.  
  1079.         5.9  Error L -- Illegal Label
  1080.  
  1081.              This error occurs because of:
  1082.  
  1083.              1)   a non-alphabetic in column 1
  1084.  
  1085.              2)   a reserved word used as a label
  1086.  
  1087.              3)   a missing label on an EQU or SET statement
  1088.  
  1089.              4)   a label on an IF, ELSE, or ENDI statement
  1090.  
  1091.  
  1092.         5.10 Error M -- Multiply Defined Label
  1093.  
  1094.              This error occurs because of:
  1095.  
  1096.              1)   a label defined in column 1 or with the EQU statement 
  1097.                   being redefined
  1098.  
  1099.              2)   a label defined by a SET statement being redefined 
  1100.                   either in column 1 or with the EQU statement
  1101.  
  1102.              3)   the value of the label changing between assembly passes
  1103.  
  1104.  
  1105.         5.11 Error O -- Illegal Opcode
  1106.  
  1107.              The opcode field of a source line may contain only a valid 
  1108.         machine opcode, a valid pseudo-op, or nothing at all.  Anything 
  1109.         else causes this error.  Note that the unique 6801 opcodes are 
  1110.         not valid until they are enabled with the CPU statement.
  1111.  
  1112.  
  1113.         5.12 Error P -- Phasing Error
  1114.  
  1115.              This error occurs because of:
  1116.  
  1117.              1)   a forward reference in a CPU, EQU, ORG, RMB, or SET 
  1118.                   statement
  1119.  
  1120.              2)   a label disappearing between assembly passes
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.                                        16
  1129.  
  1130.  
  1131.  
  1132.         5.13 Error R -- Illegal Register
  1133.  
  1134.              This error occurs either when the register designator A or B 
  1135.         is used with a machine opcode that does not permit it, or when 
  1136.         the register designator is missing with a machine opcode that 
  1137.         requires it.
  1138.  
  1139.  
  1140.         5.14 Error S -- Illegal Syntax
  1141.  
  1142.              This error means that an argument field is scrambled.  Sort 
  1143.         the mess out and reassemble.
  1144.  
  1145.  
  1146.         5.15 Error T -- Too Many Arguments
  1147.  
  1148.              This error occurs if there are more items (expressions, 
  1149.         register designators, etc.) in the argument field than the opcode 
  1150.         or pseudo-op requires.  The assembler ignores the extra items but 
  1151.         issues this error in case something is really mangled.
  1152.  
  1153.  
  1154.         5.16 Error U -- Undefined Label
  1155.  
  1156.              This error occurs if a label is referenced in an expression 
  1157.         but not defined anywhere in the source program.  If you are 
  1158.         "sure" you have defined the label, note that upper and lower case 
  1159.         letters in labels are different.  Defining "LABEL" does not 
  1160.         define "Label."
  1161.  
  1162.  
  1163.         5.17 Error V -- Illegal Value
  1164.  
  1165.              This error occurs because:
  1166.  
  1167.              1)   an index offset is not 0 thru 255, or
  1168.  
  1169.              2)   an 8-bit immediate value is not -128 thru 255, or
  1170.  
  1171.              3)   an FCB argument is not -128 thru 255, or
  1172.  
  1173.              4)   a CPU argument is not 6800 and not 6801, or
  1174.  
  1175.              5)   an INCL argument refers to a file that does not exist.
  1176.  
  1177.  
  1178.         6.0  Warning Messages
  1179.  
  1180.              Some errors that occur during the parsing of the cross-
  1181.         assembler command line are non-fatal.  The cross-assembler flags 
  1182.         these with a message on the C "stdout" device (by default, the 
  1183.         console) beginning with the word "Warning."  The messages are 
  1184.         listed below:
  1185.  
  1186.  
  1187.  
  1188.  
  1189.                                        17
  1190.  
  1191.  
  1192.  
  1193.         6.1  Warning -- Illegal Option Ignored
  1194.  
  1195.              The only options that the cross-assembler knows are -l and  
  1196.         -o.  Any other command line argument beginning with - will draw 
  1197.         this error.
  1198.  
  1199.  
  1200.         6.2  Warning -- -l Option Ignored -- No File Name
  1201.         6.3  Warning -- -o Option Ignored -- No File Name
  1202.  
  1203.              The -l and -o options require a file name to tell the 
  1204.         assembler where to put the listing file or object file.  If this 
  1205.         file name is missing, the option is ignored.
  1206.  
  1207.  
  1208.         6.4  Warning -- Extra Source File Ignored
  1209.  
  1210.              The cross-assembler will only assemble one file at a time, 
  1211.         so source file names after the first are ignored.  To assemble a 
  1212.         second file, invoke the assembler again.  Note that under CP/M-
  1213.         80, the old trick of reexecuting a core image will NOT work as 
  1214.         the initialized data areas are not reinitialized prior to the 
  1215.         second run.
  1216.  
  1217.  
  1218.         6.5  Warning -- Extra Listing File Ignored
  1219.         6.6  Warning -- Extra Object File Ignored
  1220.  
  1221.              The cross-assembler will only generate one listing and one 
  1222.         object file per assembly run, so -l and -o options after the 
  1223.         first are ignored.
  1224.  
  1225.  
  1226.         7.0  Fatal Error Messages
  1227.  
  1228.              Several errors that occur during the parsing of the cross-
  1229.         assembler command line or during the assembly run are fatal.  The 
  1230.         cross-assembler flags these with a message on the C "stdout" 
  1231.         device (by default, the console) beginning with the words "Fatal 
  1232.         Error."  The messages are explained below:
  1233.  
  1234.  
  1235.         7.1  Fatal Error -- No Source File Specified
  1236.  
  1237.              This one is self-explanatory.  The assembler does not know 
  1238.         what to assemble.
  1239.  
  1240.  
  1241.         7.2  Fatal Error -- Source File Did Not Open
  1242.  
  1243.              The assembler could not open the source file.  The most 
  1244.         likely cause is that the source file as specified on the command 
  1245.         line does not exist.  On larger systems, there could also be 
  1246.         priviledge violations.  Rarely, a read error in the disk 
  1247.         directory could cause this error.
  1248.  
  1249.  
  1250.                                        18
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.         7.3  Fatal Error -- Listing File Did Not Open
  1257.         7.4  Fatal Error -- Object File Did Not Open
  1258.  
  1259.              This error indicates either a defective listing or object 
  1260.         file name or a full disk directory.  Correct the file name or 
  1261.         make more room on the disk.
  1262.  
  1263.  
  1264.         7.5  Fatal Error -- Error Reading Source File
  1265.  
  1266.              This error generally indicates a read error in the disk data 
  1267.         space.  Use your backup copy of the source file (You do have one, 
  1268.         don't you?) to recreate the mangled file and reassemble.
  1269.  
  1270.  
  1271.         7.6  Fatal Error -- Disk or Directory Full
  1272.  
  1273.              This one is self-explanatory.  Some more space must be found 
  1274.         either by deleting files or by using a disk with more room on it.
  1275.  
  1276.  
  1277.         7.7  Fatal Error -- File Stack Overflow
  1278.  
  1279.              This error occurs if you exceed the INCLude file limit of 
  1280.         four files open simultaneously.  This limit can be increased by 
  1281.         increasing the constant FILES in file A68.H and recompiling the 
  1282.         cross-assembler.
  1283.  
  1284.  
  1285.         7.8  Fatal Error -- If Stack Overflow
  1286.  
  1287.              This error occurs if you exceed the nesting limit of 16 IF 
  1288.         blocks.  This limit can be increased by increasing the constant 
  1289.         IFDEPTH in file A68.H and recompiling the cross-assembler.
  1290.  
  1291.  
  1292.         7.9  Fatal Error -- Too Many Symbols
  1293.  
  1294.              Congratulations!  You have run out of memory.  The space for 
  1295.         the cross-assembler's symbol table is allocated at run-time using 
  1296.         the C library function alloc(), so the cross-assembler will use 
  1297.         all available memory.  The only solutions to this problem are to 
  1298.         lessen the number of labels in the source program, to use a 
  1299.         larger memory model (MSDOS/PCDOS systems only), or to add more 
  1300.         memory to your machine.
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.                                        19
  1312.