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