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

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