home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d7xx / d717 / adev11.lha / ADev11 / docs / SAsm.doc < prev    next >
Text File  |  1992-08-20  |  18KB  |  493 lines

  1. now accepts character constants of
  2.        'c
  3.   and  'c'
  4.  
  5. NAME
  6.  
  7.     DAsm
  8.  
  9. SYNOPSIS
  10.  
  11.         SAsm [options] <srcfile> [options]
  12.  
  13. DESCRIPTION
  14.  
  15. SAsm is the assembler for the DEV11 system. It is a high level macro cross
  16. assembler for the Motorola 6803, 6805 and 68HC11 families and for the
  17. Hitachi 6303 family. It is a highly modified version of the publicly
  18. distributable DASM V2.12.
  19.  
  20.     (C)Copyright 1987,1988 Matthew Dillon, All Rights Reserved
  21.     (C)Copyright 1992      Stan Burton, All Rights Reserved
  22.  
  23.     Publicly distributable for non-profit only.  Must be distributed
  24.     as is, with NO CHANGES to the documentation or code.
  25.  
  26.  
  27.     -fast assembly
  28.     -supports several common 8 bit processor models (NOT 8086, thank god!)
  29.     -optionally takes as many passes as needed
  30.     -generates relocatable object module output for use with SLink and SLib.
  31.     -XREF and XDEF pseudo ops for external module references.
  32.     -multiple segments, BSS segments (no generation).
  33.     -expressions, as in C. (all expressions are computed with 32 bit
  34.         integers)
  35.     -no real limitation on label size, label values are 32 bits.
  36.     -complex pseudo ops, repeat loops, macros, etc....
  37.  
  38.  
  39. COMMAND LINE:
  40.  
  41.         asm [options] srcfile [options]
  42.  
  43.         srcfile:    if no extension is specified in the name, .a is added
  44.  
  45.         options:    -l[name]  generate list file, if no name is specified
  46.                         extension-less srcfile with .lst extension is used
  47.                     -s[name]  generate symbol file, if no name is specified
  48.                         extension-less srcfile with .sym extension is used
  49.                     -v#       select verboseness 0-4 (default 0, see below)
  50.                     -p#       select number of passes 2-9 (default 2)
  51.                     -d              debug mode
  52.                     -DSYMBOL                    predefine a symbol, set to 0
  53.                     -DSYMBOL=EXPRESSION     predefine a symbol, set to exp
  54.  
  55.         outfile:    the file generated is the extension-less srcfile with
  56.                         a .o extension
  57.  
  58.         Example:    asm master.asm -lram:list -v3 -DVER=4
  59.  
  60. The options list can contain any of the following, separated by spaces:
  61.  
  62. -v  0        (default)
  63.         Only warnings and errors are generated
  64.  
  65.     1
  66.         -Segment list information generated after each pass
  67.         -Include file names are displayed
  68.         -statistics on why the assembler is going to make another pass
  69.             R1,R2 reason code: R3
  70.             where R1 is the number of times the assembler encountered
  71.             something requiring another pass to resolve.  R2 is the
  72.             number of references to unknown symbols which occured in the
  73.             pass (but only R1 determines the need for another pass).  R3
  74.             is a BITMASK of the reasons why another pass is required.
  75.             See the end of this document for bit designations.
  76.  
  77.     2
  78.         mismatches between program labels and equates are displayed
  79.         on every pass (usually none occur in the first pass unless you
  80.         have re-declared a symbol name).
  81.  
  82.         displayed information for symbols:
  83.             ???? = unknown value
  84.             str  = symbol is a string
  85.             eqm  = symbol is an eqm macro
  86.             (r)  = symbol has been referenced
  87.             (s)  = symbol created with SET or EQM pseudo-op
  88.  
  89.     3
  90.             Unresolved and unreferenced symbols are displayed every pass
  91.             (unsorted, sorry)
  92.  
  93.     4
  94.             An entire symbol list is displayed every pass to STDOUT.
  95.             (unsorted, sorry)
  96.  
  97. PROCESSOR MODEL:
  98.  
  99.     The processor model is chosen with the PROCESSOR pseudo-op and should
  100.     be the first thing you do in your assembly file.
  101.  
  102.     Only one PROCESSOR pseudo-op may be declared in the entire assembly,
  103.     and should be the first thing encountered.
  104.  
  105.         -68HC11
  106.         -68705
  107.         -6803
  108.         -HD6303
  109.     -68HC16
  110.  
  111. SEGMENTS:
  112.     The SEG pseudo-op creates/sets the current segment.  Segments are used
  113.     to separate the various parts of a program, for example CODE and
  114.     BSS_DATA; later the linker could place the CODE at the EPROM address
  115.     range and the data at the ram address range. The use of DS or RMB
  116.     statements in a segment planned for ROM is not logical.
  117.  
  118.     As a result of the use of relocatable segments the ORG statement found
  119.     in simpler assemblers is not used; its functionality is passed to the
  120.     linker.
  121.  
  122.     'Uninitialized' (.U) segments do not produce output.  Therefore, output
  123.     generating statements are not allowed in these segments.
  124.  
  125. GENERAL:
  126.     Most everything is recursive.  You cannot have a macro DEFINITION
  127.     within a macro definition, but can nest macro calls, repeat loops,
  128.     and include files.
  129.  
  130. ?    The other major feature in this assembler is the SUBROUTINE pseudo-op,
  131.     which logically separates local labels (starting with a dot).  This
  132.     allows you to reuse label names (for example, .1 .fail) rather than
  133.     think up crazy combinations of the current subroutine to keep it all
  134.     unique.
  135.  
  136.     By default the assembler will make 2 passes, if your file requires
  137.     more passes you can set the number via an option.
  138.  
  139.  
  140. PSEUDOPS:
  141.  
  142.         INCLUDE     "name"
  143.  
  144.             Include another assembly file.
  145.  
  146. [label] SEG[.U]     name
  147. [label] RSEG[.U]    name
  148.  
  149.             This sets the current segment, creating it if neccessary.  If
  150.             a .U extension is specified on segment creation, the segment
  151.             is an UNINITIALIZED segment.  The .U is not needed when going
  152.             back to an already created uninitialized segment, though it
  153.             makes the code more readable.
  154.  
  155. [label] DC[.BWL]    exp,exp,exp ...
  156. [label] FDB         exp,exp,exp ...
  157. [label] FCB         exp,exp,exp ...
  158.  
  159.             Declare data in the current segment.
  160.  
  161.             The default size extension for DC is a byte.
  162.  
  163. [label] DS[.BWL]    exp[,filler]
  164. [label] RMB         exp[,filler]
  165.  
  166.             Declare space (default filler is 0). Data is not generated if
  167.             within an uninitialized segment.  Note that the number of bytes
  168.             generated is exp * entrysize (1,2, or 4)
  169.  
  170.             The default size extension for DS is a byte.
  171.  
  172.             Note that the default filler is always 0.
  173.  
  174. [label] DV[.BWL]    eqmlabel exp,exp,exp....
  175.  
  176.             This is equivalent to DC, but each exp in the list is passed
  177.             through the symbolic expression specified by the EQM label.
  178.             The expression is held in a special symbol dotdot '..' on each
  179.             call to the EQM label.
  180.  
  181.             See EQM below
  182.  
  183. [label] HEX            hh hh hh..
  184.  
  185.             This sets down raw HEX data.  Spaces are optional between bytes.
  186.             NO EXPRESSIONS are allowed.  Note that you do NOT place a $
  187.             in front of the digits.  This is a short form for creating
  188.             tables compactly.  Data is always layed down on a byte-by-byte
  189.             basis.
  190.  
  191.             Example:            HEX 1A45 45 13254F 3E12
  192.  
  193.         ERR
  194.  
  195.             Abort assembly.
  196.  
  197. [label] XDEF symbol,symbol,symbol
  198.  
  199.             Defines which symbols/labels are available outside of this
  200.             module.
  201.  
  202. [label] XREF symbol,symbol,symbol
  203.  
  204.             Declares which symbols/labels from outside modules are used
  205.             in this module.
  206.  
  207.         PROCESSOR model
  208.  
  209.             Do not quote.  Model is one of: 6803,HD6303,68705,68HC11
  210.             Can only be executed once, and should be the first thing
  211.             encountered by the assembler.
  212.  
  213.         ECHO exp,exp,exp
  214.  
  215.             The expressions (which may also be strings), are echod on the
  216.             screen and into the list file
  217.  
  218. [label] ALIGN            N[,fill]
  219.  
  220.             Align the current PC to an N byte boundry.        The default
  221.             fill character is always 0, and has nothing to do with
  222.             the default fill character specifiable in an ORG.
  223.  
  224. [label] SUBROUTINE  name
  225.  
  226.             This isn't really a subroutine, but a boundry between sets of
  227.             temporary labels (which begin with a dot).  Temporary label
  228.             names are unique within segments of code bounded by SUBROUTINE:
  229.  
  230.                 CHARLIE subroutine
  231.                         ldx #10
  232.                 .1        dex
  233.                         bne .1
  234.                 BEN        subroutine
  235.                         ldx #20
  236.                 .qq        dex
  237.                         bne .qq
  238.  
  239.             Automatic temporary label boundries occur for each macro level.
  240.             Usually temporary labels are used in macros and within actual
  241.             subroutines (so you don't have to think up a thousand different
  242.             names)
  243.  
  244.  
  245. symbol        EQU            exp
  246.  
  247.             The expression is evaluated and the result assigned to the
  248.             symbol.
  249.  
  250. symbol        EQM            exp
  251.  
  252.             The STRING representing the expression is assigned to the
  253.             symbol.  Occurances of the symbol in later expressions causes
  254.             the string to be evaluated for each occurance.  Also used in
  255.             conjuction with the DV psuedo-op.
  256.  
  257. symbol        SET            exp
  258.  
  259.             Same as EQU, but the symbol may be reassigned later.
  260.  
  261.         END            [symbol]
  262.  
  263.             Optional. If used with a symbol name the value of that
  264.             symbol will be entered into the output file as the
  265.             starting address of the program.  May only be used once
  266.             and only at the end of the file.  Be careful - if a
  267.             symbol is not given and a comment without a preceding ';'
  268.             is used the first word of the comment will be interpreted
  269.             as the symbol.
  270.  
  271.         MAC            name
  272.         MACRO          name
  273.  
  274.             Declare a macro.  lines between MAC and ENDM are the macro.
  275.             You cannot recursively declare a macro.  You CAN recursively
  276.             use a macro (reference a macro in a macro).  No label is
  277.             allowed to the left of MAC or ENDM.
  278.  
  279.             Arguments passed to macros are referenced with: {#}.  The first
  280.             argument passed to a macro would thus be {1}.  You should
  281.             always use LOCAL labels (.name) inside macros which you use
  282.             more than once. {0} represents an EXACT substitution of the
  283.             ENTIRE argument line.
  284.  
  285.         ENDM
  286.  
  287.             end of macro def.  NO LABEL ALLOWED ON THE LEFT!
  288.  
  289.         MEXIT
  290.  
  291.             Used in conjuction with conditionals.  Exits the current macro
  292.             level.
  293.  
  294. [label] IFCONST     exp
  295. [label] IFD    exp
  296.  
  297.             Is TRUE if the expression result is defined,  FALSE otherwise
  298.             and NO error is generated if the expression is undefined.
  299.  
  300. [label] IFNCONST    exp
  301. [label] IFND        exp
  302.  
  303.             Is TRUE if the expression result is undefined, FALSE otherwise
  304.             and NO error is generated if the expression is undefined.
  305.  
  306. [label] IF            exp
  307.  
  308.             Is TRUE if the expression result is defined AND non-zero.
  309.             Is FALSE if the expression result is defined AND zero.
  310.             Neither IF or ELSE will be executed if the expression result
  311.             is undefined.  If the expression is undefined, another assembly
  312.             pass is automatically taken.
  313.  
  314. [label] ELSE
  315.  
  316.             ELSE the current IF.
  317.  
  318. [label] ENDIF
  319. [label] ENDC
  320. [label] EIF
  321.  
  322.             Terminate an IF. ENDIF and EIF are equivalent.
  323.  
  324. [label] REPEAT            exp
  325. [label] REPEND
  326.  
  327.             Repeat code between REPEAT/REPEND 'exp' times.  if exp == 0,
  328.             the code repeats forever.  exp is evaluated once.
  329.  
  330.                 Y   SET     0
  331.                     REPEAT  10
  332.                 X   SET     0
  333.                     REPEAT  10
  334.                     DC            X,Y
  335.                 X   SET     X + 1
  336.                     REPEND
  337.                 Y   SET     Y + 1
  338.                     REPEND
  339.  
  340.             generates an output table:        0,0 1,0 2,0 ... 9,0  0,1 1,1 2,1
  341.             ... 9,1, etc...
  342.  
  343.             Labels within a REPEAT/REPEND should be temporary labels with a
  344.             SUBROUTINE pseudoop to keep them unique.
  345.  
  346.             The Label to the left of REPEND is assigned AFTER the loop
  347.             FINISHES.
  348.  
  349.  
  350. [label] XXX[.force] operand
  351.  
  352.             XXX is some mnemonic, not necessarily three characters long.
  353.             The .FORCE optional extension is used to force specific
  354.             addressing modes (see below).
  355.  
  356. GENERAL:
  357.  
  358.     The label will be set to the current segment counter either before or
  359.     after a pseudo-op is executed.  Most of the time, the label is set
  360.     before the pseudo-op is executed. The following pseudo-op's
  361.     labels are created AFTER execution of the pseudo-op:
  362.  
  363.         SEG, ALIGN
  364.  
  365. EXTENSIONS:
  366.  
  367.     FORCE extensions are used to force an addressing mode.  Force
  368.     extensions are also used with DS,DC, and DV to determine the element
  369.     size.  NOT ALL EXTENSIONS APPLY TO ALL PROCESSORS!
  370.  
  371.         example:    lda.z   charlie
  372.  
  373.         i   -implied
  374.         ind -indirect word
  375.         0   -implied
  376.         0x  -implied indexing (0,x)
  377.         0y  -implied indexing (0,y)
  378.         b   -byte address
  379.         bx  -byte address indexed x
  380.         by  -byte address indexed y
  381.         w   -word address
  382.         wx  -word address indexed x
  383.         wy  -word address indexed y
  384.         l   -longword (4 bytes) (DS/DC/DV)
  385.         r   -relative
  386.         u   -uninitialized (SEG)
  387.  
  388.         First character equivalent substitutions:
  389.  
  390.         b z d            (byte, zeropage, direct)
  391.         w e a            (word, extended, absolute)
  392.  
  393.  
  394. EXPRESSIONS:
  395.         Some operators, such as ||, can return a resolved value even if
  396.         one of the expressions is not resolved.   Operators are as follows:
  397.  
  398.         NOTE WELL!  Some operations will result in non-byte values when a
  399.         byte value was wanted.        For example:        ~1  is NOT $FF, but
  400.         $FFFFFFFF.  Preceding it with a < (take LSB of) will solve the
  401.         problem.  ALL ARITHMETIC IS CARRIED OUT IN 32 BITS.  The final
  402.         Result will be automatically truncated to the maximum handleable
  403.         by the particular machine language (usually a word) when applied
  404.         to standard mnemonics.
  405.  
  406.         prec            UNARY
  407.  
  408.         20  ~exp    one's complement.
  409.         20  -exp    negation
  410.         20  !exp    not expression (returns 0 if exp non-zero, 1 if exp zero)
  411.         20  <exp    take LSB byte of a 16 bit expression
  412.         20  >exp    take MSB byte of an expression
  413.  
  414.                     BINARY
  415.  
  416.         19  *            multiplication
  417.         19  /            division
  418.         19  %            mod
  419.         18  +            addition
  420.         18  -            subtraction
  421.         17  >>,<<   shift right, shift left
  422.         16  >,>=    greater, greater equal
  423.         16  <,<=    smaller, smaller equal
  424.         15  ==            equal to.  Try to use this instead of =
  425.         15  =            exactly the same as == (exists compatibility)
  426.         15  !=            not equal to
  427.         14  &            logical and
  428.         13  ^            logical xor
  429.         12  |            logical or
  430.         11  &&            left expression is true AND right expression is true
  431.         10  ||            left expression is true OR right expression is true
  432.          9  ?            if left expression is true, result is right expression,
  433.                     else result is 0.        [10 ? 20] returns 20
  434.          8  []            group expressions
  435.          7  ,            separate expressions in list (also used in
  436.                     addressing mode resolution, BE CAREFUL!
  437.  
  438.     Constants:
  439.  
  440.         nnn        decimal
  441.         0nnn        octal
  442.         %nnn        binary
  443.         $nnn        hex
  444.         'c      character
  445.         'c'      character
  446.         "cc.."  string (NOT zero terminated if in DC/DS/DV)
  447.         [exp]d        the constant expressions is evaluated and it's decimal
  448.                 result turned into an ascii string.
  449.  
  450.     Symbols:
  451.  
  452.         ..        -holds evaluated value in DV pseudo op
  453.         .name        -represents a temporary symbol name.  Temporary symbols
  454.                  may be reused inside MACROS and between SUBROUTINES, but
  455.                  may not be referenced across macros or across SUBROUTINEs.
  456.         .        -current program counter (as of the beginning of the
  457.                  instruction).
  458.         name        -beginning with an alpha character and containing letters,
  459.                  numbers, or '_'.  Represents some global symbol name.
  460.  
  461.  
  462. WHY codes:
  463.     Each bit in the WHY word (verbose option 1) is a reason (why
  464.     the assembler needs to do another pass), as follows:
  465.  
  466.     bit 0   expression in mnemonic not resolved
  467.         1   -
  468.         2   expression in a DC not resolved
  469.         3   expression in a DV not resolved (probably in DV's EQM symbol)
  470.         4   expression in a DV not resolved (could be in DV's EQM symbol)
  471.         5   expression in a DS not resolved
  472.         6   expression in an ALIGN not resolved
  473.         7   ALIGN: Relocatable origin not known (impossible -Stan)
  474.         8   ALIGN: Normal origin not known        (if in ORG at the time)
  475.         9   EQU:   expression not resolved
  476.         10  EQU:   value mismatch from previous pass (phase error)
  477.         11  IF:     expression not resolved
  478.         12  REPEAT: expression not resolved
  479.  
  480.         13  a program label has been defined after it has been
  481.             referenced (forward reference) and thus we need another
  482.             pass
  483.         14  a program label's value is different from that of the
  484.             previous pass (phase error)
  485.  
  486.     Certain errors will cause the assembly to abort immediately, others
  487.     will wait until the current pass is over.        The remaining allow another
  488.     pass to occur in the hopes the error will fix itself.
  489.  
  490.  
  491. VERSIONS:
  492.  
  493.