BSD 3 development
[unix-history] / usr / doc / as.ms
CommitLineData
ebb763d8
JR
1.TL
2Assembler Reference Manual
3.AU
4John F. Reiser
5.AI
6.HO
7.AU
8Robert R. Henry\s-2\u*\d\s+2
9.FS
10\&\s-2\u*\d\s+2
11Preparation of this paper supported in part
12by the National Science Foundation under grant MCS # 78-07291.
13.FE
14.AI
15Electronics Research Laboratory
16University of California
17Berkeley, CA 94720
18.ND November 5, 1979
19.NH
20Introduction
21.PP
22This document describes the usage and input syntax
23of the \s8UNIX VAX\s10-11 assembler \fIas\fP.
24\fIAs\fP is designed for assembling the code produced by the
25C compiler; certain concessions have been made to handle code written
26directly by people, but in general little sympathy has been extended.
27This document is intended only for the writer of a compiler or a maintainer
28of the assembler.
29.NH
30Usage
31.PP
32\fIas\fP is used as follows:
33.in +5
34as [ \fB\-L\fR ] [ \fB\-V\fR ] [ \fB\-DTC\fR ]
35[ \fB\-d\fIn\fR ] [ \fB\-o \fIoutput\fR ] [ \fIname\d\s-2\&1\s+2\u1 ]
36[ name\d\s-2\&2\s+2\u ... \fP ]
37.br
38.in -5
39.PP
40The \fB\-L\fP flag instructs the assembler to save labels beginning with
41a 'L' in the symbol table portion output file.
42Labels are not saved by default, as the default action of the link
43editor \fIld\fP is to discard them anyway.
44.PP
45The \fB\-d\fP flag specifies the number of bytes
46which the assembler should allow for a displacement when the value of the
47displacement expression is undefined in the first pass.
48The possible values of \fIn\fP are 1, 2, or 4; the assembler uses 4 bytes
49if \fB-d\fP is not specified.
50See \(sc 9.2.
51.PP
52The \fB\-o\fP flag causes the output to be placed on the named file.
53The output of the assembler is by default placed on
54the file \fIa.out\fR in the current directory.
55.PP
56The input to the assemble is normally taken from the standard input.
57If file arguments occurs, then the input is taken
58sequentially from the files \fIname\d\s-2\&1\s+2\u\fP,
59\fIname\d\s-2\&2\s+2\u\fP...
60This is not to say that the files are assembled seperately;
61\fIname\d\s-2\&2\s+2\u\fP
62is effectively concatenated to \fIname\d\s-2\&1\s+2\u\fP,
63so multiple definitions cannot occur amongst the input sources.
64.PP
65The \fB\-V\fP flag tells the assembler to place its interpass temporary
66file into virtual memory. In normal circumstances, the system manager
67will decide where the temporary file should lie. Our experiments
68with very large temporary files show that placing the temporary
69file into virtual memory will save about 13% of the assembly time,
70where the size of the temporary file is about 350K bytes.
71Most assembler sources will not be this long.
72.PP
73The \fB\-D\fP flag enables debugging information, provided that the
74assembler has been compiled to have debugging information available.
75.PP
76The \fB\-T\fP flag enables a trace to be generate of each token read
77by \fIas\fP to be printed. This is long and boring, but useful when
78debugging the assembler.
79.PP
80The \fB\-C\fP flag will, upon termination of the assembly, print
81out various statistics regarding the symbol table, the jump resolution
82algorithm, and the total elapsed time.
83.NH
84Lexical conventions
85.PP
86Assembler tokens include identifiers (alternatively, ``symbols'' or ``names''),
87constants, and operators.
88.NH
89Identifiers
90.PP
91An identifier consists of a sequence of alphanumeric characters (including
92period ``\|\fB.\fR\|'' and underscore ``\(ul''
93as alphanumeric)
94of which the first may not be numeric.
95Currently, only the first eight characters are significant.
96.NH 2
97Constants
98.NH 3
99Simple constants
100.PP
101All integer constants are 32 bits wide and interpreted as two's
102complement numbers.
103Floating-point constants are 64 bits wide.
104The digits are ``0123456789abcdefABCDEF'' with the obvious values.
105.PP
106An octal constant consists of a sequence of digits with a leading zero.
107.PP
108A decimal constant consists of a sequence of digits without a leading zero.
109.PP
110A hexadecimal constant consists of the characters ``0x'' (or ``0X'')
111followed by a sequence of digits.
112.PP
113A single-character constant consists of a single quote ``\|\(fm\|''
114followed by an \s8ASCII\s10 character, including \s8ASCII\s10 newline.
115The constant's value is the code for the
116given character.
117.PP
118A floating-point constant consists of the characters ``0f'', ``0d'',
119``0F'', or ``0D'' followed by a sequence of characters which \fIatof\fP
120will recognize as a floating-point number;
121either ``e'', ``E'', ``d''or ``D''
122may be used to designate the exponent field.
123.NH 3
124String Constants
125.PP
126A string constant is defined using the same syntax and semantics as ``C''
127beginning and ending with a ``"'' (double quote).
128The \s8DEC\s10 assembler conventions for flexible string quoting is
129not implemented.
130All ``C'' backslash conventions are observed; the backslash conventions
131peculiar to the \s-2PDP\-11\s+2 assembler are not observed.
132Strings are known by their value and their length; the assembler
133does not implicitly end strings with a null byte.
134.NH 2
135Operators
136.PP
137There are several single-character
138operators; see \(sc7.
139.NH 2
140Blanks
141.PP
142Blank and tab characters
143may be interspersed freely between tokens, but may
144not be used within tokens (except character constants).
145A blank or tab is required to separate adjacent
146identifiers or constants not otherwise separated.
147.NH 2
148Comments
149.NH 3
150Decadent Comments
151.PP
152The character ``\|#\|'' introduces a comment, which extends
153through the end of the line on which it appears.
154Comments starting in column 1,
155of the format ``\|# \fIexpression string\fP\|"
156are interpreted as an indication that the assembler is now assembling
157file \fIstring\fP at line \fIexpression\fP.
158Thus, one can use the C preprocessor on an assembly language source file,
159and use the \fI#include\fP and \fI#define\fP
160preprocessor directives.
161(Note that their may not be an assembler comment starting in column
1621 if the assembler source is given to the C preprocessor, as it will
163be intrepreted by the preprocessor in a way not intended.)
164Comments are otherwise ignored by the assembler.
165.NH 3
166C Style Comments
167.PP
168The assembler will recognize C style comments, introduced with
169the prologue \fB/*\fP and ending with the epilogue \fB*/\fP.
170C style comments may extend across multiple lines, and are the preferred
171comment style to use if one chooses to use the C preprocessor.
172.NH 1
173Segments and Location Counters
174.PP
175Assembled code and data fall into three segments: the text segment,
176the data segment, and the bss segment. The operating system makes
177some assumptions about the content of these segments; the assembler
178does not. Within the text and data segments there are a number of
179sub-segments, distinguished by number (``text 0'', ``text 1'', .\|.\|.
180``data 0'', ``data 1'', .\|.\|.\|).
181Currently there are four subsegments each in text and data.
182The subsegments are for programming convenience only. Before writing the
183output file, the assembler zero-pads each text subsegment to a multiple of four
184bytes and then concatenates the subsegments in order to form the text segment;
185an analogous operation is done for the data segment.
186Requesting that the loader define symbols and storage regions is the only
187action allowed by the assembler with respect to the bss segment.
188Assembly begins in ``text 0''.
189.PP
190Associated with each (sub)segment is an implicit location counter which
191begins at zero and is incremented by 1 for each byte assembled into the
192(sub)segment. There is no way to explicitly reference a location counter.
193Note that the location counters of subsegments other than ``text 0''
194and ``data 0'' behave peculiarly due to the concatenation used to form
195the text and data segments.
196.NH 1
197Statements
198.PP
199A source program is composed of a sequence of
200\fIstatements\fP.
201Statements are separated either by new-lines
202or by semicolons.
203There are two kinds of statements: null statements
204and keyword statements.
205Either kind of statement may be preceded by
206one or more labels.
207.NH 2
208Labels
209.PP
210A label consists of a name followed
211by a colon (\|:\|).
212The effect of a name label is to assign the current
213value and type of the location counter
214to the name.
215An error is indicated in pass 1 if the
216name is already defined;
217an error is indicated in pass 2 if the
218value assigned changes the definition
219of the label.
220.PP
221Labels beginning with a ``\|L\|'' are discarded unless the \fB-L\fP option
222is in effect.
223.NH 2
224Null statements
225.PP
226A null statement is an empty statement (which may, however,
227have labels).
228A null statement is ignored by the assembler.
229Common examples of null statements are empty
230lines or lines containing only a label.
231.NH 2
232Keyword statements
233.PP
234A keyword statement begins with one of the many predefined
235keywords of the assembler;
236the syntax of the remainder depends
237on the keyword.
238All instruction opcodes are keywords.
239The remaining keywords are assembler pseudo-operations,
240also called directives.
241The pseudo-operations are listed below with the syntax they require.
242.NH 1
243Expressions
244.PP
245An expression is a sequence of symbols representing a value.
246Its constituents are identifiers, constants,
247operators, and parentheses.
248Each expression has a type.
249.PP
250All operators in expressions are fundamentally binary in
251nature.
252Arithmetic is two's complement and has 32 bits of precision.
253There are four levels of precedence, listed here from
254lowest precedence level to highest:
255.IP (binary) 16
256\|+\|, -\|
257.IP (binary) 16
258\||\|, \|&\|, \|^\|, \|!\|
259.IP (binary) 16
260\|*\|, \|/\|, \|%\|, \|!\|
261.IP (unary) 16
262\|-\|, \|!\|
263.PP
264All operators of the same precedence are evaluated strictly left to right,
265except for evaluation order enforced by parenthesis.
266.NH 2
267Expression operators
268.PP
269The operators are:
270.IP + 16
271addition
272.IP \- 16
273subtraction
274.IP * 16
275multiplication
276.IP / 16
277division
278.IP %
279modulo
280.IP & 16
281bitwise and
282.IP \(bv 16
283bitwise or
284.IP ^ 16
285bitwise exclusive or
286.IP "> (or >>)" 16
287logical right shift
288.IP "< (or <<)" 16
289logical left shift
290.hc
291.IP ! 8
292\fIa\fR\|!\|\fIb\fR is \fIa \fBor \fR(\|\fBnot \fIb\fR\|);
293i.e., the \fBor\fR of the first operand and
294the one's complement of the second; most common use is
295as a unary operator.
296.PP
297Expressions may be grouped by use of parentheses ``\|(\|\|)\|''.
298.NH 2
299Types
300.PP
301The assembler deals with a number of types
302of expressions. Most types
303are attached to keywords and used to select the
304routine which treats that keyword. The types likely
305to be met explicitly are:
306.IP undefined 8
307.br
308Upon first encounter, each symbol is undefined.
309It may become undefined if it is assigned an undefined expression.
310It is an error to attempt to assemble an undefined
311expression in pass 2; in pass 1, it is not (except that
312certain keywords require operands which are not undefined).
313.IP "undefined external" 8
314.br
315A symbol which is declared \fB.globl\fR but not defined
316in the current assembly is an undefined
317external.
318If such a symbol is declared, the link editor \fIld\fR
319must be used to load the assembler's output with
320another routine that defines the undefined reference.
321.IP absolute 8
322.br
323An absolute symbol is defined ultimately from a constant.
324Its value is unaffected by any possible future applications
325of the link-editor to the output file.
326.IP text 8
327.br
328The value of a text symbol is measured
329with respect to the beginning of the text segment of the program.
330If the assembler output is link-edited, its text
331symbols may change in value
332since the program need
333not be the first in the link editor's output.
334Most text symbols are defined by appearing as labels.
335At the start of an assembly, the value of ``\|\fB.\fP\|'' is text 0.
336.IP data 8
337.br
338The value of a data symbol is measured
339with respect to the origin of the data segment of a program.
340Like text symbols, the value of a data symbol may change
341during a subsequent link-editor run since previously
342loaded programs may have data segments.
343After the first \fB.data\fR statement, the value of ``\|\fB.\fP\|''
344is data 0.
345.IP bss 8
346.br
347The value of a bss symbol is measured from
348the beginning of the bss segment of a program.
349Like text and data symbols, the value of a bss symbol
350may change during a subsequent link-editor
351run, since previously loaded programs may have bss segments.
352.IP "external absolute, text, data, or bss" 8
353.br
354symbols declared \fB.globl\fR
355but defined within an assembly as absolute, text, data, or bss
356symbols may be used exactly as if they were not
357declared \fB.globl\fR; however, their value and type are available
358to the link editor so that the program may be loaded with others
359that reference these symbols.
360.IP register 8
361.br
362The symbols
363.DS
364\fBr0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15\fP
365\fBap fp sp pc\fP
366.DE
367are predefined
368as register symbols.
369In addition, the operator converts an absolute value to type register.
370.IP "other types" 8
371.br
372Each keyword known to the assembler has a type which
373is used to select the routine which processes
374the associated keyword statement.
375The behavior of such symbols
376when not used as keywords is the same as if they were absolute.
377.NH 2
378Type propagation in expressions
379.PP
380When operands are combined by expression operators,
381the result has a type which depends on the types
382of the operands and on the operator.
383The rules involved are complex to state but
384were intended to be sensible and predictable.
385For purposes of expression evaluation the
386important types are
387.DS
388undefined
389absolute
390text
391data
392bss
393undefined external
394other
395.DE
396The combination rules are then:
397If one of the operands
398is undefined, the result is undefined.
399If both operands are absolute, the result is absolute.
400If an absolute is combined with one of the ``other types''
401mentioned above,
402the result has the other type.
403An ``other type'' combined with an explicitly
404discussed type other than absolute
405it acts like an absolute.
406.PP
407Further rules applying to particular operators
408are:
409.IP +
410If one operand is text-, data-, or bss-segment
411relocatable, or is an undefined external,
412the result has the postulated type and the other operand
413must be absolute.
414.IP \-
415If the first operand is a relocatable
416text-, data-, or bss-segment symbol, the second operand
417may be absolute (in which case the result has the
418type of the first operand);
419or the second operand may have the same type
420as the first (in which case the result is absolute).
421If the first operand is external undefined, the second must be
422absolute.
423All other combinations are illegal.
424.PP
425.IP others
426.br
427It is illegal to apply these operators to any but absolute
428symbols.
429.NH 1
430Pseudo-operations (Directives)
431.PP
432The keywords listed below introduce
433influence the later operations of the assembler.
434The metanotation
435.DS
436[ stuff ] .\|.\|.
437.DE
438means that 0 or more instances of the given stuff may appear.
439The metatnotation
440.DS
441( stuff )\|*\|\|\fIn\fP\|
442.DE
443means that exactly \fIn\fP occurances of stuff must occur.
444.PP
445Boldface tokens are literals, italic words
446are substitutable.
447.PP
448The pseudo operations listed belowe are grouped into functional
449categories, and not alphabetically.
450.NH 2
451Interface to a Previous Pass
452.in +5m
453.NH 3
454\&.ABORT
455.PP
456As soon as the assembler sees this directive, it ignores all further
457input (but it does read to the end of file), and aborts the assembly.
458No files are created.
459It is anticipated that this would be used in a pipe interconnected
460version of a compiler, where the first major syntax error would
461cause the compiler to issue this directive, saving unnecessary
462work in assembling code that would have to be discarded anyway.
463.NH 3
464\&.file \fIstring\fP
465.PP
466This directive causes the assembler to think it is in file \fIstring\fP
467so error messages reflect the proper source file.
468.NH 3
469\&.line \fIexpression\fP
470.PP
471This directive causes the assembler to think it is on line \fIexpression\fP
472so error messages reflect the proper source file.
473.PP
474The only effect of assembling multiple files specified in the command string
475is to insert the
476\fIfile\fP and \fIline\fP directives, with the appropriate values,
477at the beginning of the source from each file.
478.NH 3
479Preprocessor Interface
480.DS
481\fI# expression string\fP
482\fI# expression\fP
483.DE
484.PP
485This is the only instance where a comment is meaningful to the assembler.
486The ``\|#\|''
487.ul 1
488must
489be in the first column.
490This meta comment causes the assembler
491to believe it is on line \fIexpression\fP.
492The second argument, if included, causes the assembler to believe it is in
493file \fIstring\fP, otherwise the current file name does not change.
494.in -5m
495.NH 2
496Location Counter Control
497.in +5m
498.NH 3
499\&\fB.align\fP \fIexpression\fP
500.PP
501The location counter is adjusted (by assembling bytes containing
502zeroes, if necessary) so that the \fIexpression\fP lowest bits
503become zero. Thus ``.align 2'' makes the location counter divisible by 4.
504The expression must be defined, absolute, nonnegative,
505and less than 16.
506(Note that the subsegment concatenation convention
507and the current loader conventions may not preserve attempts at aligning
508to more than 2 low-order zero bits.)
509.NH 3
510Subsegment switching
511.DS
512 \fB.data\fP [ \fIexpression\fP ]
513 \fB.text\fP [ \fIexpression\fP ]
514.DE
515.PP
516These two pseudo-operations cause the
517assembler to begin assembling into the indicated text or data
518subsegment. If specified, the expression must be defined and absolute;
519an omitted expression is treated as zero.
520Assembly starts in the text 0 subsegment.
521.NH 3
522\&\fB.org\fP \fIexpression\fP
523.PP
524The location counter is set equal to the value of the expression.
525The expression must be defined.
526The value of the expression must be greater than the current value
527of the location counter.
528.NH 3
529\&\fB.space\fP \fIexpression\fP
530.PP
531\&\fIexpression\fP bytes of zeroes are assembled.
532.in -5m
533.NH 2
534Initialized Data
535.in +5m
536.NH 3
537Expression Initialized Data
538.DS
539 \fB.byte \fIexpression \fR[ \fB, \fIexpression \fR] .\|.\|.
540 \fB.double \fIexpression \fR[ \fB, \fIexpression \fR] .\|.\|.
541 \fB.float \fIexpression \fR[ \fB, \fIexpression \fR] .\|.\|.
542 \fB.int \fIexpression \fR[ \fB, \fIexpression \fR] .\|.\|.
543 \fB.long \fIexpression \fR[ \fB, \fIexpression \fR] .\|.\|.
544 \fB.word \fIexpression \fR[ \fB, \fIexpression \fR] .\|.\|.
545.DE
546.PP
547The \fIexpression\fRs in the comma-separated
548list are truncated to the indicated size (byte=8 bits, double=64, float=32,
549int=32, long=32, word=16) and
550assembled in successive locations. The expressions must be absolute.
551The value assembled in bits 32-63 for \fB.double\fP is unpredictable
552if the expression is not of type double.
553.PP
554Each expression may optionally be of the form
555.DS
556 \fIexpression\d\s-21\&\s+2\u\fP \fB:\fP \fIexpression\d\s-2\&2\s+2\u\fP.
557.DE
558In this case the value of \fIexpression\d\s-2\&2\s+2\u\fP
559is truncated to \fIexpression\d\s-2\&1\s+2\u\fP
560bits and assembled in the next \fIexpr\d\s-2\&1\s+2\u\fP-bit
561field which fits in
562the natural data size being assembled.
563Bits which are skipped because
564a field does not fit are made zero.
565Thus "\fB.byte\fP 123" is equivalent to
566"\fB.byte\fP 8:123" and "\fB.byte\fP 3:1,2:1,5:1"
567assembles two bytes, containing the values 9 and 1.
568.NH 3
569String Initialized Data
570.DS
571 \fB.ascii\fP \fIstring\fP [ \fB,\fP \fIstring\fP ]
572 \fB.asciz\fP \fIstring\fP [ \fB,\fP \fIstring\fP ]
573.DE
574.PP
575Each \fIstring\fP in the list is assembled into successive locations,
576with the first letter in the string being placed
577into the first location, etc.
578The \fB.ascii\fP directive will not null pad the string;
579the \fB.asciz\fP directive will null pad the string.
580(Recall that strings are known by their length, and need not be terminated
581with a null, and that the C conventions for escaping are understood.)
582The \fB.ascii\fP directive is identical to:
583.DS
584\&\fB.byte\fP \fIstring\d\s-2\&0\s+2\u\fP\fB,\fP \fIstring\d\s-2\&1\s+2\u\fP\fB,\fP ...
585.DE
586.in -5m
587.NH 2
588Symbol Definition
589.in +5m
590.NH 3
591General
592.in +5m
593.NH 4
594\&\fB.comm\fI name \fB, \fIexpression\fR
595.PP
596Provided the \fIname\fR is not defined elsewhere,
597its type is made ``undefined external'', and its value is \fIexpression\fR.
598In fact the \fIname\fR behaves
599in the current assembly just like an
600undefined external.
601However, the link editor \fIld\fR has been special-cased
602so that all external symbols which are not
603otherwise defined, and which have a non-zero
604value, are defined to lie in the bss
605segment, and enough space is left after the
606symbol to hold \fIexpression\fR
607bytes.
608.NH 4
609\&\fB.lcomm\fI name \fB, \fIexpression\fR
610.PP
611\fIexpression\fP bytes will be allocated in the bss segment and \fIname\fP
612assigned the location of the first byte, but the \fIname\fP is not declared
613as global and hence will be unknown to the link editor.
614.NH 4
615\&\fB.globl\fP \fIname\fP
616.PP
617This statement makes the \fIname\fR external.
618If it is otherwise defined (by \fB.set\fP or by
619appearance as a label)
620it acts within the assembly exactly as if
621the \fB.globl\fR statement were not given;
622however, the link editor may be used
623to combine this routine with other routines that refer
624to this symbol.
625.PP
626Conversely, if the given symbol is not defined
627within the current assembly, the link editor
628can combine the output of this assembly
629with that of others which define the symbol.
630The assembler makes all otherwise
631undefined symbols external.
632.NH 4
633\&\fB.set\fP \fIname\fP \fB,\fP \fIexpression\fP
634.PP
635The (\fIname\fP, \fIexpression\fP) pair is entered into the symbol table.
636Multiple \fB.set\fP statements with the same name are legal;
637the most recent value replaces all previous values.
638.in -5m
639.NH 3
640Debugger Support
641.in +5m
642.NH 4
643\&\fB.lsym\fP \fIname\fP \fB,\fP \fIexpression\fP
644.PP
645A unique and otherwise unreferenceable instance of the
646(\fIname\fP, \fIexpression\fP)
647pair is created in the symbol table.
648The Fortran 77 compiler uses this mechanism to pass local symbol definitions
649to the link editor and debugger.
650.NH 4
651Special Symbol Table entries
652.DS
653\&\fB.stab\fP (\fIexpr\d\s-2i\s+2\u \fB,\fR)\|*8\| \fIexpr\d\s-2\&1\s+2\u\fB,\fP expr\d\s-2\&2\s+2\u\fB,\fP expr\d\s-2\&3\s+2\u\fB,\fP expr\d\s-2\&4\s+2\u\fR
654.in +5m
655\fR(normal \fBs\fPymbol \fBtab\fPle entry)\fR
656.in -5m
657\&\fB.stabs\fP \fIstring, expr\d\s-2\&1\s+2\u, expr\d\s-2\&2\s+2\u, expr\d\s-2\&3\s+2\u, expr\d\s-2\&4\s+2\u\fR
658.in +5m
659\fR(\fBstab s\fPtring)\fR
660.in -5m
661\&\fB.stabn\fP \fIexpr\d\s-2\&1\s+2\u\fB,\fP expr\d\s-2\&2\s+2\u\fB,\fP expr\d\s-2\&3\s+2\u\fB,\fP expr\d\s-2\&4\s+2\u\fR
662.in +5m
663\fR(\fBstab n\fPone)\fR
664.in -5m
665\&\fB.stabd\fP \fIexpr\d\s-2\&1\s+2\u\fB,\fP expr\d\s-2\&2\s+2\u\fB,\fP expr\d\s-2\&3\s+2\u\fR
666.in +5m
667\fR(\fBstab d\fPot)\fR
668.in -5m
669.DE
670.PP
671The \fIstab\fP directives place symbols in the symbol table for the symbolic
672debugger, \fIsdb\fP\s-2\u*\d\s+2.
673.FS
674.in +5
675.ti -5
676\s-2\u*\d\s+2Katseff, H.P. \fISdb: A Symbol Debugger\fP.
677Bell Laboratories, Holmdel,
678NJ. April 12, 1979.
679.br
680.ti -5
681\&Katseff, H.P. \fISymbol Table Format for Sdb\fP. File 39394,
682Bell Laboratores, Holmdel, NJ. March 14, 1979.
683.in -5
684.FE
685In the \fB.stab\fP directive, the first 8 expressions are used for the
686symbol name, which may be zero. The \fIstring\fP in the \fB.stabs\fP
687directive serves the same purpose. If the symbol name is zero, the
688\&\fB.stabn\fP directive may be used instead.
689.PP
690The other expressions are stored in the symbol table;
691the value of the expressions are peculiar to formats required by \fIsdb\fP\fR.
692.in +5m
693.ti -5
694\&\fIexpr\d\s-2\&1\s+2\u\fP is used as a symbol table tag.
695.br
696.ti -5
697\&\fIexpr\d\s-2\&2\s+2\u\fP seems to always be zero.
698.br
699.ti -5
700\&\fIexpr\d\s-2\&3\s+2\u\fP is used for either the
701source line number, or for a nesting level.
702.br
703.ti -5
704\fIexpr\d\s-2\&4\s+2\u\fR is used as tag specific information. In the
705case of the \fB.stabd\fP directive, this expression is non existant, and
706is taken to be the value of the location counter at the following instruction.
707Since there is no associated name for a \fB.stabd\fP directive, it can
708only be used in circumstances there the name is zero.
709The effect of a \fB.stabd\fP directive can be achieved by one of the other
710\&\fB.stab\fPx directives in the following manner:
711.in -5m
712.DS
713\& \fB.stabs\fP \fIstring\fB,\fP expr\d\s-2\&1\s+2\u\fB,\fP expr\d\s-2\&2\s+2\u\fB,\fP expr\d\s-2\&3\s+2\u\fB,\fP \fP LL\fIn\fP
714LL\fIn\fP\fB:\fP
715.DE
716The \fB.stabd\fP directive is prefered, because it does not clog the symbol
717table with labels used only for the stab symbol entrys.
718.in -5m
719.in -5m
720.NH 1
721Machine instructions
722.PP
723The syntax of machine instruction statements accepted by \fIas\fP
724is generally similar to the syntax of \s8DEC MACRO\s10-32. There are
725differences, however.
726.NH 2
727Character set
728.PP
729\fIas\fP uses the character `$' instead of `#',
730and the character `*' instead of `@'. Opcodes and register names
731are spelled with lower-case rather than upper-case letters.
732.NH 2
733Lengths
734.PP
735Under certain circumstances, the following constructs are (optionallly)
736recognized by \&\fIas\fP to indicate the number of bytes to allocate
737for unresolved expressions used to specify displacement or indirect
738displacement addressing modes:
739.DS
740\&\fBB^\fP or \fBB\`\fP to indicate byte lengths (1 byte)
741\&\fBW^\fP or \fBW\`\fP to indicate word lengths (2 bytes)
742\&\fBL^\fP or \fBL\`\fP to indicate long word lengths (3 bytes)
743.DE
744One can also use lower case \fBb\fP, \fBw\fP or \fBl\fP instead of the upper
745case letters.
746There must be no space between the size specifier letter and the \fB^\fP or
747\&\fB\`\fP.
748The constructs \fBS^\fP and \fBG^\fP are not recognized
749by \fIas\fP as they are by the \s-2DEC\s+2 assembler.
750It is preferred to use the "\`" displacement specifier,
751so that the ``^'' is not
752misinterpreted as the \fBxor\fP operator.
753.PP
754Literal values (including floating-point literals used where the
755hardware expects a floating-point operand) are assembled as short
756literals if possible, hence not needing the \fBS^\fP \s-2DEC\s+2
757directive. If the value of the displacement is known exactly in the
758first pass \fIas\fP determines the length automatically, assembling it
759in the shortest possible way, ignoring (if present) the length
760expression. If the value of the displacement is not known in the first
761pass, \&\fI\fP will use the value of the displacement given by the
762optional length specifier, or will use the value specified by the
763\fB\-D\fP argument, or will default to 4 bytes.
764.NH 2
765CASE instructions
766.PP
767\fIas\fP considers the instructions \fBcaseb\fP, \fBcasel\fP, \fBcasew\fP
768to have three operands (namely: selector, base, limit).
769The displacements must be explicitly assembled using one
770or more \fB.word\fP statements.
771.NH 2
772Extended branch instructions
773.PP
774These opcodes (formed in general
775by substituting a ``j'' for the initial ``b''
776of the standard opcodes)
777take as branch destinations the name of a label in the current
778subsegment. If the destination is close enough then the corresponding
779``b'' instruction is assembled. Otherwise the assembler choses a sequence
780of one or more instructions which together have the same effect as if the
781``b'' instruction had a larger span. In general, \fIas\fP chooses the
782inverse branch followed by a \fBbrw\fP, but a \fBbrw\fP
783is sometimes pooled among several ``j'' instructions with the same
784destination.
785.KS
786.DS
787.ft B
788.ta 1.0i 2.0i 3.0i
789jeql jeqlu jneq jnequ
790jgeq jgequ jgtr jgtru
791jleq jlequ jlss jlssu
792jbcc jbsc jbcs jbss
793jlbc jlbs
794jcc jcs
795jvc jvs
796jbc jbs
797jbr
798.DE
799.KE
800\fBjbr\fR turns into \fBbrb\fR
801if its target is close enough; else a \fBbrw\fP is used.
802.NH 1
803Diagnostics
804.PP
805Diagnostics are intended to be self explanatory.
806.NH 1
807Limits
808.DS
809 8 Significant characters per name
810 128 Characters per input line
811 128 Characters per string
8124000 User defined symbols + jump instructions
8133000 User defined symbols
814 4 Text segments
815 4 Data segments
816.DE