home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 25 / CD_ASCQ_25_1095.iso / dos / prg / asxx_108 / as02_108 / as02.man < prev    next >
Text File  |  1995-07-01  |  24KB  |  660 lines

  1. Kingswood Software Development Tools                                 AS02
  2. -------------------------------------------------------------------------
  3.  
  4. NAME
  5.    as02 - assembler for M6800/6801/6802/6803 microprocessors.
  6.  
  7.  
  8. SYNOPSIS
  9.    as02 [-cdghilnopqstvwxz] file
  10.  
  11.  
  12. DESCRIPTION
  13.    This documentation is for as02 [1.08].
  14.    Copyright 1990-1994, Frank A. Vorstenbosch, Kingswood Software.
  15.  
  16.    AS02 is an assembler for the Motorola 6800/6801/6802 and 6803 
  17.    microprocessors.  It reads input from an ASCII text file, assembles 
  18.    this into memory, and then writes a listing and a binary or hex file.
  19.  
  20.    AS02 is case sensitive, not only does it differentiate between the
  21.    labels XYZ and xyz, but it also requires all (pseudo) instruction and
  22.    register names to be lower case.  This way, the listing is the most
  23.    readable.  Option -i can be used to make the assembler case insensitive.
  24.    Alternatively, the included TOLOWER program can be used to convert
  25.    sources to lower case.
  26.  
  27.  
  28. OPTIONS
  29.    As02 recognizes the following options:
  30.  
  31.       -c   Show number of cycles per instruction in listing.  This
  32.            decreases the number of columns available for listing by 5.
  33.            The number of cycles is printed between brackets [ and ].
  34.  
  35.       -d<name>
  36.             Define a label before the first source line is read.  If
  37.             no name is specified, DEBUG is defined.  The label is
  38.             EQUated to be 1.
  39.  
  40.       -g   Generate source-level debug information file.  This file
  41.            can then be used in in-system debugging or a software
  42.            simulator.
  43.  
  44.       -h<lines>
  45.            Specify height of page for listing.  This option determines
  46.            the number of lines per printed page.  Each page has a header
  47.            and is terminated by a form-feed character.  The special
  48.            case -h0 indicates an infinite page length.  In this case,
  49.            page breaks are only inserted between the two passes and
  50.            the symbol table (if present).
  51.  
  52.       -i   Ignore case in opcodes.  In this way, the assembler does not
  53.            differentiate between 'add' and 'ADD', for example.  Labels
  54.            are still case sensitive.
  55.  
  56.       -l   Generate pass 2 listing.
  57.  
  58.       -l<filename>
  59.             Listing file name.  The listing file is used for pass 1 and
  60.             pass 2 listing, for the symbol table (printed between the
  61.             two passes), and some statistics.  When neither -p nor -t
  62.             is specified, and -l<filename> is given, then the assembler
  63.             automatically generates a pass 2 listing.  When -p or -t is
  64.             specified, an additional -l should be given is a pass 2
  65.             listing is required.  The filename - can be used to direct
  66.             the listing to standard output.
  67.  
  68.       -l   Generate pass 2 listing.
  69.  
  70.       -n   Disable optimizations.  When this option is specified no
  71.            optimizations will be done, even when the OPT pseudo-
  72.            instruction is used in the source code.
  73.  
  74.       -o<filename>
  75.            Specify binary or s-records output file name.  The assembler
  76.            automatically adds ".bin" for binary output or ".s19" for
  77.            s-records output when no extension is given.
  78.  
  79.       -p   Generate pass 1 listing.  This may be used to examine any
  80.            optimizations/bugs generated in pass 2.
  81.  
  82.       -q   Quiet mode.  No running line counter is displayed on standard
  83.            error output.
  84.  
  85.       -s   Write s-records instead of binary file.  The s-records file
  86.            contains data for (only) the used memory; the binary file
  87.            begins at the lowest used address, and continues up to the
  88.            highest used address; filling unused memory between these
  89.            two addresses with either $ff or $00.
  90.  
  91.       -s2  Write intel-hex file instead of binary file.  The intel-hex
  92.            file contains data for (only) the used memory.
  93.  
  94.       -t   Generate symbol table.  The symbol table is listed between
  95.            passes one and two, displaying the name, hexadecimal and
  96.            decimal value of each label, using 4-digit hexadecimal
  97.            numbers where possible, otherwise 8-digit numbers.  The
  98.            decimal value is followed by an asterisk if the label is
  99.            redefinable (defined using SET instead of EQU).
  100.  
  101.       -v   Verbose mode.  More information is displayed on standard
  102.            output.
  103.  
  104.       -w<width>
  105.            Specify column width.  Normally, the listing is printed using
  106.            79 columns for output to a 80-column screen or printer.  If
  107.            the -w option is given without a number following it, then
  108.            the listing will be 131 columns wide, otherwise it will be
  109.            the number of colulmns specified (between 60 and 200).
  110.  
  111.       -x   Use 6801/6803 extensions.  These two CPUs have several
  112.            additional instructions and improve slightly on execution
  113.            times.  When this option is not specified the assembler 
  114.            rejects the 6801/6803 extensions.
  115.  
  116.       -z   Fill unused memory with zeros.  Normally when a binary file
  117.            is generated, unused bytes between the lowest and highest
  118.            used addresses are filled with $ff, the unprogrammed state
  119.            of EPROMs.  If this is not wanted, the -z option can be used
  120.            to initialize this memory to $00.  With s-records, unused
  121.            memory is not output to the file, and this option forces the
  122.            creation of an S9 (start address) record instead, even if no 
  123.            start address is specified in the file with the END pseudo-
  124.            instruction.
  125.  
  126.    Commandline options can be catenated, but no other option can follow
  127.    one that may have a parameter.  Thus:
  128.       -tlfile
  129.    is correct (specifying symbol table and pass 2 listing), but
  130.       -h5t
  131.    is not.
  132.  
  133.    It is possible to discard any of the the output files by specifying
  134.    the name 'nul'.
  135.  
  136.  
  137. EXPRESSIONS
  138.  
  139.    The assembler recognizes most C-language expressions.  The operators
  140.    are listed here in order of precedence, highest first:
  141.  
  142.        ()            braces to group subexpressions
  143.        * $           current location counter
  144.        unary + - ! ~ unary + (no-operation), negation, logical NOT,
  145.                      binary NOT
  146.        * / %         multiplication, division, modulo
  147.        + -           addition, subtraction
  148.        << >>         shift left, shift right
  149.        < > <= >=     comparison for greater/less than
  150.        = !=          comparison for equality (== can be used for =)
  151.        &             binary AND
  152.        ^             binary XOR
  153.        |             binary OR
  154.        &&            logical AND
  155.        ||            logical OR
  156.  
  157.    The logical NOT (!) evaluates to zero if the parameter is nonzero,
  158.    and vice versa.  The binary NOT (~) complements all the bits in its
  159.    parameter.  Logical AND (&&) and OR (||) operators evaluate to one
  160.    if both resp. at least one argument is nonzero.  These two operators
  161.    evaluate both arguments, unlike the C-language versions.
  162.  
  163.    Note: the asterisk is both used as the multiplication operator, and
  164.    as symbol for the current location.  The assembler determines from
  165.    the context which is which. Thus:
  166.  
  167.        5**
  168.  
  169.    is a valid expression, evaluating to five times the current location
  170.    counter, and:
  171.  
  172.        2+*/2
  173.  
  174.    is too, evaluating to the current location counter divided by two, to
  175.    which two is added.  In the same way, the % sign is both used as the
  176.    modulo operator and the prefix for binary numbers.
  177.  
  178.    Numbers can be specified in any number base between 2 and 36.
  179.    Decimal numbers can be used without a prefix, hexadecimal numbers
  180.    can be prefixed by $, octal numbers by @, and binary numbers by %.
  181.    Other number bases can be used by using the following format:  
  182.       <base>#<number>, 
  183.    where the base is the number base to use (must be specified in 
  184.    decimal), and number is the value.  Thus:
  185.       1000    - decimal number, value 10*10*10=1000
  186.       %1000   - binary number, value 2*2*2=8
  187.       @1000   - octal number, value 8*8*8=512
  188.       $1000   - hexadecimal number, value 16*16*16=4096
  189.       2#1000  - binary number, value 2*2*2=8
  190.       4#1000  - base-4 number, value 4*4*4=64
  191.       7#1000  - base-7 number, value 7*7*7=343
  192.       36#1000 - base-36 number, value 36*36*36=444528
  193.    For number bases greater than 10, additional digits are represented
  194.    by letters, starting from A.  Both lower and upper case letters can
  195.    be used.
  196.       11#aa = 120
  197.       16#ff = 255
  198.       25#oo = 624
  199.       36#zz = 1295
  200.  
  201.  
  202. PSEUDO-INSTRUCTIONS
  203.  
  204.    align <expression>
  205.  
  206.       Align fills zero or more bytes with zeros until the new address
  207.       modulo <expression> equals zero.  If the expression is not present,
  208.       align fills zero or one bytes with zeros until the new address
  209.       is even.
  210.  
  211.       Example 1:
  212.                       align  256             ; continue assembly on the
  213.                                              ; next 256-byte page
  214.  
  215.       Example 2:
  216.                       align                  ; make sure table begins
  217.       Table           dw     1,2,3           ; on an even address
  218.  
  219.  
  220.  
  221.    bss
  222.  
  223.       Put all following data in the bss segment.  Only data pseudo-instructions 
  224.       can be used in the bss segment, and these only increment the location 
  225.       counter.  It is up to the programmer to initialize the bss segment.  The 
  226.       bss segment is especially meaningful in a ROM based system where
  227.       variables must be placed in RAM, and RAM is not automatically initialized.
  228.  
  229.       The assembler internally maintains three separate location counters,
  230.       one for the code segment, one for the data segment and one for the
  231.       uninitialized data segment.  The user is responsible for not overlapping
  232.       the segments by setting appropriate origins.  The code, data and bss
  233.       pseudo-instructions can be used to interleave code and data in the source
  234.       listing, while separating the three in the generated program.  The
  235.       assembler starts with the code segment if none is specified.
  236.  
  237.       Example:
  238.                      code
  239.                      org    $f000           ; Assuming 4 kbyte code ROM
  240.                      data                   ; with 2 kbyte program and
  241.                      org    $f800           ; 2 kbyte initialized data
  242.                      bss
  243.                      org    0               ; bss segment is in RAM
  244.  
  245.       Buffer         ds     100
  246.  
  247.                      code
  248.       Begin          ldx    #Table
  249.                      lda    ,x
  250.                      .
  251.                      .
  252.                      .
  253.  
  254.                      data
  255.       Table          db     1,2,3
  256.  
  257.                      code
  258.       MyFunc         ldx    #Table
  259.                      .
  260.                      .
  261.  
  262.    code
  263.  
  264.       Put all following assembled instructions and data in the code segment.
  265.       See BSS
  266.  
  267.  
  268.    data
  269.  
  270.       Put all following assembled instructions and data in the data segment.
  271.       See BSS
  272.  
  273.  
  274.    db <bytelist>
  275.  
  276.       Define bytes.  The bytes may be specified as expressions or strings,
  277.       and are placed in the current (code or data) segment.  This pseudo
  278.       instruction is similar to the Motorola-defined fcb and fcc pseudo-
  279.       instructions.
  280.  
  281.       Example:
  282.       Message         db     7,"Error",13,10,0
  283.  
  284.  
  285.    ds <expression>
  286.  
  287.       Define zero or more bytes empty space.  The specified number of
  288.       bytes are filled with zeros.  This pseudo-instruction is identical
  289.       to the Motorola-defined pseudo-instruction rmb.
  290.  
  291.       Example:
  292.                      ds     100             ; reserve 100 bytes here
  293.  
  294.  
  295.    dw <wordlist>
  296.  
  297.       Define words.  The words are placed in the current (code or data)
  298.       segment.  This pseudo-instruction is identical to the Motorola-
  299.       defined fcw and fdb pseudo-instructions.
  300.  
  301.       Example:
  302.                      ldb    Function        ; number of function
  303.                      ldx    #JumpTable
  304.                      lslb
  305.                      abx
  306.                      ldx    ,x
  307.                      jmp    ,x              ; jump to function
  308.  
  309.       JumpTable      dw     Function0
  310.                      dw     Function1
  311.                      dw     Function2
  312.  
  313.  
  314.    else
  315.  
  316.       The else pseudo-instruction can be used for if-then-else
  317.       constructions. It must be placed between an if and an endif
  318.       instruction.  For an example, see the if pseudo-instruction.
  319.  
  320.  
  321.    end <expression>
  322.  
  323.       The end pseudo-instruction is optional, and need not be used.  If
  324.       it is used, its optional operand specifies the staring address of
  325.       the program.  This address is displayed when the program is
  326.       assembled, and is also placed in the s-record output file.
  327.  
  328.       Example:
  329.                      end    Start
  330.  
  331.    endif
  332.  
  333.       The endif pseudo-instruction must be used to close an if-endif
  334.       or if-else-endif construction.  For an example, see the if
  335.       pseudo-instruction.
  336.  
  337.  
  338.    <label> equ <expression>
  339.  
  340.       The equ (equate) pseudo-instruction sets the specified label to
  341.       the value of the expression.  The label may not already exist.
  342.       Some programmers choose to use only upper-case identifiers for
  343.       labels defined in this way to differentiate them from addresses.
  344.  
  345.       Example:
  346.       ESCAPE          equ    27
  347.  
  348.  
  349.    fcb <bytelist>
  350.  
  351.       Define bytes (form constant byte).  The bytes may be specified
  352.       only as expressions, and are placed in the current (code or data)
  353.       segment.  This pseudo-instruction was originally defined
  354.       by Motorola and is similar to the db pseudo-instruction.
  355.  
  356.       Example:
  357.       Message        fcb    7
  358.                      fcc    "Error"
  359.                      fcb    13,10,0
  360.  
  361.  
  362.    fcc <string>
  363.  
  364.       Define bytes (form constant character).  The bytes may be
  365.       specified only as a string, and are placed in the current (code or
  366.       data) segment.  This pseudo-instruction was originally defined
  367.       by Motorola and is similar to the db pseudo-instruction.
  368.  
  369.  
  370.    fcw <wordlist>
  371.  
  372.       Define words (form constant word).  The words are placed in the
  373.       current (code or data) segment.  This pseudo instruction is
  374.       identical to the fdb and dw pseudo-instructions.
  375.  
  376.  
  377.    fdb <wordlist>
  378.  
  379.       Define words (form double byte).  The words are placed in the
  380.       current (code or data) segment.  This pseudo instruction is
  381.       identical to the fcw and dw pseudo-instructions.
  382.  
  383.  
  384.    if <expression>
  385.  
  386.       The if pseudo-instruction can be used in conjunction with the
  387.       endif and possibly the else pseudo-instructions to selectively
  388.       enable and disable pieces of code in the source.  If the expression
  389.       given evaluates to zero, then the following code up to the matching
  390.       else or endif is not included in the assembly.  If the expression
  391.       is nonzero, then the following code is included, but any code
  392.       between the matching else and endif is not.
  393.  
  394.       Example:
  395.                      if COUNT=2 | COUNT=4
  396.                      asla                   ; shift left for counts
  397.                      if COUNT=4             ; of 2 and 4
  398.                      asla
  399.                      endif
  400.                      else
  401.                      ldb     #COUNT         ; otherwise use slow
  402.                      jsr     Multiply       ; multiply subroutine
  403.                      endif
  404.  
  405.  
  406.    include <string>
  407.  
  408.       The named file is included in the assembly at this point.  After
  409.       it has been read, assembly continues with the next line of the
  410.       current file. Include files may be nested.
  411.  
  412.       Example:
  413.                      include "defines.i"
  414.  
  415.  
  416.    list
  417.  
  418.       Enable generation of the listing in the list-file.  If the listing
  419.       has been disabled twice, it must be enabled twice before it is
  420.       generated.  When no -p or -l option has been specified on the
  421.       command line, this pseudo-instruction has no effect.
  422.  
  423.  
  424.    nolist
  425.  
  426.       Disable generation of the listing in the list-file.
  427.  
  428.  
  429.    noopt
  430.  
  431.       Disable optimizations.  If the -n option has been specified on the
  432.       command line, this pseudo-instruction has no effect.
  433.  
  434.  
  435.    nop <expression>
  436.  
  437.       No operation.  When the optional expression is not present, this
  438.       is simply the nop instruction of the processor.  When the
  439.       expression is present, the specified number of nop instructions
  440.       are inserted.
  441.  
  442.       Example:
  443.                      nop    10
  444.  
  445.  
  446.    opt
  447.  
  448.       Enable optimizations.  If the -n option has been specified on the
  449.       command line, this pseudo-instruction has no effect.
  450.       When optimization is enabled, the assembler tries to use the
  451.       shortest and fastest instructions possible which have the effect
  452.       the user wants.  It may replace any extended-address instruction
  453.       by zero-page instructions.  It replaces jumps with branches or
  454.       jumps to zero page and zero-offset indexed instructions by no-offset
  455.       indexed instructions.  The effects of optimizations is clearly visible
  456.       if both a pass one and a pass two listing is generated.
  457.  
  458.  
  459.    org <expression>
  460.  
  461.       The org (origin) pseudo-instruction specifies the next address to
  462.       be used for assembly.  When no origin has been specified, the
  463.       assembler uses the value 0.  The assembler maintains three separate
  464.       location counters: one for the code segment, one for the data
  465.       segment, and one for the bss segment.  See the code and pseudo-
  466.       instruction for more information.
  467.  
  468.  
  469.    page <expression>
  470.  
  471.       When the optional expression is not present, the assembly listing
  472.       is continued on the next page.  When the expression is present,
  473.       the listing is continued on the next page only if the specified
  474.       number of lines do not fit on the current page.
  475.  
  476.  
  477.    rmb <expression>
  478.  
  479.       Define zero or more bytes empty space.  The specified number of
  480.       bytes are filled with zeros.  This pseudo-instruction is identical
  481.       to the pseudo-instruction ds.
  482.  
  483.  
  484.    <label> set <expression>
  485.    <label> = <expression>
  486.  
  487.       The set pseudo-instruction sets the specified label to the value
  488.       of the expression.  The label may or may not already exist.
  489.       Some programmers choose to use only upper-case identifiers for
  490.       labels defined in this way to differentiate them from addresses.
  491.  
  492.       Example:
  493.       CURRENT         set    0
  494.  
  495.                       .
  496.                       .
  497.                       .
  498.  
  499.       CURRENT         set    CURRENT+1
  500.  
  501.  
  502.    struct <name>
  503.    struct <name>,<expression>
  504.  
  505.       The struct (structure) pseudo-instruction can be used to define
  506.       data structures in memory more easily.
  507.  
  508.       The name of the structure is set to the total size of the structure;
  509.       if the expression is present, the starting offset is the value of
  510.       the expression in stead of zero.
  511.  
  512.       Between the struct and end struct pseudo-instructions the following
  513.       pseudo-instructions can be used: db, dw, ds, label, align.
  514.       Within structures these pseudo-instructions take a slightly different
  515.       format than normally:
  516.  
  517.          db <name>                element is one byte
  518.  
  519.          dw <name>                element is two bytes
  520.  
  521.          ds <name>,<expression>   element is the specified number of bytes
  522.  
  523.          ds <expression>          skip the specified number of bytes
  524.  
  525.          label <name>             element is zero bytes, i.e. set the name
  526.                                   to the current structure offset
  527.  
  528.          align <expression>       skip until (offset%expression)=0
  529.  
  530.          align                    skip until offset is even
  531.  
  532.  
  533.       Example:
  534.                      struct ListNode,4
  535.                      dw     LN_Next
  536.                      dw     LN_Previous
  537.                      db     LN_Type
  538.                      align
  539.                      label  LN_Simple       ; size of structure so far
  540.                      align  8
  541.                      ds     LN_Data,10
  542.                      end struct
  543.  
  544.       This is identical to:
  545.  
  546.       LN_Next        equ     4       ;\
  547.       LN_Previous    equ     6       ; offset of structure elements
  548.       LN_Type        equ     8       ;/
  549.       LN_Simple      equ     10      ; size of structure so far
  550.       LN_Data        equ     16      ; offset of structure element
  551.       ListNode       equ     26      ; size of structure
  552.  
  553.  
  554.    title <string>
  555.  
  556.       The title pseudo-instruction sets the title to be used in the
  557.       header of each listing page.  The string should be no longer than
  558.       80 characters.
  559.  
  560.       Example:
  561.                    title  "DIS02 : A disassembler for a 6802 CPU"
  562.  
  563.  
  564. ADDRESSING MODES
  565.    The assembler allows all 6800/6801/6802/6803 addressing modes.
  566.  
  567.    List of available modes:
  568.       address
  569.       ,x
  570.       offset,x  (where offset is between 0 and 255)
  571.  
  572.  
  573. LIST OF ACCEPTED INSTRUCTIONS
  574.    aba abx adca adcb adda addb addd align anda andb asl asla aslb asld
  575.    asr asra asrb bcc bcs beq bge bgt bhi bhs bita bitb ble blo bls blt bmi
  576.    bne bpl bra brn bsr bss bvc bvs cba clc cli clr clra clrb clv cmpa cmpb
  577.    code com coma comb cpx daa data db dd dec deca decb des dex disable ds
  578.    dw else enable end endif eora eorb equ fcb fcc fcw fdb if inc inca incb
  579.    include ins inx jmp jsr lda ldaa ldab ldad ldb ldd lds ldx list lsl
  580.    lsla lslb lsld lsr lsra lsrb lsrd mul neg nega negb nolist noopt nop
  581.    opt ora oraa orab orb org page psha pshb pshx pula pulb pulx rmb rol
  582.    rola rolb ror rora rorb rti rts sba sbca sbcb sec sei set sev sta staa
  583.    stab stad stb stc std sti struct sts stv stx suba subb subd swi tab
  584.    tap tba title tpa tst tsta tstb tsx txs wai
  585.  
  586.    Of these instructions, the following are (more or less) synonymous,
  587.    and can be used interchangably.
  588.    YOU CAN USE     WHERE YOU WOULD PREVIOUSLY USE
  589.       disable   -  sei
  590.       enable    -  cli
  591.       lda       -  ldaa
  592.       ldb       -  ldab
  593.       ldd       -  ldad
  594.       nop 6     -  nop nop nop ....
  595.       ora       -  oraa
  596.       orb       -  orab
  597.       sta       -  staa
  598.       stb       -  stab
  599.       std       -  stad
  600.       stc       -  sec
  601.       sti       -  sei
  602.       stv       -  sev
  603.       xora      -  eora
  604.       xorb      -  eorb
  605.  
  606.    And pseudo-instructions:
  607.       db        -  fcb, fcc
  608.       dw        -  fcw, fdb
  609.       ds        -  rmb
  610.       =         -  set
  611.       struct    -  lots of EQUs
  612.  
  613.  
  614. LIST OF OTHER KEYWORDS
  615.    !  !=  #  %  &  &&  (  )  *  +  ++  ,  -  --  /  <
  616.    <<  <=  =  >  >=  >>  [  ]  ^  |  ||  ~  x
  617.  
  618.  
  619. FILES
  620.    <file>.a02 - source file.
  621.    <file>.asm - source file -- alternative.
  622.    <file>.lst - List file.
  623.    <file>.s19 - Motorola S-records output file.
  624.    <file>.hex - Intel hex output file.
  625.    <file>.bin - Binary output file.
  626.  
  627.  
  628. BUGS
  629.    No provision for linking other pre-assembled modules is made.
  630.  
  631.  
  632. RETURNS
  633.    As02 returns one of the following values:
  634.  
  635.       0 - Source file assembled without errors.
  636.       1 - Incorrect parameter specified on the commandline.
  637.       2 - Unable to open input or output file.
  638.       3 - Assembly gave errors.
  639.       4 - No memory could be allocated.
  640.  
  641.  
  642. DIAGNOSTICS
  643.    Help message if only parameter is a question mark, or if an
  644.    illegal option has been specified.
  645.  
  646.  
  647. AUTHOR
  648.    This is copyrighted software, but may be distributed freely as long
  649.    as this document accompanies the assembler, and no copyright messages
  650.    are removed.  You are explicitly NOT allowed to sell this software
  651.    for anything more than a reasonable copying fee, say US$5.
  652.    To contact the author:
  653.       Frank A. Vorstenbosch
  654.       Kingswood Software
  655.       P.O. Box 85800              Phone: +31-(70)-355 5241
  656.       2508CM  The Hague           BBS:   +31-(70)-355 8674
  657.       Netherlands                 Email: falstaff@xs4all.nl
  658.  
  659. -------------------------------------------------------------------------
  660.