date and time created 88/10/21 13:47:49 by bostic
[unix-history] / usr / src / old / as.vax / PSD.doc / asdocs4.me
CommitLineData
d2964941
RH
1.\"
2.\" Copyright (c) 1982 Regents of the University of California
a6a7cc62 3.\" @(#)asdocs4.me 1.9 %G%
d2964941 4.\"
5cb4b394
RH
5.EQ
6delim $$
7.EN
8.SH 1 "Machine instructions"
9.pp
10The syntax of machine instruction statements accepted by
11.i as
12is generally similar to the syntax of \*(DM.
13There are differences,
14however.
15.SH 2 "Character set"
16.pp
17.i As
18uses the character
19.q \*(DL
20instead of
21.q #
22for immediate constants,
23and the character
24.q *
25instead of
26.q @
27for indirection.
28Opcodes and register names
29are spelled with lower-case rather than upper-case letters.
30.SH 2 "Specifying Displacement Lengths"
31.pp
32Under certain circumstances,
b0ab87d8 33the following constructs are (optionally) recognized by
5cb4b394
RH
34.i as
35to indicate the number of bytes to allocate for
36the displacement used when constructing
37displacement and displacement deferred addressing modes:
38.(b
39.TS
40center;
41c c l
42cb cb l.
43primary alternate length
44_
45B\` B^ byte (1 byte)
46W\` W^ word (2 bytes)
47L\` L^ long word (4 bytes)
48.TE
49.)b
50.pp
51One can also use lower case
52.b b ,
53.b w
54or
55.b l
56instead of the upper
57case letters.
58There must be no space between the size specifier letter and the
59.q "^"
60or
61.q "\`" .
62The constructs
63.b "S^"
64and
65.b "G^"
66are not recognized
67by
68.i as ,
69as they are by the \*(DM assembler.
70It is preferred to use the
71.q "\`" displacement specifier,
72so that the
73.q "^"
74is not
75misinterpreted as the
76.b xor
77operator.
78.pp
79Literal values
80(including floating-point literals used where the
81hardware expects a floating-point operand)
82are assembled as short
83literals if possible,
84hence not needing the
85.b "S^"
86\*(DM directive.
87.pp
88If the displacement length modifier is present,
89then the displacement is
90.b always
91assembled with that displacement,
92even if it will fit into a smaller field,
93or if significance is lost.
94If the length modifier is not present,
b0ab87d8 95and if the value of the displacement is known exactly in
5cb4b394
RH
96.i as 's
97first pass,
98then
99.i as
100determines the length automatically,
101assembling it in the shortest possible way,
102Otherwise,
103.i as
104will use the value specified by the
105.b \-d
106argument,
107which defaults to 4 bytes.
108.SH 2 "case\fIx\fP Instructions"
109.pp
110.i As
111considers the instructions
112.b caseb ,
113.b casel ,
114.b casew
115to have three operands.
116The displacements must be explicitly computed by
117.i as ,
118using one or more
119.b .word
120statements.
121.SH 2 "Extended branch instructions"
122.pp
123These opcodes (formed in general
124by substituting a
125.q j
126for the initial
127.q b
128of the standard opcodes)
129take as branch destinations
130the name of a label in the current subsegment.
131It is an error if the destination is known to be in a different subsegment,
132and it is a warning if the destination is not defined within
133the object module being assembled.
134.pp
135If the branch destination is close enough,
136then the corresponding
137short branch
138.q b
139instruction is assembled.
140Otherwise the assembler choses a sequence
141of one or more instructions which together have the same effect as if the
142.q b
143instruction had a larger span.
144In general,
145.i as
146chooses the inverse branch followed by a
147.b brw ,
148but a
149.b brw
150is sometimes pooled among several
151.q j
152instructions with the same destination.
153.pp
154.i As
155is unable to perform the same long/short branch generation
156for other instructions with a fixed byte displacement,
157such as the
158.b sob ,
159.b aob
160families,
161or for the
162.b acbx
163family of instructions which has a fixed word displacement.
164This would be desirable,
165but is prohibitive because of the complexity of these instructions.
166.pp
167If the
168.b \-J
169assembler option is given,
170a
171.b jmp
172instruction is used instead of a
173.b brw
174instruction
175for
176.b ALL
177.q j
178instructions with distant destinations.
179This makes assembly of large (>32K bytes)
180programs (inefficiently)
181possible.
182.i As
183does not try to use clever combinations of
184.b brb ,
185.b brw
186and
187.b jmp
188instructions.
189The
190.b jmp
191instructions use PC relative addressing,
192with the length of the offset given by the
193.b \-d
194assembler
195option.
196.pp
197These are the extended branch instructions
198.i as
199recognizes:
200.(b
201.TS
202center;
203lb lb lb.
204jeql jeqlu jneq jnequ
205jgeq jgequ jgtr jgtru
206jleq jlequ jlss jlssu
207jbcc jbsc jbcs jbss
208
209jlbc jlbs
210jcc jcs
211jvc jvs
212jbc jbs
213jbr
214.TE
215.)b
216.pp
217Note that
218.b jbr
219turns into
220.b brb
221if its target is close enough;
222otherwise a
223.b brw
224is used.
225.SH 1 "Diagnostics"
226.pp
227Diagnostics are intended to be self explanatory and appear on
228the standard output.
229Diagnostics either report an
230.i error
231or a
232.i warning.
233Error diagnostics complain about lexical, syntactic and some
234semantic errors, and abort the assembly.
235.pp
236The majority of the warnings complain about the use of \*(VX
237features not supported by all implementations of the architecture.
238.i As
239will warn if new opcodes are used,
240if
241.q G
242or
243.q H
244floating point numbers are used
b0ab87d8 245and will complain about mixed floating conversions.
5cb4b394
RH
246.SH 1 "Limits"
247.(b
248.TS
249center;
250l l.
251limit what
252_
253Arbitrary\** Files to assemble
254BUFSIZ Significant characters per name
a6a7cc62
RH
255Arbitrary Characters per input line
256Arbitrary Characters per string
5cb4b394
RH
257Arbitrary Symbols
2584 Text segments
2594 Data segments
260.TE
261.)b
262.(f
263\**Although the number of characters available to the \fIargv\fP line
264is restricted by \*(UX to 10240.
265.)f
266.SH 1 "Annoyances and Future Work"
267.pp
268Most of the annoyances deal with restrictions on the extended
269branch instructions.
270.pp
271.i As
272only uses a two level algorithm for resolving extended branch
273instructions into short or long displacements.
274What is really needed is a general mechanism
275to turn a short conditional jump into a
276reverse conditional jump over one of
277.b two
278possible unconditional branches,
279either a
280.b brw
281or a
282.b jmp
283instruction.
284Currently, the
285.b \-J
286forces the
287.b jmp
288instruction to
289.i always
290be used,
291instead of the
292shorter
293.b brw
294instruction when needed.
295.pp
296The assembler should also recognize extended branch instructions for
297.b sob ,
298.b aob ,
299and
300.b acbx
301instructions.
302.b Sob
303instructions will be easy,
304.b aob
305will be harder because the synthesized instruction
306uses the index operand twice,
307so one must be careful of side effects,
308and the
309.b acbx
310family will be much harder (in the general case)
b0ab87d8 311because the comparison depends on the sign of the addend operand,
5cb4b394
RH
312and two operands are used more than once.
313Augmenting
314.i as
315with these extended loop instructions
b0ab87d8 316will allow the peephole optimizer to produce much better
5cb4b394
RH
317loop optimizations,
318since it currently assumes the worst
319case about the size of the loop body.
a6a7cc62
RH
320.pp
321The string temporary file is not put in memory when the -V flag is set.
322The string table in the generated a.out contains some strings
323and names that are never referenced from the symbol table;
324the loader removes these unreferenced strings, however.