as [-a[cdhlns][=file]] [-D] [–defsym sym=val] [-I dir] [-o objs] [-R] [-W] [–warn] [target-options]
[-mthumb] [-EB|-EL] [-mapcs-32|-mapcs-26|-mapcs-float|-mapcs-reentrant] [-mthumb-interwork] [-moabi] [-k]
-a[cdhlmns]
|
|||
-ac
|
omit false conditionals
|
-ah
|
include high-level source
|
-ad
|
omit debugging directives
|
-al
|
include assembly
|
-an
|
omit forms processing
|
-am
|
include macro expansions
|
|
|
-as
|
include symbols
|
|
|
--defsym sym=value
|
Define
the symbol sym to be value before assembling the input
file. value must be an integer constant
|
-I dir
|
Add
directory dir to the
search list for .include directives.
|
-o objfile
|
Name
the object-file output from as objfile
|
--no-warn/-W
|
Suppress warning messages.
|
--fatal-warnings
|
Treat warnings as errors.
|
--warn
|
Don’t suppress warning messages or treat them as errors.
|
-mcpu=processor[+extension...]
|
specifies the target processor: arm7tdmi, arm8, strongarm, arm9, arm9tdmi, arm10t, xscale.
|
-march=architecture[+extension...]
|
specifies the target architecture: armv1, armv2, armv3, armv4, armv5, armv5te, armv5texp iwmmxt and xscale.
|
-mfpu=floating-point-format
|
specifies the floating point format: softfpa, fpe, fpa, fsoftvfp, softvfp+vfp, vfp, vfpxd, arm1020e.
|
-mapcs [26|32]
|
specifies that the output generated by the assembler should be marked as
supporting the indicated version of the
Arm Procedure Calling Standard.
|
internal preprocessor
|
removes extra whitespace: leaves one space or tab before the keywords on
a line, and turns any other whitespace on the line into a single space. Whitespace is one or more blanks or
tabs.
|
removes all comments, replaced with a single space, or an appropriate
number of newlines.
/* comment*/; line comment character ,‘@’ on the ARM; ‘#’ on the i386
|
converts character constants into the appropriate numeric values.
|
symbol
|
one or more characters chosen from the set of all letters, digits and the
three characters ‘_.$’. On most machines, you can
also use $ in symbol names.
‘.’ refers to the current
address. Expression ‘melvin: .long .’ defines melvin to
contain its own address.
|
statement
|
ends at a newline (‘\n’) or line separator (‘;’). A statement begins with zero or more labels. If the symbol begins
with a dot ‘.’ then the statement is an
assembler directive. If a letter the statement is an assembly language instruction.
|
label
|
A label is a symbol immediately followed by a colon (:). It represents the current value
of the active location counter.
|
constant
|
a number, written so that its value is known by inspection(Either ‘#’ or ‘$’ can be used to indicate
immediate operands.). Like this:
.byte
74, 0112, 092, 0x
.ascii
"Ring the bell\7" # A string constant.
.octa
0x123456789abcdef0123456789ABCDEF0 #
A bignum.
.float
95028841971.693993751E-40
# - pi, a flonum.
|
assembler directives
|
|
.abort
|
stops
the assembly immediately
|
.err
|
it will print an error message and, it will not generate an object file.
|
.end
|
marks the end of the assembly file. It does not process anything in the
file past the .end directive.
|
.print
“string”
|
print string on
the standard output during assembly.
|
.align
abs-expr,
abs-expr,
abs-expr
|
Pad location counter to a particular storage boundary.
The first expression is the alignment required.
The second expression gives the fill value to be stored in the
padding bytes. If it is omitted, the padding bytes are normally zero.
The third expression , if it is present, it is the maximum number of
bytes that should be skipped by this alignment directive.
|
|
|
.data
subsection
|
Indicate the following statements onto the end of the data subsection subsection (absolute expression). If
omitted, it defaults to zero.
|
.byte
expressions
|
.byte expects zero or more expressions, separated by commas. Each expression is
assembled into the next byte.
|
.ascii
"string"
|
expects zero or more string separated by commas. It assembles each string
(with no automatic trailing zero byte) into consecutive addresses.
|
.int
expressions
|
Expect zero or more expressions, of any section, separated by
commas.
|
.long
expressions
|
the same as ‘.int’
|
.float
flonums
|
expects zero or more flonums, separated by commas.
|
.double
flonums
|
expects zero or more flonums, separated by commas.
|
|
|
.equ
symbol, expr
|
sets the value of symbol to expression. It is synonymous with ‘.set’.
|
.global
symbol,
.globl
symbol
|
makes the symbol visible to ld. If symbol
defined in partial program, its
value is made available to other partial programs that are linked with it.
|
.comm
symbol
,
length
|
declares a common symbol named symbol. When linking, if ld does not see a definition for the
symbol then it will allocate length bytes of uninitialized
memory. If ld sees multiple common symbols
with the same name, it will allocate space using the largest size.
|
.func
name[,label]
|
.func emits debugging information
to denote function name, and is ignored unless the file is assembled with debugging enabled. The
function must be terminated with .endfunc.
|
.macro
|
.macro
and .endm define macros that generate
assembly output.
|
.include
"file"
|
include
supporting files at specified points in your source program.
|
.org
new-lc , fill
|
Advance
location counter of current section to new-lc. new-lc is either an absolute expr
or an expr with same section as the current subsection.
|
.if
absolute expr
|
marks
the beginning of a section of code assembled if argument is nonzero. It
ends with .endif
|
.ifeq absolute expr
|
Assembles
the following section of code if the argument is zero.
|
.ifdef
symbol
|
Assembles the following section of code if symbol has been defined.
|
ARM Machine Directives
|
|
name .req regName
|
This
creates an alias for register name called name.( foo .req r0)
|
.code [16|32]
.thumb .arm
|
This
directive selects the instruction set being generated. The value 16 selects Thumb,
with the value 32 selecting ARM.
|
nop
|
evaluate to a legal ARM instruction that does nothing(MOV r0, r0)
|
ldr
<register> , = <expr>
|
If expr evaluates to a numeric constant then a MOV or MVN instruction will be used in place of the LDR
instruction.
If the constant can be generated by either of these instructions.
Otherwise the constant will be placed into the nearest literal pool and a PC relative LDR instruction will be generated.
|
adr
<register> <label>
|
Load the address of label into the indicated register. It will evaluate to a PC relative ADD or SUB instruction depending upon
where the label is located.
|
adrl
<register> <label>
|
Load the address of label into the indicated register. It will evaluate to one or
two PC relative ADD or SUB instructions depending upon where the label is
located. If a second instruction is not needed a NOP will be in its place, so
that this instruction is always 8 bytes long.
|
|
|
section
|
A
section is a range of addresses, with no gaps; all data “in” those addresses is
treated the same for some particular purpose.
The
linker LD reads many object files (partial
programs) and combines their contents to form a runnable program.
When AS emits an object file, the partial
program is assumed to start at address 0. LD assigns the final addresses for
the partial program, so that different partial programs do not overlap. LD moves blocks of bytes of the program
to their run-time addresses. These blocks slide to their run-time addresses
as rigid units; their length does not change and neither does the order of
bytes within them. Such a rigid unit is called a section. Assigning runtime addresses
to sections is called relocation. It includes the task of
adjusting mentions of object-file addresses so they refer to the proper
run-time addresses.
An object file written by AS has at least three sections, any of which may be empty. These are named text, data and bss sections. When it generates
COFF or ELF output, AS can also generate whatever other named sections you specify using the ‘.section’ directive. Within the
object file, the text section starts at address 0, the data section follows, and the
bss section follows the data section.
Any address whose section is unknown at assembly time is by definition
rendered {undefined U}—where U is filled in later. The only way
to generate an undefined address is to mention an undefined symbol.
|
relocation
|
• Where
in the object file is the beginning of this reference to an address?
• How long
(in bytes) is this reference?
• Which
section does
the address refer to? What is the numeric value of (address) − (start-address of section)?
• Is the reference to an address “Program-Counter relative”? In
fact, every address as ever uses is expressed as (section) + (offset
into section)
It use the notation {secname N} to mean “offset N into section secname.”
Addresses in the absolute section remain unchanged. address {absolute 0} is “relocated” to run-time
address 0 by ld.
|
bss section
|
Contains zeroed bytes when your program begins running. It is used to
hold uninitialized variables or common storage.
|
Sub-Sections
Assembled
bytes conventionally fall into two sections: text and data. You may have separate
groups of data in named sections that you want to end up near to each other in the
object file, even though they are not contiguous in the assembler source. AS allows
you to use subsections
for this
purpose. Within each section, there can be numbered subsections with values
from 0 to 8192. Objects assembled into the same subsection go into the
object file together with other objects in the same subsection. For example, a
compiler might want to store constants in the text section, but might not want
to have them interspersed with the program being assembled. In this case, the
compiler could issue a ‘.text 0’ before each section of
code being output, and a ‘.text 1’ before each group of
constants being output.
bss
Section
The
bss section is used for local common variable storage. You may allocate address
space in the bss section, but you may not dictate data to load into it before
your program executes. When your program starts running, all the contents of
the bss section are zeroed bytes.
No comments:
Post a Comment