f78
Assembler options for mips
Contents|Index|Previous|Next
Assembler
options for MIPS
The following documentation
discusses the assembler options for MIPS.
To use the GNU assembler, as,
to assemble gcc
output, configure gcc
with the switch, --with-gnu-as
(in GNUPro Toolkit distributions) or with the option, -mgas.
The assembler for MIPS architecture supports the MIPS R2000, R3000, and
R4000 processors.
-mgas
Compile using as
to assemble GCC output.
-Wa
If you invoke as
through the GNU C compiler (version 2), you can use the -Wa
option to pass arguments through to
ffb
the assembler. One common use of this
option is to exploit the assembler’s listing features. Assembler arguments
that you specify with gcc
-Wa
must be separated from each other (and the -Wa)
by commas.
-L
The additional assembler
option -L
preserves local labels, which may make the listing output more intelligible
to humans. For example, in the following commandline, the assembler option,
-ahl,
requests a listing with interspersed high-level language and assembly language.
$ h8300-hms-gcc -c -g -O -Wa,-alh,-L file.c
-L
preserves local labels, while the compiler debugging option, -g,
gives the assembler the necessary debugging information.
Assembler
options for listing output for MIPS
Use the following options
to enable listing output from the assembler (the letters after -a
may be combined into one option, such as -aln):
-a
By itself, -a
requests listings of high-level language source, assembly language, and
symbols.
-ah
Requests a high-level language
listing.
-al
Requests an output-program
assembly listing.
-as
Requests a symbol table
listing.
-ad
Omits debugging directives
from the listing.
High-level listings require
using a compiler debugging option like -g,
and assembly listings (-al)
also need to be requested.
Assembler
listing-control directives for MIPS
Use the following listing-control
assembler directives to control the appearance of the listing output (if
you do not request listing output
ffb
with one of the -a
options, the following listing-control directives have no effect).
.list
Turn on listings from this
point on.
.nolist
Turn off listings from this
point on.
.psize linecount, columnwidth
Describe the page size for
your output (the default is 60, 200). as
generates form feeds after printing each group of linecount
lines. To avoid these automatic form feeds, specify 0
as the linecount.
.eject
Skip to a new page (issue
a form feed).
.title
Use heading
as the title (this is the second line of the listing output, directly after
the source file name and page number) when generating assembly listings.
.sbttl
Use subheading
as the subtitle (this is the third line of the listing output, directly
after the title line) when generating assembly listings.
-an
Turn off all forms processing.
Assembler
options for MIPS
The MIPS configurations of
as
support three special options, and accept one other for command-line compatibility.
See Command-Line
Options in Using
AS in GNUPro Utilities for information on the command-line
options available with all configurations of the GNU assembler.
-G num
This option sets the largest
size of an object that will be referenced implicitly with the gp
register. It is only accepted for targets that use ECOFF format. The default
value is 8.
-EB
-EL
Any MIPS configuration of
as
can select big-endian or little-endian output at run time (unlike the ot
ffb
her
GNU development tools, which must be configured for one or the other).
Use -EB
to select big-endian output, and -EL
for little-endian.
-nocpp
This option is ignored.
It is accepted for command-line compatibility with other assemblers, which
use it to turn off C style preprocessing. With the GNU assembler, there
is no need for -nocpp,
because the GNU assembler itself never runs the C preprocessor.
Assembler
directives for debugging information for MIPS
MIPS ECOFF as
supports several directives used for generating debugging information which
are not supported by traditional MIPS assemblers:
.def .endef .dim
.file .scl .size
.tag .type .val
.stabd .stabn .stabs
The debugging information generated
by the three .stab
directives can only be read by gdb,
not by traditional MIPS debuggers (this enhancement is required to fully
support C++ debugging). These directives are primarily used by compilers,
not assembly language programmers. See Assembler
Directives in Using
AS in Binary Utilities for full information
on all as
directives.
MIPS
ECOFF object code
The assembler supports some
additional sections for a MIPS ECOFF target besides the usual .text,
.data
and .bss.
The additional sections are:
.rdata
.sdata
.sbss
For small common objects
When assembling for ECOFF, the
assembler uses the $gp
($28) register
to form the address of a small object. Any object in the .sdata
or .sbss
section is considered small in this sense. Using small ECOFF objects requires
linker support, and assumes that the $gp
register has been correctly initialized (normally done automatically by
the startup code).
Note:
MIPS ECOFF assembly code
must not modify the $gp
register.
Options
for MIPS ECOFF object code
GCC -G
For external objects, or
for objects in the .bss
section, you can use the gcc
-G
option to control the size of objects addressed via $gp;
the default value is 8,
meaning that a reference to any object eight bytes or smaller will use
$gp.
-G 0
Passing -G
0 to as
prevents as
from using the $gp
register on the basis of object size (the assembler uses $gp
for objects in .sdata
or .sbss
in any case).
Directives
for MIPS ECOFF object code
.comm
.lcomm
The size of an object in
the .bss
section is set by the .comm
or .lcomm
directive that defines it.
.extern
The size of an external
object may be set with the .extern
directive. Use the following input, for example.
.extern sym, 4
This directive declares that
the object at sym
is 4 bytes in length, while leaving sym
otherwise undefined.
Registers
used for integer arguments for MIPS
Arguments on MIPS architectures
are not split, so that if a double word argument starts in R7,
the entire word gets pushed onto the stack instead of being split between
R7
and the stack.
If the first argument is
an integer, the MIPS uses the following registers for all arguments.
The following calling convention
for MIPS architectures depends on whether or not hardware floating-point
is installed. Even if it is, the MIPS uses the registers for integer arguments
whenever the first argument is an integer.
The MIPS uses the registers
for floating-point arguments only for floating-point arguments and only
if the first argument is a floating point.
The following calling convention
for the MIPS also depends on whether you are using standard 32-bit mode
or Cygnus Solutions 64-bit mode; 32-bit mode only allows the MIPS to use
even numbered registers, while 64-bit mode allows the MIPS to use both
odd and even numbered registers.
Note:
Functions compiled with
different calling conventions cannot be run together without some care.
-
The MIPS passes the first four
words of arguments in registers R4
through R7,
which are also called registers A0
through A3.
-
If the function return values
are integers, they are stored in R2
and R3.
Registers
used for floating-point arguments for MIPS
If the first argument is
a floating-point, the MIPS uses the following registers for floating-point
arguments.
-
In 32-bit mode, the MIPS passes
the first four words of arguments in registers F12
and F14.
-
In 64-bit mode, the MIPS passes
the first four words of arguments in registers F12
through F15.
If the function return value
is a floating-point, it’s stored in F0.
Calling
conventions used for integer arguments for MIPS
The following conventions
apply to integer arguments.
R0
is hardwired to the value 0.
R1,
which is also called AT,
is reserved as the assembler’s temporary register. R26
through R29
and R31
have reserved uses. Registers R2
through R15,
R24,
and R25
can be used for temporary values.
When a function is compiled
with the default options, it must return with R16
through R23
and R30
unchanged.
Calling
conventions used for floating-point arguments for MIPS
The following conventions
apply to floating-point arg
60e
uments. None
of the registers has a reserved use.
-
In 32-bit mode, F0
through F18
can be used for temporary values. When a function is compiled with the
default options, it must return with F20
through F30
unchanged.
-
In 64-bit mode, F0
through F19
can be used for temporary values. When a function is compiled with the
default options, it must return with F20
through F31
unchanged.
0