home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 500 / 470 / rccl007 < prev    next >
Text File  |  1987-03-02  |  31KB  |  776 lines

  1.  
  2.             UNIX Assembler Reference Manual
  3.  
  4.                Dennis M. Ritchie
  5.  
  6.                Bell Laboratories
  7.             Murray Hill, New Jersey
  8.  
  9.  
  10.  
  11.    0.  Introduction
  12.  
  13.    This document describes the usage and  input  syntax  of  the  UNIX  PDP-11
  14.    assembler as.  The details of the PDP-11 are not described; consult the DEC
  15.    documents PDP-11/20 Handbook and PDP-11/45 Handbook.
  16.  
  17.    The input syntax of the UNIX assembler is generally similar to that of  the
  18.    DEC assembler PAL-11R, although its internal workings and output format are
  19.    unrelated.  It may be useful to read the publication  DEC-11-ASDB-D,  which
  20.    describes   PAL-11R,  although naturally one must use care in assuming that
  21.    its rules apply to as.
  22.  
  23.    As is a rather ordinary two-pass assembler without macro capabilities.  It
  24.    produces  an  output  file  which  contains  relocation  information and a
  25.    complete symbol table; thus the output is acceptable  to  the  UNIX  link-
  26.    editor  ld,  which  may be used to combine the outputs of several assembler
  27.    runs and to obtain object programs from libraries.  The output  format  has
  28.    been  designed  so  that  if a program contains no unresolved references to
  29.    external symbols, it is executable without further processing.
  30.  
  31.    1.  Usage
  32.  
  33.    as is used as follows:
  34.  
  35.      as  [  -  ]  file
  36.  
  37.    If the optional '-' argument is given, all undefined symbols in the current
  38.    assembly will be made undefined external.  See the .globl directive below.
  39.  
  40.    The other arguments name files which are concatenated and assembled.  Thus
  41.    programs may be written in several pieces and assembled together.
  42.  
  43.    The output of the assembler is placed on the  file  a.out  in  the  current
  44.    directory.  If  there were no unresolved external references, and no errors
  45.    detected, a.out is made executable; otherwise, if it is produced at all, it
  46.    is made non-executable.
  47.  
  48.    2.  Lexical conventions
  49.  
  50.    Assembler tokens include identifiers  (alternatively,  symbols  or  names),
  51.    temporary symbols, constants, and operators.
  52.  
  53.    2.1  Identifiers
  54.  
  55.    An identifier consists of a sequence of alphanumeric characters  (including
  56.    period  '.'  , underscore '_' , and tilde '~' as alphanumeric) of which the
  57.    first may not be numeric.  Only the first eight characters are significant.
  58.    When a name begins with a tilde, the tilde is discarded and that occurrence
  59.    of the identifier generates a unique entry in the symbol  table  which  can
  60.    match no other occurrence of the identifier.  This feature is used by the C
  61.    compiler to place names of local  variables  in  the  output  symbol  table
  62.    without having to worry about making them unique.
  63.  
  64.    2.2  Temporary symbols
  65.  
  66.    A temporary symbol consists of a digit followed by f or Temporary  symbols
  67.    are discussed fully in 5.1.
  68.  
  69.    2.3  Constants
  70.  
  71.    An octal constant consists of a sequence of digits; 8 and The  constant  is
  72.    truncated to 16 bits and interpreted in two's complement notation.
  73.  
  74.    A decimal constant consists of a sequence of digits terminated by a decimal
  75.    point  '.'.  The  magnitude  of  the constant should be representable in 15
  76.    bits; i.e., be less than 32,768.
  77.  
  78.    A single-character constant consists of a single quote ''' followed  by  an
  79.    ASCII  character  not  a new-line.  Certain dual character escape sequences
  80.    are acceptable in place of the ASCII character to  represent  new-line  and
  81.    other  non-graphics (see String statements, 5.5).  The constant's value has
  82.    the code for the given character in the least significant byte of the  word
  83.    and is null-padded on the left.
  84.  
  85.    A double-character constant consists of a double quote '"'  followed  by  a
  86.    pair  of  ASCII  characters not including new-line.  Certain dual-character
  87.    escape sequences are acceptable in place of either of the ASCII  characters
  88.    to  represent new-line and other non-graphics (see String statements, 5.5).
  89.    The constant's value has the code for the  first  given  character  in  the
  90.    least  significant  byte  and  that  for  the  second character in the most
  91.    significant byte.
  92.  
  93.    2.4  Operators
  94.  
  95.    There are several single- and double-character operators; see 6.
  96.  
  97.    2.5  Blanks
  98.  
  99.    Blank and tab characters may be interspersed freely between to tokens , but
  100.    may not be used within tokens (except character constants).  A blank or tab
  101.    is required to separate adjacent identifiers  or  constants  not  otherwise
  102.    separated.
  103.  
  104.    2.6  Comments
  105.  
  106.    The character '/' introduces a comment, which extends through  the  end  of
  107.    the line on which it appears.  Comments are ignored by the assembler.
  108.  
  109.    3.  Segments
  110.  
  111.    Assembled code and data fall into three segments: the  text  seg-ment,  the
  112.    data  segment,  and  the bss segment.  The text segment is the one in which
  113.    the assembler begins, and  it  is  the  one  into  which  instructions  are
  114.    typically  placed.  The UNIX system will, if desired, enforce the purity of
  115.    the text segment of programs by trapping write operations into  it.  Object
  116.    programs  produced by the assembler must be processed by the link-editor ld
  117.    (using its '_' flag) if the  text  segment  is  to  be  write-protected.  A
  118.    single  copy  of  the  text segment is shared among all processes executing
  119.    such a program.
  120.  
  121.    The data segment is available for placing data or instructions  which  will
  122.    be  modified  during  execution.  Anything which may go in the text segment
  123.    may be put into  the  data  segment.  In  pro-grams  with  write-protected,
  124.    sharable  text segments, data segment contains the initialized but variable
  125.    parts of a program.  If the text segment is  not  pure,  the  data  segment
  126.    begins immediately after the text segment; if the text segment is pure, the
  127.    data segment begins at the lowest 8K byte boundary after the text seg-ment.
  128.  
  129.    The bss segment may not contain any explicitly initialized  code  or  data.
  130.    The  length of the bss segment (like that of text or data) is determined by
  131.    the high-water mark of the location counter within it.  The bss segment  is
  132.    actually  an extension of the data segment and begins immediately after it.
  133.    At the start of execution of a program,  the  bss  segment  is  set  to  0.
  134.    Typically the bss segment is set up by statements exemplified by
  135.  
  136.        lab: . = .+10
  137.  
  138.    The advantage in using the bss segment for storage that starts off empty is
  139.    that  the initialization information need not be stored in the output file.
  140.    See also Location counter and Assignment statements below.
  141.  
  142.    4.  The location counter
  143.  
  144.    One special symbol, '.', is the location counter.  Its value at any time is
  145.    the  offset within the appropriate segment of the start of the statement in
  146.    which it appears.  The location  counter  may  be  assigned  to,  with  the
  147.    restriction that the current segment may not change; furthermore, the value
  148.    of '.' may not de-crease.  If the effect of the assignment is  to  increase
  149.    the  value of '.', the required number of null bytes are generated (but see
  150.    Segments above).
  151.  
  152.    5.  Statements
  153.  
  154.    A source program is composed of a sequence of  statements.  Statements  are
  155.    separated  either  by  new-lines or by semicolons.  There are five kinds of
  156.    statements: null statements, expression statements, assignment  statements,
  157.    string statements, and keyword statements.
  158.  
  159.    Any kind of statement may be preceded by one or more labels.
  160.  
  161.    5.1  Labels
  162.  
  163.    There are two kinds of label: name labels and numeric labels.  A name label
  164.    consists  of a name followed by a colon ':'.  The effect of a name label is
  165.    to assign the current value and type of the location  counter  '.'  to  the
  166.    name.  An  error  is indicated in pass 1 if the name is already defined; an
  167.    error is indicated in  pass  2  if  the  '.'  value  assigned  changes  the
  168.    definition of the label.
  169.  
  170.    A numeric label consists of a digit 0 to 9 followed by a colon ':'.  Such a
  171.    label  serves to define temporary symbols of the form Nb and Nf, where N is
  172.    the digit of the label.  As in the case of name  labels,  a  numeric  label
  173.    assigns  the  current  value  and  type  of  '.'  to  the temporary symbol.
  174.    However, several numeric labels with the same digit may be used within  the
  175.    same  assembly.  References of the form Nf refer to the first numeric label
  176.    N: forward  from the reference; backward from the reference.  This sort  of
  177.    temporary  label  was introduced by Knuth [The Art of Computer Programming,
  178.    Vol I:  Fundamental Algorithms].  Such labels tend  to  conserve  both  the
  179.    symbol  table  space  of  the  assembler  and  the  inventive powers of the
  180.    programmer.
  181.  
  182.    5.2  Null statements
  183.  
  184.    A null statement is an empty statement (which may, however,  have  labels).
  185.    A  null  statement  is  ignored  by the assembler.  Common examples of null
  186.    statements are empty lines or lines containing only a label.
  187.  
  188.    5.3  Expression statements
  189.  
  190.    An expression statement consists of an arithmetic expression not  beginning
  191.    with a keyword.  The assembler computes its (16-bit) value and places it in
  192.    the output stream, together with the appropriate relocation bits.
  193.  
  194.    5.4  Assignment statements
  195.  
  196.    An assignment statement consists of an identifier, an equals sign '=',  and
  197.    an  expression.  The  value  and type of the expression are assigned to the
  198.    identifier.  It is not required that the type or value be the same in  pass
  199.    2 as in pass 1, nor is it an error to redefine any symbol by assignment.
  200.  
  201.    Any external attribute of the expression is  lost  across  an  assignment.
  202.    This  means that it is not possible to declare a global symbol by assigning
  203.    to it, and that it is impossible to define a symbol to  be  offset  from  a
  204.    non-locally defined global symbol.
  205.  
  206.    As mentioned, it is permissible to assign to the location counter '.' .  It
  207.    is  required,  however, that the type of the expression  assigned be of the
  208.    same type as '.', and it is forbidden to decrease the value  of  '.'  .  In
  209.    practice,  the  most common assignment to . has the form for some number n;
  210.    this has the effect of generating n null bytes.
  211.  
  212.    5.5  String statements
  213.  
  214.    A  string  statement  generates  a  sequence  of  bytes  containing   ASCII
  215.    characters.  A  string  statement  consists  of  a  left  string  quote '<'
  216.    followed by a sequence of ASCII characters not including newline,  followed
  217.    by  a  right string quote '>'.  Any of the ASCII characters may be replaced
  218.    by a  two-character  escape  se-quence  to  represent  certain  non-graphic
  219.    characters, as follows:
  220.  
  221.        \n NL (012)
  222.        \t HT (011)
  223.        \e EOT (004)
  224.        \0 NUL (000)
  225.        \r CR (015)
  226.        \a ACK (006)
  227.        \p PFX (033)
  228.        \\ \
  229.        \> >
  230.  
  231.    The last two are included so that the escape character and the right string
  232.    quote  may  be  represented.  The  same  escape  sequences may also be used
  233.    within single- and double-character constants (see 2.3 above).
  234.  
  235.    5.6  Keyword statements
  236.  
  237.    Keyword statements are numerically the most common type, since most machine
  238.    instructions  are of this sort.  A keyword statement begins with one of the
  239.    many predefined keywords of the assembler;  the  syntax  of  the  remainder
  240.    depends on the keyword.  All the keywords  are listed below with the syntax
  241.    they require.
  242.  
  243.    6.  Expressions
  244.  
  245.    An  expression  is  a  sequence  of  symbols  representing  a  value.   Its
  246.    constituents  are identifiers, constants, temporary symbols, operators, and
  247.    brackets.  Each expression has a type.
  248.  
  249.    All operators in expressions are fundamentally  binary  in  nature;  if  an
  250.    operand  is  missing  on  the  left,  a  0  of  absolute  type is  assumed.
  251.    Arithmetic  is  two's  complement  and  has  16  bits  of  precision.   All
  252.    operators  have  equal  precedence,  and expressions are evaluated strictly
  253.    left to right except for the effect of brackets.
  254.  
  255.    6.1  Expression operators
  256.  
  257.    The operators are:
  258.  
  259.      (blank) when there is no operator between operands, the effect is exactly
  260.       the same as if a + had appeared.
  261.  
  262.      +    addition
  263.  
  264.      -    subtraction
  265.  
  266.      *    multiplication
  267.  
  268.      \/   division (note that plain / starts a comment)
  269.  
  270.      &    bitwise and
  271.  
  272.      |    bitwise or
  273.  
  274.      >>   logical right shift
  275.  
  276.      <<   logical left shift
  277.  
  278.      %    modulo
  279.  
  280.      !    a!b is a or (not |); i.e., the or of the first operand  and  the
  281.       one's complement of the second; most common use is as a unary.
  282.  
  283.      ^    result has the value of first operand and the type of the second;
  284.       most often   used  to  define  new  machine  instructions  with
  285.       syntax identical to existing instructions.
  286.  
  287.    Expressions may be  grouped  by  use  of  square  brackets  '['']'.  (Round
  288.    parentheses are reserved for address modes.)
  289.  
  290.    6.2  Types
  291.  
  292.    The assembler deals with a number of types of expressions.  Most types  are
  293.    attached  to  keywords  and  used  to  select the routine which treats that
  294.    keyword.  The types likely to be met explicitly are:
  295.  
  296.       undefined
  297.      Upon first encounter, each symbol is undefined.  It may be-
  298.      come  undefined  if it is assigned an undefined expression.
  299.      It is an error to attempt to assemble an undefined  expres-
  300.      sion  in  pass 2; in pass 1, it is not (except that certain
  301.      keywords require operands which are not undefined).
  302.  
  303.       undefined external
  304.      A symbol which is declared .globl but not  defined  in  the
  305.      current  assembly is an undefined external.  If such a sym-
  306.      bol is declared, the link editor ld must be  used  to  load
  307.      the  assembler's  output  with another routine that defines
  308.      the undefined reference.
  309.  
  310.       absolute
  311.      An absolute symbol is one defined ultimately  from  a  con-
  312.      stant.   Its value is unaffected by any possible future ap-
  313.      plications of the link-editor to the output file.
  314.  
  315.       text
  316.      The value of a text symbol is measured with respect to  the
  317.      beginning  of  the text segment of the program.  If the as-
  318.      sembler output is link-edited, its text symbols may  change
  319.      in  value  since  the  program need not be the first in the
  320.      link editor's output.  Most text symbols are defined by ap-
  321.      pearing  as labels.  At the start of an assembly, the value
  322.      of '.' is text 0.
  323.  
  324.       data
  325.      The value of a data symbol is measured with respect to  the
  326.      origin  of  the  data segment of a program.  Like text sym-
  327.      bols, the value of a data symbol may change during a subse-
  328.      quent  link-editor run since previously loaded programs may
  329.      have data segments.  After the first .data  statement,  the
  330.      value of '.' is data 0.
  331.  
  332.       bss
  333.      The value of a bss symbol is measured from the beginning of
  334.      the  bss segment of a program.  Like text and data symbols,
  335.      the value of a bss symbol may change  during  a  subsequent
  336.      link-editor  run, since previously loaded programs may have
  337.      bss segments.  After the first .bss statement, the value of
  338.      '.' is bss 0.
  339.  
  340.       external absolute, text, data, or bss
  341.      symbols declared .globl but defined within an  assembly  as
  342.      absolute, text, data, or bss symbols may be used exactly as
  343.      if they were not declared .globl; however, their value  and
  344.      type  are  available to the link editor so that the program
  345.      may be loaded with others that reference these symbols.
  346.  
  347.       register
  348.      The symbols
  349.  
  350.           r0  ... r5
  351.           fr0  ... fr5
  352.           sp
  353.           pc
  354.  
  355.      are predefined as register symbols.  Either they or symbols
  356.      defined  from  them  must  be  used  to  refer  to  the six
  357.      general-purpose, six floating-point,  and  the  2  special-
  358.      purpose  machine  registers.   The behavior of the floating
  359.      register names is identical to that  of  the  corresponding
  360.      general  register  names;  the  former  are  provided  as a
  361.      mnemonic aid.
  362.  
  363.       other types
  364.      Each keyword known to the assembler has  a  type  which  is
  365.      used  to  select the routine which processes the associated
  366.      keyword statement.  The behavior of such symbols  when  not
  367.      used as keywords is the same as if they were absolute.
  368.  
  369.    6.3  Type propagation in expressions
  370.  
  371.    When operands are combined by expression operators, the result has  a  type
  372.    which  depends on the types of the operands and on the operator.  The rules
  373.    involved are complex  to  state  but  were  intended  to  be  sensible  and
  374.    predictable.  For  purposes  of  expression  evaluation the important types
  375.    are:
  376.  
  377.     undefined
  378.     absolute
  379.     text
  380.     data
  381.     bss
  382.     undefined external
  383.     other
  384.  
  385.    The combination rules are then:  If one of the operands is  undefined,  the
  386.    result  is  undefined.  If  both  operands  are  absolute,  the  result  is
  387.    absolute.  If an absolute is combined with one of the other types mentioned
  388.    above,  or with a register expression, the result has the register or other
  389.    type.  As a consequence, one can refer to r3 as r0+3.  If two  operands  of
  390.    other  type  are  combined, the result has the numerically larger type (not
  391.    that this fact is very useful, since the values are not  made  public).  An
  392.    other  type  combined with an explicitly discussed type other than absolute
  393.    acts like an absolute.
  394.  
  395.    Further rules applying to particular operators are:
  396.  
  397.      +   If one operand is text-, data-, or bss-segment relocatable,
  398.       or is an undefined external, the result has the postulated
  399.       type and the other operand must be absolute.
  400.  
  401.      -   If the first operand is  a  relocatable  text-,  data-,  or
  402.       bss-segment symbol, the second operand may be absolute (in
  403.       which case the result has the type of the first  operand);
  404.       or  the second operand may have the same type as the first
  405.       (in which case the result  is  absolute).   If  the  first
  406.       operand  is  external  undefined, the second must be abso-
  407.       lute.  All other combinations are illegal.
  408.  
  409.      ^   This operator follows no other rule than  that  the  result
  410.       has  the  value  of  the first operand and the type of the
  411.       second.
  412.  
  413.      others It is illegal to apply these operators to any but  abso-
  414.       lute symbols.
  415.  
  416.    7.  Pseudo-operations
  417.  
  418.    The keywords listed below  introduce  statements  which  generate  data  in
  419.    unusual  forms  or  influence  the  later operations of the assembler.  The
  420.    metanotation:
  421.  
  422.      [ stuff ] ...
  423.  
  424.    means that 0 or more  instances  of  the  given  stuff  may  appear.  Also,
  425.    boldface tokens are literals, italic words are substitutable.
  426.  
  427.    7.1  .byte  expression  [  , expression ]  ...
  428.  
  429.    The expressions in the comma-separated list are truncated  to  8  bits  and
  430.    assembled  in  successive  bytes.  The  expressions must be absolute.  This
  431.    statement and the string statement above are the only ones  which  assemble
  432.    data one byte at at time.
  433.  
  434.    7.2  .even
  435.  
  436.    If the location counter '.' is odd, it is  advanced  by  one  so  the  next
  437.    statement will be assembled at a word boundary.
  438.  
  439.    7.3  .if  expression
  440.  
  441.    The expression must be absolute and defined in pass  1.  If  its  value  is
  442.    nonzero,  the  .if  is ignored; if zero, the statements between the .if and
  443.    the matching .endif (below) are ignored. .if may be nested.  The effect  of
  444.    .if  cannot  extend  beyond  the end of the input file in which it appears.
  445.    (The statements are not  totally ignored, in the following sense: .ifs  and
  446.    .endifs  are  scanned for, and moreover all names are entered in the symbol
  447.    table.  Thus names occurring only inside an .if will show up  as  undefined
  448.    if the symbol table is listed.)
  449.  
  450.    7.4  .endif
  451.  
  452.    This statement marks the end of a conditionally-assembled section of  code.
  453.    See .if above.
  454.  
  455.    7.5  .globl  name  [  ,  name  ]  ...
  456.  
  457.    This statement makes the names external.  If they are otherwise defined (by
  458.    assignment  or  appearance as a label) they act within the assembly exactly
  459.    as if the .globl statement were not given; however, the link editor ld  may
  460.    be  used  to  combine  this  routine  with  other routines that refer these
  461.    symbols.
  462.  
  463.    Conversely, if the  given  symbols  are  not  defined  within  the  current
  464.    assembly, the link editor can combine the output of this assembly with that
  465.    of others which define the symbols.
  466.  
  467.    As discussed in 1., it is possible to  force  the  assembler  to  make  all
  468.    otherwise undefined symbols external.
  469.  
  470.    7.6  .text
  471.    7.7  .data
  472.    7.8  .bss
  473.  
  474.    These three pseudo-operations cause the assembler to begin assembling  into
  475.    the  text,  data, or bss segment respectively.  Assembly starts in the text
  476.    segment.  It is forbidden to  assemble  any  code  or  data  into  the  bss
  477.    segment, but symbols may be defined and '.' moved about by assignment.
  478.  
  479.    7.9  .comm  name  ,  expression
  480.  
  481.    Provided the name is not defined elsewhere, this statement is equivalent to
  482.  
  483.      .globl  name
  484.      name = expression ^ name
  485.  
  486.    That is, the  type  of  name  is  undefined  external,  and  its  value  is
  487.    expression.  In fact the name behaves in the current  assembly just like an
  488.    undefined external.  However, the link-editor ld has been special-cased  so
  489.    that all external symbols which are not otherwise defined, and which have a
  490.    non-zero value, are  defined to lie in the bss segment, and enough space is
  491.    left  after  the symbol to hold expression bytes.  All symbols which become
  492.    defined in this way are located before  all  the  explicitly  defined  bss-
  493.    segment locations.
  494.  
  495.    8.   Machine instructions
  496.  
  497.    Because of the rather complicated instruction and addressing  structure  of
  498.    the  PDP-11,  the  syntax  of  machine  instruction  state-ments is varied.
  499.    Although the following sections give the syntax in detail,  the  11/20  and
  500.    11/45 handbooks should be consulted on the semantics.
  501.  
  502.    8.1  Sources and Destinations
  503.  
  504.    The syntax of general source and destination addresses is  the  same.  Each
  505.    must  have  one of the following forms, where reg is a register symbol, and
  506.    expr is any sort of expression:
  507.  
  508.        syntax          words   mode
  509.  
  510.        reg             0       0+reg
  511.        (reg)+          0       2+reg
  512.        _(reg)          0       4+reg
  513.        expr(reg)       1       6+reg
  514.        (reg)           0       1+reg
  515.        *reg            0       1+reg
  516.        *(reg)+         0       3+reg
  517.        *_(reg)         0       5+reg
  518.        *(reg)          1       7+reg
  519.        *expr(reg)      1       7+reg
  520.        expr            1       67
  521.        $expr           1       27
  522.        *expr           1       77
  523.        *$expr          1       37
  524.  
  525.    The words column gives the number of  address  words  generated;  the  mode
  526.    column  gives  the  octal  address-mode  number.  The syntax of the address
  527.    forms is identical to that in DEC assemblers,  except  that  '*'  has  been
  528.    substituted  for  '@' and '$' for '#'; the UNIX typing conventions make '@'
  529.    and '#' rather inconvenient.
  530.  
  531.    Notice that mode *reg is identical to (reg); that *(reg) generates an index
  532.    word (namely, 0); and that  addresses consisting of an unadorned expression
  533.    are assembled as pc-relative references independent  of  the  type  of  the
  534.    expression.  To  force  a  non-relative  reference,  the form *$expr can be
  535.    used, but notice that further indirection is impossible.
  536.  
  537.    8.3  Simple machine instructions
  538.  
  539.    The following instructions are defined as absolute symbols:
  540.  
  541.     clc
  542.     clv
  543.     clz
  544.     cln
  545.     sec
  546.     sev
  547.     sez
  548.     sen
  549.  
  550.    They therefore require no special syntax.   The  PDP-11  hardware
  551.    allows  more  than  one  of the clear class, or alternatively
  552.    more than one of the set class to be or-ed together; this may
  553.    be expressed as follows:
  554.  
  555.     clc|clv
  556.  
  557.    8.4  Branch
  558.  
  559.    The following instructions take an expression as  operand.  The  expression
  560.    must  lie  in  the  same  segment  as  the  reference, cannot be undefined-
  561.    external, and its value cannot differ from the current location of  '.'  by
  562.    more than 254 bytes:
  563.  
  564.     br blos
  565.     bne bvc
  566.     beq bvs
  567.     bge bhis
  568.     blt bec (= bcc)
  569.     bgt bcc
  570.     ble blo
  571.     bpl bcs
  572.     bmi bes (= bcs)
  573.     bhi
  574.  
  575.    bes (branch on error set) and bec (branch on error clear) are  intended  to
  576.    test the error bit returned by system calls (which is the c-bit).
  577.  
  578.    8.5   Extended branch instructions
  579.  
  580.    The following symbols are followed by an expression representing an address
  581.    in  the  same  segment  as  '.'.  If  the target address is close enough, a
  582.    branch-type instruction is generated; if the address is too far away, a jmp
  583.    will be used.
  584.  
  585.     jbr jlos
  586.     jne jvc
  587.     jeq jvs
  588.     jge jhis
  589.     jlt jec
  590.     jgt jcc
  591.     jle jlo
  592.     jpl jcs
  593.     jmi jes
  594.     jhi
  595.  
  596.    jbr turns into a plain jmp if its target is too remote; the oth-ers  (whose
  597.    names are contructed by replacing the b in the branch instruction's name by
  598.    j) turn into the converse branch over a jmp to the target address.
  599.  
  600.    8.6  Single operand instructions
  601.  
  602.    The following symbols are names of  single-operand  machine  instructions.
  603.    The form of address expected is discussed in 8.1 above.
  604.  
  605.     clr sbcb
  606.     clrb ror
  607.     com rorb
  608.     comb rol
  609.     inc rolb
  610.     incb asr
  611.     dec asrb
  612.     decb asl
  613.     neg aslb
  614.     negb jmp
  615.     adc swab
  616.     adcb tst
  617.     sbc tstb
  618.  
  619.    8.7  Double operand instructions
  620.  
  621.    The following instructions take a general  source  and  destination  (8.1),
  622.    separated by a comma, as operands.
  623.  
  624.     mov
  625.     movb
  626.     cmp
  627.     cmpb
  628.     bit
  629.     bitb
  630.     bic
  631.     bicb
  632.     bis
  633.     bisb
  634.     add
  635.     sub
  636.  
  637.    8.8  Miscellaneous instructions
  638.  
  639.    The following instructions have more specialized  syntax.  Here  reg  is  a
  640.    register name, src and dst a general source or destination  (8.1), and expr
  641.    is an expression:
  642.  
  643.     jsr reg,dst
  644.     rts reg
  645.     sys expr
  646.     ash src,reg (or, als)
  647.     ashc src,reg (or, alsc)
  648.     mul src,reg (or, mpy)
  649.     div src,reg (or, dvd)
  650.     xor reg,dst
  651.     sxt dst
  652.     mark expr
  653.     sob reg,expr
  654.  
  655.    sys is another name for the trap instruction.  It is used  to  code  system
  656.    calls.   Its  operand  is  required  to  be  expressible  in  6  bits.  The
  657.    alternative forms for ash, ashc,  mul,  and  div  are   provided  to  avoid
  658.    conflict with EAE register names should they be needed.
  659.  
  660.    The expression in mark must be expressible in six bits, and the  expression
  661.    in  sob must be in the same segment as '.', must not be external-undefined,
  662.    must be less than '.', and must be within 510 bytes of '.'.
  663.  
  664.    8.9  Floating-point unit instructions
  665.  
  666.    The  following  floating-point  operations  are  defined,  with  syntax  as
  667.    indicated:
  668.  
  669.     cfcc
  670.     setf
  671.     setd
  672.     seti
  673.     setl
  674.     clrf fdst
  675.     negf fdst
  676.     absf fdst
  677.     tstf fsrc
  678.     movf fsrc,freg (= ldf)
  679.     movf freg,fdst (= stf)
  680.     movif src,freg (= ldcif)
  681.     movfi freg,dst (= stcfi)
  682.     movof fsrc,freg (= ldcdf)
  683.     movfo freg,fdst (= stcfd)
  684.     movie src,freg (= ldexp)
  685.     movei freg,dst (= stexp)
  686.     addf fsrc,freg
  687.     subf fsrc,freg
  688.     mulf fsrc,freg
  689.     divf fsrc,freg
  690.     cmpf fsrc,freg
  691.     modf fsrc,freg
  692.     ldfps src
  693.     stfps dst
  694.     stst dst
  695.  
  696.    fsrc, fdst, and freg mean floating-point source, destination, and  register
  697.    respectively.  Their  syntax  is  identical  to that for their non-floating
  698.    counterparts, but note that only floating re-gisters 0_3 can be a freg.
  699.  
  700.    The names of several of the operations have been changed to  bring  out  an
  701.    analogy  with  certain  fixed-point instructions.  The only strange case is
  702.    movf, which turns into either stf or ldf depending respectively on  whether
  703.    its  first operand is or is not a register.  Warning: ldf sets the floating
  704.    condition codes, stf does not.
  705.  
  706.    9.  Other symbols
  707.  
  708.    9.1  '..'
  709.  
  710.    The symbol '..' is the relocation counter.  Just before each assembled word
  711.    is  placed  in the output stream, the current value of this symbol is added
  712.    to the word if the word refers to a text, data or bss segment location.  If
  713.    the  output  word is a pc-relative address word which refers to an absolute
  714.    location, the value of '..' is subtracted.
  715.  
  716.    Thus the value of '..' can be taken to mean the starting core  location  of
  717.    the  program.  In  UNIX systems with relocation hardware, the initial value
  718.    of '..' is 0.
  719.  
  720.    The value of '..' may be changed by assignment.  Such a course of action is
  721.    sometimes  necessary, but the consequences should be carefully thought out.
  722.    It is particularly ticklish to change '..' midway in an assembly or  to  do
  723.    so  in  a  program  which  will be treated by the loader, which has its own
  724.    notions of '..'.
  725.  
  726.    9.2  System calls
  727.  
  728.    The following absolute symbols may be used to code calls to the UNIX system
  729.    (see the sys instruction above).
  730.  
  731.     break nice
  732.     chdir open
  733.     chmod read
  734.     chown seek
  735.     close setuid
  736.     creat signal
  737.     exec stat
  738.     exit stime
  739.     fork stty
  740.     fstat tell
  741.     getuid time
  742.     gtty umount
  743.     link unlink
  744.     makdir wait
  745.     mdate write
  746.     mount
  747.  
  748.    Warning: the wait system call is not the same  as  the  wait  instruction,
  749.    which is not defined in the assembler.
  750.  
  751.    10.  Diagnostics
  752.  
  753.    When an input file cannot be read, its name followed by a question  mark is
  754.    typed  and  assembly  ceases.  When  syntactic or semantic  errors occur, a
  755.    single-character diagnostic is typed out together  with the line number and
  756.    the  file  name in which it occurred.   Errors in pass 1 cause cancellation
  757.    of pass 2.  The possible errors are:
  758.  
  759.        )   parentheses error
  760.        ]   parentheses error
  761.        >   string not terminated properly
  762.        *   indirection (*) used illegally
  763.        .   illegal assignment to .
  764.        A   error in address
  765.        B   branch address is odd or too remote
  766.        E   error in expression
  767.        F   error in local (f or b) type symbol
  768.        G   garbage (unknown) character
  769.        I   end of file inside an .if
  770.        M   multiply defined symbol as label
  771.        O   word quantity assembled at odd address
  772.        P   phase error_ . different in pass 1 and 2
  773.        R   relocation error
  774.        U   undefined symbol
  775.        X   syntax error
  776.