home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / AS05_107 / AS05.MAN < prev    next >
Text File  |  1994-11-22  |  23KB  |  641 lines

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