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

  1. /*
  2.     HEADER:        CUG149;
  3.     TITLE:        1805A Cross-Assembler (Portable);
  4.     FILENAME:    A18.DOC;
  5.     VERSION:    2.5;
  6.     DATE:        08/27/1988;
  7.  
  8.     DESCRIPTION:    "This program lets you use your computer to assemble
  9.             code for the RCA 1802, 1804, 1805, 1805A, 1806, and
  10.             1806A 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.             RCA, CDP1802, CDP1805;
  16.  
  17.     SEE-ALSO:    CUG113, 1802 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.                       1802/1805A Cross-Assembler (Portable)
  46.  
  47.  
  48.                                    Version 2.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 1802/1805A 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 EJCT pseudo-ops for details.
  110.  
  111.              3)   Default extensions for the source and object (hex) 
  112.                   files are no longer supplied.
  113.  
  114.              4)   The predefined labels R0-RF are no longer predefined, 
  115.                   so you will have to add a few lines to programs 
  116.                   designed for the older versions.
  117.  
  118.              5)   Include files are now supported and may be nested.
  119.  
  120.              Alas, as the sage says, "There ain't no such thing as a free 
  121.         lunch."  Massive internal changes had to be made to divorce the 
  122.         program from the CP/M-80 environment.  These changes, the fact 
  123.         that full-featured, 8-bit C compilers generate less efficient 
  124.         code than BDS C, and the fact that I have leaned on the over-
  125.         powered, slow library function printf() heavily have caused the 
  126.         package to run about a factor of 4 slower than the older 
  127.         versions.  The package also takes 3-6K more disk space to store 
  128.         than it used to take.
  129.  
  130.              On the plus side, however, the code is written in "portable" 
  131.         C, so all of the UNIX users, and the new crop of IBM-PC users 
  132.         should be able to compile and run the package almost without 
  133.         modification.  The internal structure of the package is cleaner 
  134.         than ever, so it should be very easy to hack on and turn into 
  135.         cross-assemblers for other 8-bit processors.  Finally, the source 
  136.         code has shrivelled almost to nothing since many tasks have been 
  137.         off-loaded onto standard library functions, so the need to 
  138.         "squeeze" the source code is gone.
  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 ...................................  5
  163.              2.4  Expressions ........................................  6
  164.         3.0  Machine Opcodes .........................................  7
  165.              3.1  Opcodes -- No Arguments ............................  7
  166.              3.2  Opcodes -- One Register Argument ...................  7
  167.              3.3  Opcodes -- One I/O Port Argument ...................  8
  168.              3.4  Opcodes -- One Immediate Argument ..................  8
  169.              3.5  Opcodes -- One Memory Argument .....................  8
  170.              3.6  Opcodes -- Two Arguments ...........................  8
  171.              3.7  Opcodes -- Short Branches ..........................  8
  172.         4.0  Pseudo Opcodes ..........................................  8
  173.              4.1  Pseudo-ops -- BLK ..................................  9
  174.              4.2  Pseudo-ops -- BYTE .................................  9
  175.              4.3  Pseudo-ops -- CPU ..................................  9
  176.              4.4  Pseudo-ops -- EJCT .................................  9
  177.              4.5  Pseudo-ops -- END .................................. 10
  178.              4.6  Pseudo-ops -- EQU .................................. 10
  179.              4.7  Pseudo-ops -- IF, ELSE, ENDI ....................... 10
  180.              4.8  Pseudo-ops -- INCL ................................. 11
  181.              4.9  Pseudo-ops -- LOAD ................................. 11
  182.              4.10 Pseudo-ops -- ORG .................................. 12
  183.              4.11 Pseudo-ops -- PAGE ................................. 12
  184.              4.12 Pseudo-ops -- SET .................................. 12
  185.              4.13 Pseudo-ops -- TEXT ................................. 13
  186.              4.14 Pseudo-ops -- TITL ................................. 13
  187.              4.15 Pseudo-ops -- WORD ................................. 13
  188.         5.0  Assembly Errors ......................................... 13
  189.              5.1  Error * -- Missing Statement ....................... 14
  190.              5.2  Error ( -- Parenthesis Imbalance ................... 14
  191.              5.3  Error " -- Missing Quotation Mark .................. 14
  192.              5.4  Error B -- Branch Target Too Distant ............... 14
  193.              5.5  Error D -- Illegal Digit ........................... 14
  194.              5.6  Error E -- Illegal Expression ...................... 14
  195.              5.7  Error I -- IF-ENDI Imbalance ....................... 15
  196.              5.8  Error L -- Illegal Label ........................... 15
  197.              5.9  Error M -- Multiply Defined Label .................. 15
  198.              5.10 Error O -- Illegal Opcode .......................... 15
  199.              5.11 Error P -- Phasing Error ........................... 16
  200.              5.12 Error R -- Illegal Register ........................ 16
  201.              5.13 Error S -- Illegal Syntax .......................... 16
  202.              5.14 Error T -- Too Many Arguments ...................... 16
  203.              5.15 Error U -- Undefined Label ......................... 16
  204.              5.16 Error V -- Illegal Value ........................... 16
  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 .................. 17
  219.              6.2  Warning -- -l Option Ignored -- No File Name ....... 17
  220.              6.3  Warning -- -o Option Ignored -- No File Name ....... 17
  221.              6.4  Warning -- Extra Source File Ignored ............... 17
  222.              6.5  Warning -- Extra Listing File Ignored .............. 17
  223.              6.6  Warning -- Extra Object File Ignored ............... 17
  224.         7.0  Fatal Error Messages .................................... 17
  225.              7.1  Fatal Error -- No Source File Specified ............ 17
  226.              7.2  Fatal Error -- Source File Did Not Open ............ 18
  227.              7.3  Fatal Error -- Listing File Did Not Open ........... 18
  228.              7.4  Fatal Error -- Object File Did Not Open ............ 18
  229.              7.5  Fatal Error -- Error Reading Source File ........... 18
  230.              7.6  Fatal Error -- Disk or Directory Full .............. 18
  231.              7.7  Fatal Error -- File Stack Overflow ................. 18
  232.              7.7  Fatal Error -- If Stack Overflow ................... 18
  233.              7.8  Fatal Error -- Too Many Symbols .................... 18
  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 1805A source code into 1805A
  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 an 1805A.
  292.  
  293.         This program requires one input file (your 1805A 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.                   A18 source_file { >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.              a18 test18.asm                          source:   test18.asm
  311.                                                      listing:  none
  312.                                                      object:   none
  313.  
  314.              a18 test18.asm -l test18.prn            source:   test18.asm
  315.                                                      listing:  test18.prn
  316.                                                      object:   none
  317.  
  318.              a18 test18.asm -o test18.hex            source:   test18.asm
  319.                                                      listing:  none
  320.                                                      object:   test18.hex
  321.  
  322.              a18 test18.asm -l test18.prn -o test18.hex
  323.                                                      source:   test18.asm
  324.                                                      listing:  test18.prn
  325.                                                      object:   test18.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 (09H), 
  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 A18.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   RLDI  R1, POINTER     ; This line has everything.
  384.                      SEX   R1              ; 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, PAGE, 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.              $         AND       EQ        GE        GT        HIGH
  422.              LE        LT        LOW       MOD       NE        NOT
  423.              OR        SHL       SHR       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 are formed according to the Intel 
  437.         convention.  A numeric constant starts with a numeric character 
  438.         (0-9), continues with zero or more digits (0-9, A-F), and ends 
  439.         with an optional base designator.  The base designators are H for 
  440.         hexadecimal, none or D for decimal, O or Q for octal, and B for 
  441.         binary.  The hex digits a-f are converted to upper case by the 
  442.         assembler.  Note that a numeric constant cannot begin with A-F as 
  443.         it would be indistinguishable from a label.  Thus, all of the 
  444.         following evaluate to 255 (decimal):
  445.  
  446.                    0ffH   255   255D   377O   377Q   11111111B
  447.  
  448.  
  449.         2.3  String Constants
  450.  
  451.              A string constant is zero or more characters enclosed in 
  452.         either single quotes (' ') or double quotes (" ").  Single quotes 
  453.         only match single quotes, and double quotes only match double 
  454.         quotes, so if you want to put a single quote in a string, you can 
  455.  
  456.  
  457.                                         5
  458.  
  459.  
  460.  
  461.         do it like this:  "'".  In all contexts except the TEXT 
  462.         statement, the first character or two of the string constant are 
  463.         all that are used.  The rest is ignored.  Noting that the ASCII 
  464.         codes for "A" and "B" are $41 and $42, respectively, will explain 
  465.         the following examples:
  466.  
  467.                   "" and ''           evaluate to $0000
  468.                   "A" and 'A'         evaluate to $0041
  469.                   "AB"                evaluates to $4142
  470.  
  471.         Note that the null string "" is legal and evaluates to $0000.
  472.  
  473.  
  474.         2.4  Expressions
  475.  
  476.              An expression is made up of labels, numeric constants, and 
  477.         string constants glued together with arithmetic operators, 
  478.         logical operators, and parentheses in the usual way that 
  479.         algebraic expressions are made.  Operators have the following 
  480.         fairly natural order of precedence:
  481.  
  482.              Highest        anything in parentheses
  483.                             unary +, unary -
  484.                             *, /, MOD, SHL, SHR
  485.                             binary +, binary -
  486.                             LT, LE, EQ, GE, GT, NE
  487.                             NOT
  488.                             AND
  489.                             OR, XOR
  490.              Lowest         HIGH, LOW
  491.  
  492.              A few notes about the various operators are in order:
  493.  
  494.              1)   The remainder operator MOD yields the remainder from 
  495.                   dividing its left operand by its right operand.
  496.  
  497.              2)   The shifting operators SHL and SHR shift their left 
  498.                   operand to the left or right the number of bits 
  499.                   specified by their right operand.
  500.  
  501.              3)   The relational operators LT, LE, EQ, GE, GT, and NE can 
  502.                   also be written as <, <= or =<, =, >= or =>, and <> or 
  503.                   ><, respectively.  They evaluate to 0FFFFH if the 
  504.                   statement is true, 0 otherwise.
  505.  
  506.              4)   The logical opeators NOT, AND, OR, and XOR do bitwise 
  507.                   operations on their operand(s).
  508.  
  509.              5)   HIGH and LOW extract the high or low byte, of an 
  510.                   expression.
  511.  
  512.              6)   The special symbol $ can be used in place of a label or 
  513.                   constant to represent the value of the program counter 
  514.                   before any of the current line has been processed.
  515.  
  516.  
  517.  
  518.                                         6
  519.  
  520.  
  521.  
  522.              Some examples are in order at this point:
  523.  
  524.              2 + 3 * 4                          evaluates to 14
  525.              (2 + 3) * 4                        evaluates to 20
  526.              NOT %11110000 XOR %00001010        evaluates to %00000101
  527.              HIGH 1234H SHL 1                   evaluates to $0024
  528.              001Q EQ 0                          evaluates to 0
  529.              001Q = 2 SHR 1                     evaluates to $FFFF
  530.  
  531.              All arithmetic is unsigned with overflow from the 16-bit 
  532.         word ignored.  Thus:
  533.  
  534.              32768 * 2                          evaluates to 0
  535.  
  536.  
  537.         3.0  Machine Opcodes
  538.  
  539.              The opcodes of the 1802 and 1805A processors are divided 
  540.         into groups below by the type of arguments required in the 
  541.         argument field of the source line.  Opcodes that are peculiar to 
  542.         the 1805A are marked with an asterisk.  If an opcode requires 
  543.         multiple arguments, these must be placed in the argument field in 
  544.         order and separated by commas.
  545.  
  546.  
  547.         3.1  Opcodes -- No Arguments
  548.  
  549.              The following opcodes allow no arguments at all in their 
  550.         argument fields:
  551.  
  552.              ADC       ADD       AND       CID *     CIE *     DADC *
  553.              DADD *    DIS       DSAV *    DSM *     DSMB *    DTC *
  554.              ETQ *     GEC *     IDL       IRX       LDC *     LDX
  555.              LDXA      LSDF      LSIE      LSKP      LSNF      LSNQ
  556.              LSNZ      LSQ       LSZ       MARK      NOP       OR
  557.              REQ       RET       RSHL      RSHR      SAV       SCM1 *
  558.              SCM2 *    SD        SDB       SEQ       SHL       SHLC
  559.              SHR       SHRC      SKP       SM        SMB       SPM1 *
  560.              SPM2 *    STM *     STPC *    STXD      XID *     XIE *
  561.                                  XOR
  562.  
  563.  
  564.         3.2  Opcodes -- One Register Argument
  565.  
  566.              The following opcodes require one argument that is in the 
  567.         range 0 - 15 (except LDN which requires 1 - 15):
  568.  
  569.              DEC       GHI       GLO       INC       LDA       LDN
  570.              PHI       PLO       RLXA *    RNX *     RSXD *    SEP
  571.                        SEX       SRET *    STR
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.                                         7
  580.  
  581.  
  582.  
  583.         3.3  Opcodes -- One I/O Port Argument
  584.  
  585.              The following opcodes require one argument that is in the 
  586.         range 1 - 7:
  587.  
  588.                                  INP       OUT
  589.  
  590.  
  591.         3.4  Opcodes -- One Immediate Argument
  592.  
  593.              The following opcodes require one argument that is in the 
  594.         range -128 through 255:
  595.  
  596.              ADCI      ADI       ANI       DACI *    DADI *    DSBI *
  597.              DSMI *    LDI       ORI       SDBI      SDI       SMBI
  598.              SMI       XRI
  599.  
  600.  
  601.         3.5  Opcodes -- One Memory Argument
  602.  
  603.              The following opcodes require one argument that can have any 
  604.         value:
  605.  
  606.              LBDF      LBNF      LBNQ      LBNZ      LBQ       LBR
  607.                                  LBZ       NLBR
  608.  
  609.  
  610.         3.6  Opcodes -- Two Arguments
  611.  
  612.              The opcodes in this group require two arguments.  The first 
  613.         must be in the range 0 - 15.  The second can have any value.  The 
  614.         opcodes are:
  615.  
  616.                        DBNZ *    RLDI *    SCAL *
  617.  
  618.  
  619.         3.7  Opcodes -- Short Branches
  620.  
  621.              The opcodes in this group require one argument whose high 
  622.         byte is the same as the high byte of the address of the LAST byte 
  623.         of the insruction.  The opcodes are:
  624.  
  625.              B1        B2        B3        B4        BCI *     BDF
  626.              BGE       BL        BM        BN1       BN2       BN3
  627.              BN4       BNF       BNQ       BNZ       BPZ       BQ
  628.                        BR        BXI *     BZ        NBR
  629.  
  630.  
  631.         4.0  Pseudo Opcodes
  632.  
  633.              Unlike 1802/1805A opcodes, pseudo opcodes (pseudo-ops) do 
  634.         not represent machine instructions.  They are, rather, directives 
  635.         to the assembler.  These directives require various numbers and 
  636.         types of arguments.  They will be listed individually below.
  637.  
  638.  
  639.  
  640.                                         8
  641.  
  642.  
  643.  
  644.  
  645.         4.1  Pseudo-ops -- BLK
  646.  
  647.              The BLK pseudo-op is used to reserve a block of storage for 
  648.         program variables, or whatever.  This storage is not initialized 
  649.         in any way, so its value at run time will usually be random.  The 
  650.         argument expression (which may contain no forward references) is 
  651.         added to the assembly program counter.  The following statement 
  652.         would reserve 10 bytes of storage called "STORAGE":
  653.  
  654.              STORAGE   BLK       10
  655.  
  656.  
  657.         4.2  Pseudo-ops -- BYTE
  658.  
  659.              The BYTE pseudo-op allows arbitrary bytes to be spliced into 
  660.         the object code.  Its argument is a chain of zero or more 
  661.         expressions that evaluate to -128 through 255 separated by 
  662.         commas.  If a comma occurs with no preceding expression, a 00H 
  663.         byte is spliced into the object code.  The sequence of bytes 
  664.         0FEH, 0FFH, 00H, 01H, 02H could be spliced into the code with the 
  665.         following statement:
  666.  
  667.                        BYTE      -2, -1, , 1, 2
  668.  
  669.  
  670.         4.3  Pseudo-ops -- CPU
  671.  
  672.              By default, the assembler does not recognize the additional 
  673.         opcodes of the 1805A CPU.  This prevents the assembler from 
  674.         generating invalid 1802 object code.  The additional 1805A 
  675.         opcodes are turned on and off by this pseudo-op which requires 
  676.         one argument whose value is either 1802 or 1805 (decimal).  Thus:
  677.  
  678.                        CPU       1802      ;turns additional opcodes off
  679.                        CPU       1805      ;turns additional opcodes on
  680.  
  681.  
  682.         4.4  Pseudo-ops -- EJCT
  683.  
  684.              The EJCT pseudo-op always causes an immediate page ejection 
  685.         in the listing by inserting a form feed ('\f') character before 
  686.         the next line.  If an argument is specified, the argument 
  687.         expression specifies the number of lines per page in the listing.  
  688.         Legal values for the expression are any number except 1 and 2.  A 
  689.         value of 0 turns the listing pagination off.  Thus, the following 
  690.         statement cause a page ejection and would divide the listing into 
  691.         60-line pages:
  692.  
  693.                        EJCT      60
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.                                         9
  702.  
  703.  
  704.  
  705.         4.5  Pseudo-ops -- END
  706.  
  707.              The END pseudo-op tells the assembler that the source 
  708.         program is over.  Any further lines of the source file are 
  709.         ignored and not passed on to the listing.  If an argument is 
  710.         added to the END statement, the value of the argument will be 
  711.         placed in the execution address slot in the Intel hex object 
  712.         file.  The execution address defaults to the program counter 
  713.         value at the point where the END was encountered.  Thus, to 
  714.         specify that the program starts at label START, the END statement 
  715.         would be:
  716.  
  717.                        END       START
  718.  
  719.              If end-of-file is encountered on the source file before an 
  720.         END statement is reached, the assembler will add an END statement 
  721.         to the listing and flag it with a * (missing statement) error.
  722.  
  723.  
  724.         4.6  Pseudo-ops -- EQU
  725.  
  726.              The EQU pseudo-op is used to assign a specific value to a 
  727.         label, thus the label on this line is REQUIRED.  Once the value 
  728.         is assigned, it cannot be reassigned by writing the label in 
  729.         column 1, by another EQU statement, or by a SET statement.  Thus, 
  730.         for example, the following statement assigns the value 2 to the 
  731.         label TWO:
  732.  
  733.              TWO       EQU       1 + 1
  734.  
  735.              The expression in the argument field must contain no forward 
  736.         references.
  737.  
  738.  
  739.         4.7  Pseudo-ops -- IF, ELSE, ENDI
  740.  
  741.              These three pseudo-ops allow the assembler to choose whether 
  742.         or not to assemble certain blocks of code based on the result of 
  743.         an expression.  Code that is not assembled is passed through to 
  744.         the listing but otherwise ignored by the assembler.  The IF 
  745.         pseudo-op signals the beginning of a conditionally assembled 
  746.         block.  It requires one argument that may contain no forward 
  747.         references.  If the value of the argument is non-zero, the block 
  748.         is assembled.  Otherwise, the block is ignored.  The ENDI pseudo-
  749.         op signals the end of the conditionally assembled block.  For 
  750.         example:
  751.  
  752.                        IF   EXPRESSION     ;This whole thing generates
  753.                        BYTE 01H, 02H, 03H  ;  no code whatsoever if
  754.                        ENDI                ;  EXPRESSION is zero.
  755.  
  756.         The ELSE pseudo-op allows the assembly of either one of two 
  757.         blocks, but not both.  The following two sequences are 
  758.         equivalent:
  759.  
  760.  
  761.  
  762.                                        10
  763.  
  764.  
  765.  
  766.                        IF   EXPRESSION
  767.                        ... some stuff ...
  768.                        ELSE
  769.                        ... some more stuff ...
  770.                        ENDI
  771.  
  772.              TEMP_LAB  SET  EXPRESSION
  773.                        IF   TEMP_LAB NE 0
  774.                        ... some stuff ...
  775.                        ENDI
  776.                        IF   TEMP_LAB EQ 0
  777.                        ... some more stuff ...
  778.                        ENDI
  779.  
  780.              The pseudo-ops in this group do NOT permit labels to exist 
  781.         on the same line as the status of the label (ignored or not) 
  782.         would be ambiguous.
  783.  
  784.              All IF statements (even those in ignored conditionally 
  785.         assembled blocks) must have corresponding ENDI statements and all 
  786.         ELSE and ENDI statements must have a corresponding IF statement.
  787.  
  788.              IF blocks can be nested up to 16 levels deep before the 
  789.         assembler dies of a fatal error.  This should be adequate for any 
  790.         conceivable job, but if you need more, change the constant 
  791.         IFDEPTH in file A18.H and recompile the assembler.
  792.  
  793.  
  794.         4.8  Pseudo-ops -- INCL
  795.  
  796.              The INCL pseudo-op is used to splice the contents of another 
  797.         file into the current file at assembly time.  The name of the 
  798.         file to be INCLuded is specified as a normal string constant, so 
  799.         the following line would splice the contents of file "const.def" 
  800.         into the source code stream:
  801.  
  802.                        INCL      "const.def"
  803.  
  804.              INCLuded files may, in turn, INCLude other files until four 
  805.         files are open simultaneously.  This limit should be enough for 
  806.         any conceivable job, but if you need more, change the constant 
  807.         FILES in file A18.H and recompile the assembler.
  808.  
  809.  
  810.         4.9  Pseudo-ops -- LOAD
  811.  
  812.              This pseudo-op is a built-in macro that makes up for the 
  813.         1802's lack of the RLDI instruction.  The very common function of 
  814.         loading a 16-bit immediate value into a register is normally done 
  815.         with the following 4-line sequence:
  816.  
  817.                        LDI       HIGH VALUE
  818.                        PHI       REGISTER
  819.                        LDI       LOW VALUE
  820.                        PLO       REGISTER
  821.  
  822.  
  823.                                        11
  824.  
  825.  
  826.  
  827.  
  828.         This pseudo-op reduces the above sequence to the following line:
  829.  
  830.                        LOAD      REGISTER, VALUE
  831.  
  832.         Note that this construct blows away the contents of the D 
  833.         register whereas the 1805A's RLDI instruction blows away the T 
  834.         register and leaves the D register intact.
  835.  
  836.  
  837.         4.10 Pseudo-ops -- ORG
  838.  
  839.              The ORG pseudo-op is used to set the assembly program 
  840.         counter to a particular value.  The expression that defines this 
  841.         value may contain no forward references.  The default initial 
  842.         value of the assembly program counter is 0000H.  The following 
  843.         statement would change the assembly program counter to 0F000H:
  844.  
  845.                        ORG       0F000H
  846.  
  847.              If a label is present on the same line as an ORG statement, 
  848.         it is assigned the new value of the assembly program counter.
  849.  
  850.  
  851.         4.11 Pseudo-ops -- PAGE
  852.  
  853.              This pseudo-op is a built-in macro for a very common use of 
  854.         the ORG pseudo-op, i.e. setting the assembly program counter to 
  855.         the first address of the next 256-byte page.  The long-hand form 
  856.         using the ORG pseudo-op is:
  857.  
  858.                        ORG       ($ + 255) AND 0FF00H
  859.  
  860.         The short form is:
  861.  
  862.                        PAGE
  863.  
  864.         Note that this pseudo-op has no effect if the assembly counter is 
  865.         already at the beginning of a 256-byte page.
  866.  
  867.  
  868.         4.12 Pseudo-ops -- SET
  869.  
  870.              The SET pseudo-op functions like the EQU pseudo-op except 
  871.         that the SET statement can reassign the value of a label that has 
  872.         already been assigned by another SET statement.  Like the EQU 
  873.         statement, the argument expression may contain no forward 
  874.         references.  A label defined by a SET statement cannot be 
  875.         redefined by writing it in column 1 or with an EQU statement.  
  876.         The following series of statements would set the value of label 
  877.         "COUNT" to 1, 2, then 3:
  878.  
  879.              COUNT     SET       1
  880.              COUNT     SET       2
  881.              COUNT     SET       3
  882.  
  883.  
  884.                                        12
  885.  
  886.  
  887.  
  888.  
  889.  
  890.         4.13 Pseudo-ops -- TEXT
  891.  
  892.              The TEXT pseudo-op allows character strings to be spliced 
  893.         into the object code.  Its argument is a chain of zero or more 
  894.         string constants separated by blanks, tabs, or commas.  If a 
  895.         comma occurs with no preceding string constant, an S (syntax) 
  896.         error results.  The string contants are not truncated to two 
  897.         bytes, but are instead copied verbatim into the object code.  
  898.         Null strings result in no bytes of code.  The message "Kaboom!!" 
  899.         could be spliced into the code with the following statement:
  900.  
  901.                        TEXT      "Kaboom!!"     ;This is 8 bytes of code.
  902.  
  903.  
  904.         4.14 Pseudo-ops -- TITL
  905.  
  906.              The TITL pseudo-op sets the running title for the listing.  
  907.         The argument field is required and must be a string constant, 
  908.         though the null string ("") is legal.  This title is printed 
  909.         after every page ejection in the listing, therefore, if page 
  910.         ejections have not been forced by the PAGE pseudo-op, the title 
  911.         will never be printed.  The following statement would print the 
  912.         title "Random Bug Generator -- Ver 3.14159" at the top of every 
  913.         page of the listing:
  914.  
  915.                        TITL      "Random Bug Generator -- Ver 3.14159"
  916.  
  917.  
  918.         4.15 Pseudo-ops -- WORD
  919.  
  920.              The WORD pseudo-op allows 16-bit words to be spliced into 
  921.         the object code.  Its argument is a chain of zero or more 
  922.         expressions separated by commas.  If a comma occurs with no 
  923.         preceding expression, a word of 0000H is spliced into the code.  
  924.         The word is placed into memory high byte in low address, low byte 
  925.         in high address as per standard Motorola order.  The sequence of 
  926.         bytes 0FEH, 0FFH, 00H, 00H, 01H, 02H could be spliced into the 
  927.         code with the following statement:
  928.  
  929.                        WORD      0FEFFH, , 0102H
  930.  
  931.  
  932.         5.0  Assembly Errors
  933.  
  934.              When a source line contains an illegal construct, the line 
  935.         is flagged in the listing with a single-letter code describing 
  936.         the error.  The meaning of each code is listed below.  In 
  937.         addition, a count of the number of lines with errors is kept and 
  938.         printed on the C "stderr" device (by default, the console) after 
  939.         the END statement is processed.  If more than one error occurs in 
  940.         a given line, only the first is reported.  For example, the 
  941.         illegal label "=$#*'(" would generate the following listing line:
  942.  
  943.  
  944.  
  945.                                        13
  946.  
  947.  
  948.  
  949.              L  0000   FF 00 00      =$#*'(     LDA       R0
  950.  
  951.  
  952.         5.1  Error * -- Illegal or Missing Statement
  953.  
  954.              This error occurs when either:
  955.  
  956.              1)   the assembler reaches the end of the source file 
  957.                   without seeing an END statement, or
  958.  
  959.              2)   an END statement is encountered in an INCLude file.
  960.  
  961.              If you are "sure" that the END statement is present when the 
  962.         assembler thinks that it is missing, it probably is in the 
  963.         ignored section of an IF block.  If the END statement is missing, 
  964.         supply it.  If the END statement is in an INCLude file, delete 
  965.         it.
  966.  
  967.  
  968.         5.2  Error ( -- Parenthesis Imbalance
  969.  
  970.              For every left parenthesis, there must be a right paren-
  971.         thesis.  Count them.
  972.  
  973.  
  974.         5.3  Error " -- Missing Quotation Mark
  975.  
  976.              Strings have to begin and end with either " or '.  Remember 
  977.         that " only matches " while ' only matches '.
  978.  
  979.  
  980.         5.4  Error B -- Branch Target Too Distant
  981.  
  982.              The 1805A short branch instructions will only reach bytes 
  983.         that are on the same 256-byte page as the last byte of the branch 
  984.         instruction.  If this error occurs, the source code will have to 
  985.         be rearranged to bring the branch target onto the correct page or 
  986.         a long branch instruction that will reach anywhere will have to 
  987.         be used.
  988.  
  989.  
  990.         5.5  Error D -- Illegal Digit
  991.  
  992.              This error occurs if a digit greater than or equal to the 
  993.         base of a numeric constant is found.  For example, a 2 in a 
  994.         binary number would cause a D error.  Especially, watch for 8 or 
  995.         9 in an octal number.
  996.  
  997.  
  998.         5.6  Error E -- Illegal Expression
  999.  
  1000.              This error occurs because of:
  1001.  
  1002.              1)   a missing expression where one is required
  1003.  
  1004.  
  1005.  
  1006.                                        14
  1007.  
  1008.  
  1009.  
  1010.              2)   a unary operator used as a binary operator or vice-
  1011.                   versa
  1012.  
  1013.              3)   a missing binary operator
  1014.  
  1015.              4)   a SHL or SHR count that is not 0 thru 15
  1016.  
  1017.  
  1018.         5.7  Error I -- IF-ENDI Imbalance
  1019.  
  1020.              For every IF there must be a corresponding ENDI.  If this 
  1021.         error occurs on an ELSE or ENDI statement, the corresponding IF 
  1022.         is missing.  If this error occurs on an END statement, one or 
  1023.         more ENDI statements are missing.
  1024.  
  1025.  
  1026.         5.8  Error L -- Illegal Label
  1027.  
  1028.              This error occurs because of:
  1029.  
  1030.              1)   a non-alphabetic in column 1
  1031.  
  1032.              2)   a reserved word used as a label
  1033.  
  1034.              3)   a missing label on an EQU or SET statement
  1035.  
  1036.              4)   a label on an IF, ELSE, or ENDI statement
  1037.  
  1038.  
  1039.         5.9  Error M -- Multiply Defined Label
  1040.  
  1041.              This error occurs because of:
  1042.  
  1043.              1)   a label defined in column 1 or with the EQU statement 
  1044.                   being redefined
  1045.  
  1046.              2)   a label defined by a SET statement being redefined 
  1047.                   either in column 1 or with the EQU statement
  1048.  
  1049.              3)   the value of the label changing between assembly passes
  1050.  
  1051.  
  1052.         5.10 Error O -- Illegal Opcode
  1053.  
  1054.              The opcode field of a source line may contain only a valid 
  1055.         machine opcode, a valid pseudo-op, or nothing at all.  Anything 
  1056.         else causes this error.  Note that the unique 1805A opcodes are 
  1057.         not valid until they are enabled with the CPU statement.
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.                                        15
  1068.  
  1069.  
  1070.  
  1071.         5.11 Error P -- Phasing Error
  1072.  
  1073.              This error occurs because of:
  1074.  
  1075.              1)   a forward reference in a BLK, CPU, EQU, ORG, or SET 
  1076.                   statement
  1077.  
  1078.              2)   a label disappearing between assembly passes
  1079.  
  1080.  
  1081.         5.12 Error R -- Illegal Register
  1082.  
  1083.              This error occurs when a register argument is not in the 
  1084.         range 0 - 15 (1 - 15 for LDN) or when an I/O port argument is not 
  1085.         in the range 1 - 7.
  1086.  
  1087.  
  1088.         5.13 Error S -- Illegal Syntax
  1089.  
  1090.              This error means that an argument field is scrambled.  Sort 
  1091.         the mess out and reassemble.
  1092.  
  1093.  
  1094.         5.14 Error T -- Too Many Arguments
  1095.  
  1096.              This error occurs if there are more items (expressions, 
  1097.         register designators, etc.) in the argument field than the opcode 
  1098.         or pseudo-op requires.  The assembler ignores the extra items but 
  1099.         issues this error in case something is really mangled.
  1100.  
  1101.  
  1102.         5.15 Error U -- Undefined Label
  1103.  
  1104.              This error occurs if a label is referenced in an expression 
  1105.         but not defined anywhere in the source program.  If you are 
  1106.         "sure" you have defined the label, note that upper and lower case 
  1107.         letters in labels are different.  Defining "LABEL" does not 
  1108.         define "Label."
  1109.  
  1110.  
  1111.         5.16 Error V -- Illegal Value
  1112.  
  1113.              This error occurs because:
  1114.  
  1115.              1)   an immediate value is not -128 thru 255, or
  1116.  
  1117.              2)   a BYTE argument is not -128 thru 255, or
  1118.  
  1119.              3)   a CPU argument is not 1802 and not 1805, or
  1120.  
  1121.              4)   an INCL argument refers to a file that does not exist.
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.                                        16
  1129.  
  1130.  
  1131.  
  1132.         6.0  Warning Messages
  1133.  
  1134.              Some errors that occur during the parsing of the cross-
  1135.         assembler command line are non-fatal.  The cross-assembler flags 
  1136.         these with a message on the C "stdout" device (by default, the 
  1137.         console) beginning with the word "Warning."  The messages are 
  1138.         listed below:
  1139.  
  1140.  
  1141.         6.1  Warning -- Illegal Option Ignored
  1142.  
  1143.              The only options that the cross-assembler knows are -l and  
  1144.         -o.  Any other command line argument beginning with - will draw 
  1145.         this error.
  1146.  
  1147.  
  1148.         6.2  Warning -- -l Option Ignored -- No File Name
  1149.         6.3  Warning -- -o Option Ignored -- No File Name
  1150.  
  1151.              The -l and -o options require a file name to tell the 
  1152.         assembler where to put the listing file or object file.  If this 
  1153.         file name is missing, the option is ignored.
  1154.  
  1155.  
  1156.         6.4  Warning -- Extra Source File Ignored
  1157.  
  1158.              The cross-assembler will only assemble one file at a time, 
  1159.         so source file names after the first are ignored.  To assemble a 
  1160.         second file, invoke the assembler again.  Note that under CP/M-
  1161.         80, the old trick of reexecuting a core image will NOT work as 
  1162.         the initialized data areas are not reinitialized prior to the 
  1163.         second run.
  1164.  
  1165.  
  1166.         6.5  Warning -- Extra Listing File Ignored
  1167.         6.6  Warning -- Extra Object File Ignored
  1168.  
  1169.              The cross-assembler will only generate one listing and 
  1170.         object file per assembly run, so -l and -o options after the 
  1171.         first are ignored.
  1172.  
  1173.  
  1174.         7.0  Fatal Error Messages
  1175.  
  1176.              Several errors that occur during the parsing of the cross-
  1177.         assembler command line or during the assembly run are fatal.  The 
  1178.         cross-assembler flags these with a message on the C "stdout" 
  1179.         device (by default, the console) beginning with the words "Fatal 
  1180.         Error."  The messages are explained below:
  1181.  
  1182.  
  1183.         7.1  Fatal Error -- No Source File Specified
  1184.  
  1185.              This one is self-explanatory.  The assembler does not know 
  1186.         what to assemble.
  1187.  
  1188.  
  1189.                                        17
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.         7.2  Fatal Error -- Source File Did Not Open
  1196.  
  1197.              The assembler could not open the source file.  The most 
  1198.         likely cause is that the source file as specified on the command 
  1199.         line does not exist.  On larger systems, there could also be 
  1200.         priviledge violations.  Rarely, a read error in the disk 
  1201.         directory could cause this error.
  1202.  
  1203.  
  1204.         7.3  Fatal Error -- Listing File Did Not Open
  1205.         7.4  Fatal Error -- Object File Did Not Open
  1206.  
  1207.              This error indicates either a defective listing or object 
  1208.         file name or a full disk directory.  Correct the file name or 
  1209.         make more room on the disk.
  1210.  
  1211.  
  1212.         7.5  Fatal Error -- Error Reading Source File
  1213.  
  1214.              This error generally indicates a read error in the disk data 
  1215.         space.  Use your backup copy of the source file (You do have one, 
  1216.         don't you?) to recreate the mangled file and reassemble.
  1217.  
  1218.  
  1219.         7.6  Fatal Error -- Disk or Directory Full
  1220.  
  1221.              This one is self-explanatory.  Some more space must be found 
  1222.         either by deleting files or by using a disk with more room on it.
  1223.  
  1224.  
  1225.         7.7  Fatal Error -- File Stack Overflow
  1226.  
  1227.              This error occurs if you exceed the INCLude file limit of 
  1228.         four files open simultaneously.  This limit can be increased by 
  1229.         increasing the constant FILES in file A18.H and recompiling the 
  1230.         cross-assembler.
  1231.  
  1232.  
  1233.         7.8  Fatal Error -- If Stack Overflow
  1234.  
  1235.              This error occurs if you exceed the nesting limit of 16 IF 
  1236.         blocks.  This limit can be increased by increasing the constant 
  1237.         IFDEPTH in file A18.H and recompiling the cross-assembler.
  1238.  
  1239.  
  1240.         7.9  Fatal Error -- Too Many Symbols
  1241.  
  1242.              Congratulations!  You have run out of memory.  The space for 
  1243.         the cross-assembler's symbol table is allocated at run-time using 
  1244.         the C library function alloc(), so the cross-assembler will use 
  1245.         all available memory.  The only solutions to this problem are to 
  1246.         lessen the number of labels in the source program or to add more 
  1247.         memory.
  1248.  
  1249.  
  1250.                                        18
  1251.