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