xref: /dflybsd-src/contrib/binutils-2.27/gas/doc/c-hppa.texi (revision e656dc90e3d65d744d534af2f5ea88cf8101ebcf)
1*a9fa9459Szrj@c Copyright (C) 1991-2016 Free Software Foundation, Inc.
2*a9fa9459Szrj@c This is part of the GAS manual.
3*a9fa9459Szrj@c For copying conditions, see the file as.texinfo.
4*a9fa9459Szrj@page
5*a9fa9459Szrj@node HPPA-Dependent
6*a9fa9459Szrj@chapter HPPA Dependent Features
7*a9fa9459Szrj
8*a9fa9459Szrj@cindex  support
9*a9fa9459Szrj@menu
10*a9fa9459Szrj* HPPA Notes::                Notes
11*a9fa9459Szrj* HPPA Options::              Options
12*a9fa9459Szrj* HPPA Syntax::               Syntax
13*a9fa9459Szrj* HPPA Floating Point::       Floating Point
14*a9fa9459Szrj* HPPA Directives::           HPPA Machine Directives
15*a9fa9459Szrj* HPPA Opcodes::              Opcodes
16*a9fa9459Szrj@end menu
17*a9fa9459Szrj
18*a9fa9459Szrj@node HPPA Notes
19*a9fa9459Szrj@section Notes
20*a9fa9459SzrjAs a back end for @sc{gnu} @sc{cc} @code{@value{AS}} has been throughly tested and should
21*a9fa9459Szrjwork extremely well.  We have tested it only minimally on hand written assembly
22*a9fa9459Szrjcode and no one has tested it much on the assembly output from the HP
23*a9fa9459Szrjcompilers.
24*a9fa9459Szrj
25*a9fa9459SzrjThe format of the debugging sections has changed since the original
26*a9fa9459Szrj@code{@value{AS}} port (version 1.3X) was released; therefore,
27*a9fa9459Szrjyou must rebuild all HPPA objects and libraries with the new
28*a9fa9459Szrjassembler so that you can debug the final executable.
29*a9fa9459Szrj
30*a9fa9459SzrjThe HPPA @code{@value{AS}} port generates a small subset of the relocations
31*a9fa9459Szrjavailable in the SOM and ELF object file formats.  Additional relocation
32*a9fa9459Szrjsupport will be added as it becomes necessary.
33*a9fa9459Szrj
34*a9fa9459Szrj@node HPPA Options
35*a9fa9459Szrj@section Options
36*a9fa9459Szrj@code{@value{AS}} has no machine-dependent command-line options for the HPPA.
37*a9fa9459Szrj
38*a9fa9459Szrj@cindex HPPA Syntax
39*a9fa9459Szrj@node HPPA Syntax
40*a9fa9459Szrj@section Syntax
41*a9fa9459SzrjThe assembler syntax closely follows the HPPA instruction set
42*a9fa9459Szrjreference manual; assembler directives and general syntax closely follow the
43*a9fa9459SzrjHPPA assembly language reference manual, with a few noteworthy differences.
44*a9fa9459Szrj
45*a9fa9459SzrjFirst, a colon may immediately follow a label definition.  This is
46*a9fa9459Szrjsimply for compatibility with how most assembly language programmers
47*a9fa9459Szrjwrite code.
48*a9fa9459Szrj
49*a9fa9459SzrjSome obscure expression parsing problems may affect hand written code which
50*a9fa9459Szrjuses the @code{spop} instructions, or code which makes significant
51*a9fa9459Szrjuse of the @code{!} line separator.
52*a9fa9459Szrj
53*a9fa9459Szrj@code{@value{AS}} is much less forgiving about missing arguments and other
54*a9fa9459Szrjsimilar oversights than the HP assembler.  @code{@value{AS}} notifies you
55*a9fa9459Szrjof missing arguments as syntax errors; this is regarded as a feature, not a
56*a9fa9459Szrjbug.
57*a9fa9459Szrj
58*a9fa9459SzrjFinally, @code{@value{AS}} allows you to use an external symbol without
59*a9fa9459Szrjexplicitly importing the symbol.  @emph{Warning:} in the future this will be
60*a9fa9459Szrjan error for HPPA targets.
61*a9fa9459Szrj
62*a9fa9459SzrjSpecial characters for HPPA targets include:
63*a9fa9459Szrj
64*a9fa9459Szrj@samp{;} is the line comment character.
65*a9fa9459Szrj
66*a9fa9459Szrj@samp{!} can be used instead of a newline to separate statements.
67*a9fa9459Szrj
68*a9fa9459SzrjSince @samp{$} has no special meaning, you may use it in symbol names.
69*a9fa9459Szrj
70*a9fa9459Szrj@node HPPA Floating Point
71*a9fa9459Szrj@section Floating Point
72*a9fa9459Szrj@cindex floating point, HPPA (@sc{ieee})
73*a9fa9459Szrj@cindex HPPA floating point (@sc{ieee})
74*a9fa9459SzrjThe HPPA family uses @sc{ieee} floating-point numbers.
75*a9fa9459Szrj
76*a9fa9459Szrj@node HPPA Directives
77*a9fa9459Szrj@section HPPA Assembler Directives
78*a9fa9459Szrj
79*a9fa9459Szrj@code{@value{AS}} for the HPPA supports many additional directives for
80*a9fa9459Szrjcompatibility with the native assembler.  This section describes them only
81*a9fa9459Szrjbriefly.  For detailed information on HPPA-specific assembler directives, see
82*a9fa9459Szrj@cite{HP9000 Series 800 Assembly Language Reference Manual} (HP 92432-90001).
83*a9fa9459Szrj
84*a9fa9459Szrj@cindex HPPA directives not supported
85*a9fa9459Szrj@code{@value{AS}} does @emph{not} support the following assembler directives
86*a9fa9459Szrjdescribed in the HP manual:
87*a9fa9459Szrj
88*a9fa9459Szrj@example
89*a9fa9459Szrj.endm           .liston
90*a9fa9459Szrj.enter          .locct
91*a9fa9459Szrj.leave          .macro
92*a9fa9459Szrj.listoff
93*a9fa9459Szrj@end example
94*a9fa9459Szrj
95*a9fa9459Szrj@cindex @code{.param} on HPPA
96*a9fa9459SzrjBeyond those implemented for compatibility, @code{@value{AS}} supports one
97*a9fa9459Szrjadditional assembler directive for the HPPA: @code{.param}.  It conveys
98*a9fa9459Szrjregister argument locations for static functions.  Its syntax closely follows
99*a9fa9459Szrjthe @code{.export} directive.
100*a9fa9459Szrj
101*a9fa9459Szrj@cindex HPPA-only directives
102*a9fa9459SzrjThese are the additional directives in @code{@value{AS}} for the HPPA:
103*a9fa9459Szrj
104*a9fa9459Szrj@table @code
105*a9fa9459Szrj@item .block @var{n}
106*a9fa9459Szrj@itemx .blockz @var{n}
107*a9fa9459SzrjReserve @var{n} bytes of storage, and initialize them to zero.
108*a9fa9459Szrj
109*a9fa9459Szrj@item .call
110*a9fa9459SzrjMark the beginning of a procedure call.  Only the special case with @emph{no
111*a9fa9459Szrjarguments} is allowed.
112*a9fa9459Szrj
113*a9fa9459Szrj@item .callinfo [ @var{param}=@var{value}, @dots{} ]  [ @var{flag}, @dots{} ]
114*a9fa9459SzrjSpecify a number of parameters and flags that define the environment for a
115*a9fa9459Szrjprocedure.
116*a9fa9459Szrj
117*a9fa9459Szrj@var{param} may be any of @samp{frame} (frame size), @samp{entry_gr} (end of
118*a9fa9459Szrjgeneral register range), @samp{entry_fr} (end of float register range),
119*a9fa9459Szrj@samp{entry_sr} (end of space register range).
120*a9fa9459Szrj
121*a9fa9459SzrjThe values for @var{flag} are @samp{calls} or @samp{caller} (proc has
122*a9fa9459Szrjsubroutines), @samp{no_calls} (proc does not call subroutines), @samp{save_rp}
123*a9fa9459Szrj(preserve return pointer), @samp{save_sp} (proc preserves stack pointer),
124*a9fa9459Szrj@samp{no_unwind} (do not unwind this proc), @samp{hpux_int} (proc is interrupt
125*a9fa9459Szrjroutine).
126*a9fa9459Szrj
127*a9fa9459Szrj@item .code
128*a9fa9459SzrjAssemble into the standard section called @samp{$TEXT$}, subsection
129*a9fa9459Szrj@samp{$CODE$}.
130*a9fa9459Szrj
131*a9fa9459Szrj@ifset SOM
132*a9fa9459Szrj@item .copyright "@var{string}"
133*a9fa9459SzrjIn the SOM object format, insert @var{string} into the object code, marked as a
134*a9fa9459Szrjcopyright string.
135*a9fa9459Szrj@end ifset
136*a9fa9459Szrj
137*a9fa9459Szrj@ifset ELF
138*a9fa9459Szrj@item .copyright "@var{string}"
139*a9fa9459SzrjIn the ELF object format, insert @var{string} into the object code, marked as a
140*a9fa9459Szrjversion string.
141*a9fa9459Szrj@end ifset
142*a9fa9459Szrj
143*a9fa9459Szrj@item .enter
144*a9fa9459SzrjNot yet supported; the assembler rejects programs containing this directive.
145*a9fa9459Szrj
146*a9fa9459Szrj@item .entry
147*a9fa9459SzrjMark the beginning of a procedure.
148*a9fa9459Szrj
149*a9fa9459Szrj@item .exit
150*a9fa9459SzrjMark the end of a procedure.
151*a9fa9459Szrj
152*a9fa9459Szrj@item .export @var{name} [ ,@var{typ} ]  [ ,@var{param}=@var{r} ]
153*a9fa9459SzrjMake a procedure @var{name} available to callers.  @var{typ}, if present, must
154*a9fa9459Szrjbe one of @samp{absolute}, @samp{code} (ELF only, not SOM), @samp{data},
155*a9fa9459Szrj@samp{entry}, @samp{data}, @samp{entry}, @samp{millicode}, @samp{plabel},
156*a9fa9459Szrj@samp{pri_prog}, or @samp{sec_prog}.
157*a9fa9459Szrj
158*a9fa9459Szrj@var{param}, if present, provides either relocation information for the
159*a9fa9459Szrjprocedure arguments and result, or a privilege level.  @var{param} may be
160*a9fa9459Szrj@samp{argw@var{n}} (where @var{n} ranges from @code{0} to @code{3}, and
161*a9fa9459Szrjindicates one of four one-word arguments); @samp{rtnval} (the procedure's
162*a9fa9459Szrjresult); or @samp{priv_lev} (privilege level).  For arguments or the result,
163*a9fa9459Szrj@var{r} specifies how to relocate, and must be one of @samp{no} (not
164*a9fa9459Szrjrelocatable), @samp{gr} (argument is in general register), @samp{fr} (in
165*a9fa9459Szrjfloating point register), or @samp{fu} (upper half of float register).
166*a9fa9459SzrjFor @samp{priv_lev}, @var{r} is an integer.
167*a9fa9459Szrj
168*a9fa9459Szrj@item .half @var{n}
169*a9fa9459SzrjDefine a two-byte integer constant @var{n}; synonym for the portable
170*a9fa9459Szrj@code{@value{AS}} directive @code{.short}.
171*a9fa9459Szrj
172*a9fa9459Szrj@item .import @var{name} [ ,@var{typ} ]
173*a9fa9459SzrjConverse of @code{.export}; make a procedure available to call.  The arguments
174*a9fa9459Szrjuse the same conventions as the first two arguments for @code{.export}.
175*a9fa9459Szrj
176*a9fa9459Szrj@item .label @var{name}
177*a9fa9459SzrjDefine @var{name} as a label for the current assembly location.
178*a9fa9459Szrj
179*a9fa9459Szrj@item .leave
180*a9fa9459SzrjNot yet supported; the assembler rejects programs containing this directive.
181*a9fa9459Szrj
182*a9fa9459Szrj@item .origin @var{lc}
183*a9fa9459SzrjAdvance location counter to @var{lc}. Synonym for the @code{@value{AS}}
184*a9fa9459Szrjportable directive @code{.org}.
185*a9fa9459Szrj
186*a9fa9459Szrj@item .param @var{name} [ ,@var{typ} ]  [ ,@var{param}=@var{r} ]
187*a9fa9459Szrj@c Not in HP manual; @sc{gnu} HPPA extension
188*a9fa9459SzrjSimilar to @code{.export}, but used for static procedures.
189*a9fa9459Szrj
190*a9fa9459Szrj@item .proc
191*a9fa9459SzrjUse preceding the first statement of a procedure.
192*a9fa9459Szrj
193*a9fa9459Szrj@item .procend
194*a9fa9459SzrjUse following the last statement of a procedure.
195*a9fa9459Szrj
196*a9fa9459Szrj@item @var{label} .reg @var{expr}
197*a9fa9459Szrj@c ?? Not in HP manual (Jan 1988 vn)
198*a9fa9459SzrjSynonym for @code{.equ}; define @var{label} with the absolute expression
199*a9fa9459Szrj@var{expr} as its value.
200*a9fa9459Szrj
201*a9fa9459Szrj@item .space @var{secname} [ ,@var{params} ]
202*a9fa9459SzrjSwitch to section @var{secname}, creating a new section by that name if
203*a9fa9459Szrjnecessary.  You may only use @var{params} when creating a new section, not
204*a9fa9459Szrjwhen switching to an existing one.  @var{secname} may identify a section by
205*a9fa9459Szrjnumber rather than by name.
206*a9fa9459Szrj
207*a9fa9459SzrjIf specified, the list @var{params} declares attributes of the section,
208*a9fa9459Szrjidentified by keywords.  The keywords recognized are @samp{spnum=@var{exp}}
209*a9fa9459Szrj(identify this section by the number @var{exp}, an absolute expression),
210*a9fa9459Szrj@samp{sort=@var{exp}} (order sections according to this sort key when linking;
211*a9fa9459Szrj@var{exp} is an absolute expression), @samp{unloadable} (section contains no
212*a9fa9459Szrjloadable data), @samp{notdefined} (this section defined elsewhere), and
213*a9fa9459Szrj@samp{private} (data in this section not available to other programs).
214*a9fa9459Szrj
215*a9fa9459Szrj@item .spnum @var{secnam}
216*a9fa9459Szrj@c ?? Not in HP manual (Jan 1988)
217*a9fa9459SzrjAllocate four bytes of storage, and initialize them with the section number of
218*a9fa9459Szrjthe section named @var{secnam}.  (You can define the section number with the
219*a9fa9459SzrjHPPA @code{.space} directive.)
220*a9fa9459Szrj
221*a9fa9459Szrj@cindex @code{string} directive on HPPA
222*a9fa9459Szrj@item .string "@var{str}"
223*a9fa9459SzrjCopy the characters in the string @var{str} to the object file.
224*a9fa9459Szrj@xref{Strings,,Strings}, for information on escape sequences you can use in
225*a9fa9459Szrj@code{@value{AS}} strings.
226*a9fa9459Szrj
227*a9fa9459Szrj@emph{Warning!} The HPPA version of @code{.string} differs from the
228*a9fa9459Szrjusual @code{@value{AS}} definition: it does @emph{not} write a zero byte
229*a9fa9459Szrjafter copying @var{str}.
230*a9fa9459Szrj
231*a9fa9459Szrj@item .stringz "@var{str}"
232*a9fa9459SzrjLike @code{.string}, but appends a zero byte after copying @var{str} to object
233*a9fa9459Szrjfile.
234*a9fa9459Szrj
235*a9fa9459Szrj@item .subspa @var{name} [ ,@var{params} ]
236*a9fa9459Szrj@itemx .nsubspa @var{name} [ ,@var{params} ]
237*a9fa9459SzrjSimilar to @code{.space}, but selects a subsection @var{name} within the
238*a9fa9459Szrjcurrent section.  You may only specify @var{params} when you create a
239*a9fa9459Szrjsubsection (in the first instance of @code{.subspa} for this @var{name}).
240*a9fa9459Szrj
241*a9fa9459SzrjIf specified, the list @var{params} declares attributes of the subsection,
242*a9fa9459Szrjidentified by keywords.  The keywords recognized are @samp{quad=@var{expr}}
243*a9fa9459Szrj(``quadrant'' for this subsection), @samp{align=@var{expr}} (alignment for
244*a9fa9459Szrjbeginning of this subsection; a power of two), @samp{access=@var{expr}} (value
245*a9fa9459Szrjfor ``access rights'' field), @samp{sort=@var{expr}} (sorting order for this
246*a9fa9459Szrjsubspace in link), @samp{code_only} (subsection contains only code),
247*a9fa9459Szrj@samp{unloadable} (subsection cannot be loaded into memory), @samp{comdat}
248*a9fa9459Szrj(subsection is comdat), @samp{common} (subsection is common block),
249*a9fa9459Szrj@samp{dup_comm} (subsection may have duplicate names), or @samp{zero}
250*a9fa9459Szrj(subsection is all zeros, do not write in object file).
251*a9fa9459Szrj
252*a9fa9459Szrj@code{.nsubspa} always creates a new subspace with the given name, even
253*a9fa9459Szrjif one with the same name already exists.
254*a9fa9459Szrj
255*a9fa9459Szrj@samp{comdat}, @samp{common} and @samp{dup_comm} can be used to implement
256*a9fa9459Szrjvarious flavors of one-only support when using the SOM linker.  The SOM
257*a9fa9459Szrjlinker only supports specific combinations of these flags.  The details
258*a9fa9459Szrjare not documented.  A brief description is provided here.
259*a9fa9459Szrj
260*a9fa9459Szrj@samp{comdat} provides a form of linkonce support.  It is useful for
261*a9fa9459Szrjboth code and data subspaces.  A @samp{comdat} subspace has a key symbol
262*a9fa9459Szrjmarked by the @samp{is_comdat} flag or @samp{ST_COMDAT}.  Only the first
263*a9fa9459Szrjsubspace for any given key is selected.  The key symbol becomes universal
264*a9fa9459Szrjin shared links.  This is similar to the behavior of @samp{secondary_def}
265*a9fa9459Szrjsymbols.
266*a9fa9459Szrj
267*a9fa9459Szrj@samp{common} provides Fortran named common support.  It is only useful
268*a9fa9459Szrjfor data subspaces.  Symbols with the flag @samp{is_common} retain this
269*a9fa9459Szrjflag in shared links.  Referencing a @samp{is_common} symbol in a shared
270*a9fa9459Szrjlibrary from outside the library doesn't work.  Thus, @samp{is_common}
271*a9fa9459Szrjsymbols must be output whenever they are needed.
272*a9fa9459Szrj
273*a9fa9459Szrj@samp{common} and @samp{dup_comm} together provide Cobol common support.
274*a9fa9459SzrjThe subspaces in this case must all be the same length.  Otherwise, this
275*a9fa9459Szrjsupport is similar to the Fortran common support.
276*a9fa9459Szrj
277*a9fa9459Szrj@samp{dup_comm} by itself provides a type of one-only support for code.
278*a9fa9459SzrjOnly the first @samp{dup_comm} subspace is selected.  There is a rather
279*a9fa9459Szrjcomplex algorithm to compare subspaces.  Code symbols marked with the
280*a9fa9459Szrj@samp{dup_common} flag are hidden.  This support was intended for "C++
281*a9fa9459Szrjduplicate inlines".
282*a9fa9459Szrj
283*a9fa9459SzrjA simplified technique is used to mark the flags of symbols based on
284*a9fa9459Szrjthe flags of their subspace.  A symbol with the scope SS_UNIVERSAL and
285*a9fa9459Szrjtype ST_ENTRY, ST_CODE or ST_DATA is marked with the corresponding
286*a9fa9459Szrjsettings of @samp{comdat}, @samp{common} and @samp{dup_comm} from the
287*a9fa9459Szrjsubspace, respectively.  This avoids having to introduce additional
288*a9fa9459Szrjdirectives to mark these symbols.  The HP assembler sets @samp{is_common}
289*a9fa9459Szrjfrom @samp{common}.  However, it doesn't set the @samp{dup_common} from
290*a9fa9459Szrj@samp{dup_comm}.  It doesn't have @samp{comdat} support.
291*a9fa9459Szrj
292*a9fa9459Szrj@item .version "@var{str}"
293*a9fa9459SzrjWrite @var{str} as version identifier in object code.
294*a9fa9459Szrj@end table
295*a9fa9459Szrj
296*a9fa9459Szrj@node HPPA Opcodes
297*a9fa9459Szrj@section Opcodes
298*a9fa9459SzrjFor detailed information on the HPPA machine instruction set, see
299*a9fa9459Szrj@cite{PA-RISC Architecture and Instruction Set Reference Manual}
300*a9fa9459Szrj(HP 09740-90039).
301