xref: /netbsd-src/external/gpl3/binutils.old/dist/gas/doc/c-hppa.texi (revision e992f068c547fd6e84b3f104dc2340adcc955732)
1*e992f068Schristos@c Copyright (C) 1991-2022 Free Software Foundation, Inc.
216dce513Schristos@c This is part of the GAS manual.
316dce513Schristos@c For copying conditions, see the file as.texinfo.
416dce513Schristos@page
516dce513Schristos@node HPPA-Dependent
616dce513Schristos@chapter HPPA Dependent Features
716dce513Schristos
816dce513Schristos@cindex  support
916dce513Schristos@menu
1016dce513Schristos* HPPA Notes::                Notes
1116dce513Schristos* HPPA Options::              Options
1216dce513Schristos* HPPA Syntax::               Syntax
1316dce513Schristos* HPPA Floating Point::       Floating Point
1416dce513Schristos* HPPA Directives::           HPPA Machine Directives
1516dce513Schristos* HPPA Opcodes::              Opcodes
1616dce513Schristos@end menu
1716dce513Schristos
1816dce513Schristos@node HPPA Notes
1916dce513Schristos@section Notes
20ede78133SchristosAs a back end for @sc{gnu} @sc{cc} @code{@value{AS}} has been thoroughly tested and should
2116dce513Schristoswork extremely well.  We have tested it only minimally on hand written assembly
2216dce513Schristoscode and no one has tested it much on the assembly output from the HP
2316dce513Schristoscompilers.
2416dce513Schristos
2516dce513SchristosThe format of the debugging sections has changed since the original
2616dce513Schristos@code{@value{AS}} port (version 1.3X) was released; therefore,
2716dce513Schristosyou must rebuild all HPPA objects and libraries with the new
2816dce513Schristosassembler so that you can debug the final executable.
2916dce513Schristos
3016dce513SchristosThe HPPA @code{@value{AS}} port generates a small subset of the relocations
3116dce513Schristosavailable in the SOM and ELF object file formats.  Additional relocation
3216dce513Schristossupport will be added as it becomes necessary.
3316dce513Schristos
3416dce513Schristos@node HPPA Options
3516dce513Schristos@section Options
3616dce513Schristos@code{@value{AS}} has no machine-dependent command-line options for the HPPA.
3716dce513Schristos
3816dce513Schristos@cindex HPPA Syntax
3916dce513Schristos@node HPPA Syntax
4016dce513Schristos@section Syntax
4116dce513SchristosThe assembler syntax closely follows the HPPA instruction set
4216dce513Schristosreference manual; assembler directives and general syntax closely follow the
4316dce513SchristosHPPA assembly language reference manual, with a few noteworthy differences.
4416dce513Schristos
4516dce513SchristosFirst, a colon may immediately follow a label definition.  This is
4616dce513Schristossimply for compatibility with how most assembly language programmers
4716dce513Schristoswrite code.
4816dce513Schristos
4916dce513SchristosSome obscure expression parsing problems may affect hand written code which
5016dce513Schristosuses the @code{spop} instructions, or code which makes significant
5116dce513Schristosuse of the @code{!} line separator.
5216dce513Schristos
5316dce513Schristos@code{@value{AS}} is much less forgiving about missing arguments and other
5416dce513Schristossimilar oversights than the HP assembler.  @code{@value{AS}} notifies you
5516dce513Schristosof missing arguments as syntax errors; this is regarded as a feature, not a
5616dce513Schristosbug.
5716dce513Schristos
5816dce513SchristosFinally, @code{@value{AS}} allows you to use an external symbol without
5916dce513Schristosexplicitly importing the symbol.  @emph{Warning:} in the future this will be
6016dce513Schristosan error for HPPA targets.
6116dce513Schristos
6216dce513SchristosSpecial characters for HPPA targets include:
6316dce513Schristos
6416dce513Schristos@samp{;} is the line comment character.
6516dce513Schristos
6616dce513Schristos@samp{!} can be used instead of a newline to separate statements.
6716dce513Schristos
6816dce513SchristosSince @samp{$} has no special meaning, you may use it in symbol names.
6916dce513Schristos
7016dce513Schristos@node HPPA Floating Point
7116dce513Schristos@section Floating Point
7216dce513Schristos@cindex floating point, HPPA (@sc{ieee})
7316dce513Schristos@cindex HPPA floating point (@sc{ieee})
7416dce513SchristosThe HPPA family uses @sc{ieee} floating-point numbers.
7516dce513Schristos
7616dce513Schristos@node HPPA Directives
7716dce513Schristos@section HPPA Assembler Directives
7816dce513Schristos
7916dce513Schristos@code{@value{AS}} for the HPPA supports many additional directives for
8016dce513Schristoscompatibility with the native assembler.  This section describes them only
8116dce513Schristosbriefly.  For detailed information on HPPA-specific assembler directives, see
8216dce513Schristos@cite{HP9000 Series 800 Assembly Language Reference Manual} (HP 92432-90001).
8316dce513Schristos
8416dce513Schristos@cindex HPPA directives not supported
8516dce513Schristos@code{@value{AS}} does @emph{not} support the following assembler directives
8616dce513Schristosdescribed in the HP manual:
8716dce513Schristos
8816dce513Schristos@example
8916dce513Schristos.endm           .liston
9016dce513Schristos.enter          .locct
9116dce513Schristos.leave          .macro
9216dce513Schristos.listoff
9316dce513Schristos@end example
9416dce513Schristos
9516dce513Schristos@cindex @code{.param} on HPPA
9616dce513SchristosBeyond those implemented for compatibility, @code{@value{AS}} supports one
9716dce513Schristosadditional assembler directive for the HPPA: @code{.param}.  It conveys
9816dce513Schristosregister argument locations for static functions.  Its syntax closely follows
9916dce513Schristosthe @code{.export} directive.
10016dce513Schristos
10116dce513Schristos@cindex HPPA-only directives
10216dce513SchristosThese are the additional directives in @code{@value{AS}} for the HPPA:
10316dce513Schristos
10416dce513Schristos@table @code
10516dce513Schristos@item .block @var{n}
10616dce513Schristos@itemx .blockz @var{n}
10716dce513SchristosReserve @var{n} bytes of storage, and initialize them to zero.
10816dce513Schristos
10916dce513Schristos@item .call
11016dce513SchristosMark the beginning of a procedure call.  Only the special case with @emph{no
11116dce513Schristosarguments} is allowed.
11216dce513Schristos
11316dce513Schristos@item .callinfo [ @var{param}=@var{value}, @dots{} ]  [ @var{flag}, @dots{} ]
11416dce513SchristosSpecify a number of parameters and flags that define the environment for a
11516dce513Schristosprocedure.
11616dce513Schristos
11716dce513Schristos@var{param} may be any of @samp{frame} (frame size), @samp{entry_gr} (end of
11816dce513Schristosgeneral register range), @samp{entry_fr} (end of float register range),
11916dce513Schristos@samp{entry_sr} (end of space register range).
12016dce513Schristos
12116dce513SchristosThe values for @var{flag} are @samp{calls} or @samp{caller} (proc has
12216dce513Schristossubroutines), @samp{no_calls} (proc does not call subroutines), @samp{save_rp}
12316dce513Schristos(preserve return pointer), @samp{save_sp} (proc preserves stack pointer),
12416dce513Schristos@samp{no_unwind} (do not unwind this proc), @samp{hpux_int} (proc is interrupt
12516dce513Schristosroutine).
12616dce513Schristos
12716dce513Schristos@item .code
12816dce513SchristosAssemble into the standard section called @samp{$TEXT$}, subsection
12916dce513Schristos@samp{$CODE$}.
13016dce513Schristos
13116dce513Schristos@ifset SOM
13216dce513Schristos@item .copyright "@var{string}"
13316dce513SchristosIn the SOM object format, insert @var{string} into the object code, marked as a
13416dce513Schristoscopyright string.
13516dce513Schristos@end ifset
13616dce513Schristos
13716dce513Schristos@ifset ELF
13816dce513Schristos@item .copyright "@var{string}"
13916dce513SchristosIn the ELF object format, insert @var{string} into the object code, marked as a
14016dce513Schristosversion string.
14116dce513Schristos@end ifset
14216dce513Schristos
14316dce513Schristos@item .enter
14416dce513SchristosNot yet supported; the assembler rejects programs containing this directive.
14516dce513Schristos
14616dce513Schristos@item .entry
14716dce513SchristosMark the beginning of a procedure.
14816dce513Schristos
14916dce513Schristos@item .exit
15016dce513SchristosMark the end of a procedure.
15116dce513Schristos
15216dce513Schristos@item .export @var{name} [ ,@var{typ} ]  [ ,@var{param}=@var{r} ]
15316dce513SchristosMake a procedure @var{name} available to callers.  @var{typ}, if present, must
15416dce513Schristosbe one of @samp{absolute}, @samp{code} (ELF only, not SOM), @samp{data},
15516dce513Schristos@samp{entry}, @samp{data}, @samp{entry}, @samp{millicode}, @samp{plabel},
15616dce513Schristos@samp{pri_prog}, or @samp{sec_prog}.
15716dce513Schristos
15816dce513Schristos@var{param}, if present, provides either relocation information for the
15916dce513Schristosprocedure arguments and result, or a privilege level.  @var{param} may be
16016dce513Schristos@samp{argw@var{n}} (where @var{n} ranges from @code{0} to @code{3}, and
16116dce513Schristosindicates one of four one-word arguments); @samp{rtnval} (the procedure's
16216dce513Schristosresult); or @samp{priv_lev} (privilege level).  For arguments or the result,
16316dce513Schristos@var{r} specifies how to relocate, and must be one of @samp{no} (not
16416dce513Schristosrelocatable), @samp{gr} (argument is in general register), @samp{fr} (in
16516dce513Schristosfloating point register), or @samp{fu} (upper half of float register).
16616dce513SchristosFor @samp{priv_lev}, @var{r} is an integer.
16716dce513Schristos
16816dce513Schristos@item .half @var{n}
16916dce513SchristosDefine a two-byte integer constant @var{n}; synonym for the portable
17016dce513Schristos@code{@value{AS}} directive @code{.short}.
17116dce513Schristos
17216dce513Schristos@item .import @var{name} [ ,@var{typ} ]
17316dce513SchristosConverse of @code{.export}; make a procedure available to call.  The arguments
17416dce513Schristosuse the same conventions as the first two arguments for @code{.export}.
17516dce513Schristos
17616dce513Schristos@item .label @var{name}
17716dce513SchristosDefine @var{name} as a label for the current assembly location.
17816dce513Schristos
17916dce513Schristos@item .leave
18016dce513SchristosNot yet supported; the assembler rejects programs containing this directive.
18116dce513Schristos
18216dce513Schristos@item .origin @var{lc}
18316dce513SchristosAdvance location counter to @var{lc}. Synonym for the @code{@value{AS}}
18416dce513Schristosportable directive @code{.org}.
18516dce513Schristos
18616dce513Schristos@item .param @var{name} [ ,@var{typ} ]  [ ,@var{param}=@var{r} ]
18716dce513Schristos@c Not in HP manual; @sc{gnu} HPPA extension
18816dce513SchristosSimilar to @code{.export}, but used for static procedures.
18916dce513Schristos
19016dce513Schristos@item .proc
19116dce513SchristosUse preceding the first statement of a procedure.
19216dce513Schristos
19316dce513Schristos@item .procend
19416dce513SchristosUse following the last statement of a procedure.
19516dce513Schristos
19616dce513Schristos@item @var{label} .reg @var{expr}
19716dce513Schristos@c ?? Not in HP manual (Jan 1988 vn)
19816dce513SchristosSynonym for @code{.equ}; define @var{label} with the absolute expression
19916dce513Schristos@var{expr} as its value.
20016dce513Schristos
20116dce513Schristos@item .space @var{secname} [ ,@var{params} ]
20216dce513SchristosSwitch to section @var{secname}, creating a new section by that name if
20316dce513Schristosnecessary.  You may only use @var{params} when creating a new section, not
20416dce513Schristoswhen switching to an existing one.  @var{secname} may identify a section by
20516dce513Schristosnumber rather than by name.
20616dce513Schristos
20716dce513SchristosIf specified, the list @var{params} declares attributes of the section,
20816dce513Schristosidentified by keywords.  The keywords recognized are @samp{spnum=@var{exp}}
20916dce513Schristos(identify this section by the number @var{exp}, an absolute expression),
21016dce513Schristos@samp{sort=@var{exp}} (order sections according to this sort key when linking;
21116dce513Schristos@var{exp} is an absolute expression), @samp{unloadable} (section contains no
21216dce513Schristosloadable data), @samp{notdefined} (this section defined elsewhere), and
21316dce513Schristos@samp{private} (data in this section not available to other programs).
21416dce513Schristos
21516dce513Schristos@item .spnum @var{secnam}
21616dce513Schristos@c ?? Not in HP manual (Jan 1988)
21716dce513SchristosAllocate four bytes of storage, and initialize them with the section number of
21816dce513Schristosthe section named @var{secnam}.  (You can define the section number with the
21916dce513SchristosHPPA @code{.space} directive.)
22016dce513Schristos
22116dce513Schristos@cindex @code{string} directive on HPPA
22216dce513Schristos@item .string "@var{str}"
22316dce513SchristosCopy the characters in the string @var{str} to the object file.
22416dce513Schristos@xref{Strings,,Strings}, for information on escape sequences you can use in
22516dce513Schristos@code{@value{AS}} strings.
22616dce513Schristos
22716dce513Schristos@emph{Warning!} The HPPA version of @code{.string} differs from the
22816dce513Schristosusual @code{@value{AS}} definition: it does @emph{not} write a zero byte
22916dce513Schristosafter copying @var{str}.
23016dce513Schristos
23116dce513Schristos@item .stringz "@var{str}"
23216dce513SchristosLike @code{.string}, but appends a zero byte after copying @var{str} to object
23316dce513Schristosfile.
23416dce513Schristos
23516dce513Schristos@item .subspa @var{name} [ ,@var{params} ]
23616dce513Schristos@itemx .nsubspa @var{name} [ ,@var{params} ]
23716dce513SchristosSimilar to @code{.space}, but selects a subsection @var{name} within the
23816dce513Schristoscurrent section.  You may only specify @var{params} when you create a
23916dce513Schristossubsection (in the first instance of @code{.subspa} for this @var{name}).
24016dce513Schristos
24116dce513SchristosIf specified, the list @var{params} declares attributes of the subsection,
24216dce513Schristosidentified by keywords.  The keywords recognized are @samp{quad=@var{expr}}
24316dce513Schristos(``quadrant'' for this subsection), @samp{align=@var{expr}} (alignment for
24416dce513Schristosbeginning of this subsection; a power of two), @samp{access=@var{expr}} (value
24516dce513Schristosfor ``access rights'' field), @samp{sort=@var{expr}} (sorting order for this
24616dce513Schristossubspace in link), @samp{code_only} (subsection contains only code),
24716dce513Schristos@samp{unloadable} (subsection cannot be loaded into memory), @samp{comdat}
24816dce513Schristos(subsection is comdat), @samp{common} (subsection is common block),
24916dce513Schristos@samp{dup_comm} (subsection may have duplicate names), or @samp{zero}
25016dce513Schristos(subsection is all zeros, do not write in object file).
25116dce513Schristos
25216dce513Schristos@code{.nsubspa} always creates a new subspace with the given name, even
25316dce513Schristosif one with the same name already exists.
25416dce513Schristos
25516dce513Schristos@samp{comdat}, @samp{common} and @samp{dup_comm} can be used to implement
25616dce513Schristosvarious flavors of one-only support when using the SOM linker.  The SOM
25716dce513Schristoslinker only supports specific combinations of these flags.  The details
25816dce513Schristosare not documented.  A brief description is provided here.
25916dce513Schristos
26016dce513Schristos@samp{comdat} provides a form of linkonce support.  It is useful for
26116dce513Schristosboth code and data subspaces.  A @samp{comdat} subspace has a key symbol
26216dce513Schristosmarked by the @samp{is_comdat} flag or @samp{ST_COMDAT}.  Only the first
26316dce513Schristossubspace for any given key is selected.  The key symbol becomes universal
26416dce513Schristosin shared links.  This is similar to the behavior of @samp{secondary_def}
26516dce513Schristossymbols.
26616dce513Schristos
26716dce513Schristos@samp{common} provides Fortran named common support.  It is only useful
26816dce513Schristosfor data subspaces.  Symbols with the flag @samp{is_common} retain this
26916dce513Schristosflag in shared links.  Referencing a @samp{is_common} symbol in a shared
27016dce513Schristoslibrary from outside the library doesn't work.  Thus, @samp{is_common}
27116dce513Schristossymbols must be output whenever they are needed.
27216dce513Schristos
27316dce513Schristos@samp{common} and @samp{dup_comm} together provide Cobol common support.
27416dce513SchristosThe subspaces in this case must all be the same length.  Otherwise, this
27516dce513Schristossupport is similar to the Fortran common support.
27616dce513Schristos
27716dce513Schristos@samp{dup_comm} by itself provides a type of one-only support for code.
27816dce513SchristosOnly the first @samp{dup_comm} subspace is selected.  There is a rather
27916dce513Schristoscomplex algorithm to compare subspaces.  Code symbols marked with the
28016dce513Schristos@samp{dup_common} flag are hidden.  This support was intended for "C++
28116dce513Schristosduplicate inlines".
28216dce513Schristos
28316dce513SchristosA simplified technique is used to mark the flags of symbols based on
28416dce513Schristosthe flags of their subspace.  A symbol with the scope SS_UNIVERSAL and
28516dce513Schristostype ST_ENTRY, ST_CODE or ST_DATA is marked with the corresponding
28616dce513Schristossettings of @samp{comdat}, @samp{common} and @samp{dup_comm} from the
28716dce513Schristossubspace, respectively.  This avoids having to introduce additional
28816dce513Schristosdirectives to mark these symbols.  The HP assembler sets @samp{is_common}
28916dce513Schristosfrom @samp{common}.  However, it doesn't set the @samp{dup_common} from
29016dce513Schristos@samp{dup_comm}.  It doesn't have @samp{comdat} support.
29116dce513Schristos
29216dce513Schristos@item .version "@var{str}"
29316dce513SchristosWrite @var{str} as version identifier in object code.
29416dce513Schristos@end table
29516dce513Schristos
29616dce513Schristos@node HPPA Opcodes
29716dce513Schristos@section Opcodes
29816dce513SchristosFor detailed information on the HPPA machine instruction set, see
29916dce513Schristos@cite{PA-RISC Architecture and Instruction Set Reference Manual}
30016dce513Schristos(HP 09740-90039).
301