GNU AS ARM Reference Gas ARMRef

User Manual: GasARMRef

Open the PDF directly: View PDF PDF.
Page Count: 1

DownloadGNU AS ARM Reference Gas ARMRef
Open PDF In BrowserView PDF
Assembler Control Directives
Directive
.arm
.thum b
.code 16
.code 32
.include
.align
.balign
.balignw

.balignl

.end
.fail
.err
.print
.section
.tex t

.data

.bss

.struct

.org
.pool

Description
Following opcodes use the ARM instruction set
Following opcodes use the THUMB instruction subset
Same as .thum b
Same as .arm
Include a file.
Byte align the following code to alignment byte boundary
(default=4). Fill skipped bytes with fill (defa ult=0 or
NOP). If the number of bytes skipped is greater than max,
then don't align (de fault=alignm ent ).
Same as .align
Half-word align the following code to alignment byte
boundary (default=4). Fill skipped half-words with fill
(default=0 or NOP). If the number of bytes skipped is
greater than max, then don't align (default=alignm ent ).
W ord align the following code to alignment byte boundary
(default=4). Fill skipped words with fill (default=0 or
NOP). If the number of bytes skipped is greater than max,
then don't align (de fault=alignm ent ).
Marks the end of the assembly file. Data following this
directive is not processed.
Generates errors or warnings durring assembly. If expr is
greater than or equal to 500, it prints a warning message.
If less than it prints an error message.
Generate an error durring assembly.
Print a string to standard output durring assembly.
Tell the assembler to assemble the following in section
expr . expr can be either .text, .data, or .bss.
Tell assembler to assemble the following in the "text"
(code) section. You can also specify a subsection of "text"
with subsection .
Tell assembler to assemble the following in the "data"
section. You can also specify a subsection of "data" with
subsection .
Tell assembler to assemble the following in the "bss"
(variables) section. You can also specify a subsection of
"bss" with subsection .
Tell assembler to assemble the following in an absolute
section. Be sure to switch sections before you get back to
code or data.
feild1 is 0.

Syntax

Macro Directives

.arm
.thumb
.code 16
.code 32
.include "file"

Exam ple
.arm
.thum b
.code 16
.code 32
.include "hardware.i"

.align {alignment} {, fill} {, max}

.align

.balign {alignment} {, fill} {, max}

.balign 8, 0

.balignw {alignment} {, fill} {, max}

.balignw 2

.balignl {alignment} {, fill} {, max}

.balignl

.endm
.exitm

Directive
.macro

.end

.end

\@

.fail expr

.fail 1

.purgem

.err
.print string

.err
.print "Something is broken"

.section expr

.section .bss

.text {subsection}

.text

.data {subsection}

.data 0

.bss {subsection}

.bss

.struct expr

field2 is 4.
Following code is inserted at the start of the section plus
.org new-lc {, fill}
new-lc .
Tell the assembler where it can safely place data for
immediate 32bit loads (ideally after your return). Use the = .pool
prefix operator to pool the value. ldr r0, =0x4000002

Description
Define a macro.
A macro can be defined without arguments,
and can be called simply by specifying its name.
A macro can also be defined with arguments,
and can be called the same way with commas seperating its
arguments.
Arguments can be accessed by their name prefixed with a \.
You can define default macro arguments.
Arguments are omited by simply placing a comma and no
value, or ignoring them all together (trailing only).
Arguments can be set in a modified order by referencing
them by name.
Macros can be recursive.
Mark the end of a macro.
Exit a macro early.

.equiv
.global
.globl

Description
Set the value of symbol equal to expr .
Same as .equ
Set the value of symbol equal to expr . Generates an error
if the symbol has been previously defined.
Makes symbol visible to the linker.
Same as .global

.pool

.equiv symbol, expr

.equiv Version, "0.2"

.global symbol
.globl symbol

.globa l MyAsmFunc
.globl MyOtherAsmFunc

Constant Definition Directives
Directive
.byte
.hword
.short
.word
.int
.long
.ascii
.asciz
.string
.quad
.octa
.float
.single
.double
.fill
.zero
.space
.skip

Description
Define byte expr (8bit numbers)
Define half-word expr (16bit numbers)
Same as .hw ord
Define word expr (32bit numbers)
Same as .word
Same as .word
Define string expr (non zero terminated array of bytes)
Define string expr (ze ro terminated array of bytes)
Same as .asciz
Define bignum expr (break at 8bit increments)
Define bignum expr (break at 16bit increments)
Define 32bit IEEE flonum expr (floating point numbers)
Same as .float
Define 64bit IEEE flonum expr (floating point numbers)
Generate repeat copies of value that is of size size . size
defaults to 1, and value defaults to 0.
Fills in size bytes with 0.
Fills in size bytes with value . value defaults to 0.
Same as .spa ce

Syntax
.byte expr {, …}
.hword expr {, …}
.short expr {, …}
.word expr {, …}
.int expr {, …}
.long expr {, …}
.ascii expr {, …}
.asciz expr {, …}
.string expr {, …}
.quad expr {, …}
.octa expr {, …}
.float expr {, …}
.single expr {, …}
.double expr {, …}

Example
.byte 25, 0x11, 031, 'A
.hword 2, 0xFFE0
.short 257
.word 144511, 0x11223
.int 21
.long 1923, 0b10010101
.ascii "Ascii text is here"
.asciz "Zero Terminated Text"
.string "My Cool String\n"
.qua d 0xDAFADAFA911
.octa 0xFEDCBA987654321
.floa t 0f3.14, 0F359.2e11
.single 0f12341243.14E2
.double 0f2E1

.fill repeat {, size} {, value}

.fill 32, 4, 0xFFFFFFFF

.zero size
.space size {, value}
.skip size {, value}

.zero 400
.space 25, 0b11001100
.skip 22

Assembly Listing Directives
Directive
.eje ct

.psize

.list
.nolist
.title
.sbttl

Description
Force a page break when generating assembly listings.
Set the number of lines to generate for each page of the
assembly listing and the number of columns . Lines
defaults to 60, Columns defaults to 200. A page break is
generated when the number of lines hits lines . If lines is
0, then no page breaks are generated (excluding ones by
.e je ct).
Start generation of an assembly listings from .list to
.nolist.
End generation of an assembly listing. Listings can be restarted with .list again.
Uses heading as the title (2nd line, under filename and
page number)
Uses heading as the title (3rd line, under .title )

Syntax

Example

.eject

.eject

.psize lines {, columns}

.psize 40, 80

.list

.list

.nolist

.nolist

.title "heading"

.title "My Asm Output"

.sbttl "heading

.sbttl "Part 1: Cool stuff"

Conditional Directives
Directive
.if
.else if
.else
.endif
.ifdef
.ifnde f
.ifnotdef
.ifc
.ifnc
.ifeqs
.ifnes
.ifeq
.ifne
.ifge
.ifgt
.ifle
.iflt

Description
Assembles if absolute_expression does not equal zero.
For all If's, if absolute_expression is omited, it equals 0.
Assembles if absolute_expression does not equal zero.
Used in .if blocks to provide alternates when previous .if's
or .e lseif's fail.
Assembles if all previous .if and .elseif blocks failed.
Ends an .if block.
Assembles if symb ol exists.
Assembles if symb ol does not exist.
Same as .ifndef
Assembles if the strings are the same.
Assembles if the strings are not the same.
Same as .ifc
Same as .ife qs
Assembles if absolute_expression equals zero.
Assembles if absolute_expression does not equal zero.
Assembles if absolute_expression is greater than or equal
to zero.
Assembles if absolute_expression is greater than zero.
Assembles if absolute_expression is less than or equal to
zero.
Assembles if absolute_expression is less than zero.

Syntax

Example

.if {absolute_expression}

.if (2+2)

.elseif {absolute_expression}

.elseif (2+3) - 5

.else
.endif
.ifdef symbol
.ifndef symbol
.ifnotdef symbol
.ifc string1, string2
.ifnc string1, string2
.ifeqs string1, string2
.ifnes string1, string2
.ifeq {absolute_expression}
.ifne {absolute_expression}

.else
.endif
.ifde f _test_i_
.ifndef _test_i_
.ifnotdef _test_i_
.ifc "this", "that"
.ifnc "this", "that"
.ifeqs "those", "this"
.ifne s "those", "this"
.ifeq (2+2) - 4
.ifne (2+2) - 5

.ifge {absolute_expression}

.ifge 10

.ifgt {absolute_expression}

.ifgt

.ifle {absolute_expression}

.ifle

.iflt {absolute_expression}

.iflt -10

Debug Directives
Directive
.func
.endfunc
.stabs

Description
Syntax
Example
Generate debug information for code as a function. If label
.func name {, label}
.func CoolFunc
is omited, label is assumed to be name .
Mark the end of a function.
.endfunc
.endfunc
See GAS documentation for info. Not very useful unless
.stabs string, type, other, desc, value
your generate assembly listings from another source.

Looping Directives
Directive
.rept
.irp
.irpc
.endr

Description
Repeat the sequence of lines between .rept and .e ndr
count number of times.
Evaluate a comma delimited sequence of statements to
assign to the value of symbol .
For each character in values , assign its value.
Symbol can be referenced with \symbol.
End .re pt, .irp, and .irpc sequences.

Syntax

Example

.rept count

.rept 10

.irp symbol, values…

.irp newval, 1, 2, 3

.irp symbol, value
\symbol
.endr

.irp newval, 123
.byte 0xC\new val
.endr

ArgMacro 10, 11
mov r0, \arg

\arg

.macro ArgMacro arg=1, arg2
ArgMacro , 11
ArgMacro arg2=11, arg=10
.endm
.exitm

.endm
.exitm

MyLabel\@:
.purgem NoArgsMacro

Base
10
16
8
1
10
n/a
n/a
Base

Prefix
0x or 0X
0
0b or 0B
0f or 0F
'
" and "
Prefix

Digits
0-9
0 - 9, A - F (10 - 15)
0-7
0-1
0-9
Ascii Symbol
Ascii Symbol(s)
Digits

Exa mple
25
0xD7
027
0b11010
0f+24.112E-25
'c
"MyString\n"
Exa mple

Escape Codes
\
\b
\f
\n
\r
\t

.org 0x20000

Exam ple
.equ Version, "0.1"
.set Flavor, "CHERRY"

name {args, …}

Digit Encoding Formats
Numbe r Type
Decimal Inte ge r
Hex adecima l Integer
Octa l Integer
Bina ry Inte ger
Floa ting Point Num ber
Cha racter
String
Numbe r Type

.struct 0
field1:
.struct field1 + 4
field2:

Syntax
.equ symbol, expr
.set symbol, expr

Example
.macro NoArgsMacro
NoArgsMacro
.macro ArgMacro arg, arg2

Psudo variable that contains the macro number executed.
\@
Can be used for a unique number on every macro definition.
Undefine a macro, so that further uses do not evaluate.
.purgem name

Symbol Directives
Directive
.equ
.set

Syntax
.macro name {args, …}

De scription
Backspace
Form Feed
New Line
Carrige Return
Horizontol Tab

Ascii
8
12
10
13
9

\
\###
\x##
\\
\"

De scription
Octal Character Code
Hex Character Code
\ character
" character

Expression Operators
Precedence
prefix
prefix
Highest
Highest
Highest
Highest
Highest
Intermediate
Intermediate
Intermediate
Intermediate
Lowest
Lowest
Precedence

Symbol
~
*
/
%
<< or <
>> or >
|
&
^
!
+
Symbol

Name
Negate
Compliment
Multiplication
Division
Remainder
Left Shift
Right Shift
Bitwise OR
Bitwise AND
Bitwise XOR
Bitwise OR NOT
Addition
Subtraction
Name

Operation
Negate argument.
Compliment argument.
Multiply arg1 by arg2.
Divide arg1 by arg2.
Divide arg1 by arg2, and return the remainder.
Shift arg1 left by arg2.
Shift arg1 right by arg2.
OR arg1 with arg2.
AND arg1 with arg2.
XOR arg1 with arg2.
OR arg1 with arg2, and NOT result.
Add arg1 to arg2.
Subtract arg2 from arg1.
Operation



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
Create Date                     : 2001:09:16 14:13:21
Producer                        : Acrobat Distiller 4.05 for Windows
Author                          : 
Creator                         : Pscript.dll Version 5.0
Title                           : GNU AS ARM Reference
Modify Date                     : 2001:09:16 14:16:24-04:00
Page Count                      : 1
Page Mode                       : UseNone
EXIF Metadata provided by EXIF.tools

Navigation menu