Red Hat Enterprise Linux 4
Using as, the Gnu Assembler
Red Hat Enterprise Linux 4: Using as, the Gnu Assembler
Copyright © 1987, 1989, 1991-2004 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document underthe terms of the GNU Free Documentation
License, Version 1.1 or any later version published by the Free Software Foundation. A copy of the licenseis included in the
section entitled "GNU Free Documentation License".
This manual contains no Invariant Sections. The Front-Cover Texts are (a) (see below), and the Back-CoverTexts are (b) (see
below).
(a) The FSF’s Front-Cover Text is: A GNU Manual
(b) The FSF’s Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies
published by the Free Software Foundationraise funds for GNU development.
This version is by Red Hat, Inc.
Red Hat, Inc.
1801 Varsity Drive
Raleigh NC 27606-2072 USA
Phone: +1 919 754 3700
Phone: 888 733 4281
Fax: +1 919 754 3701
PO Box 13588
Research Triangle Park NC 27709 USA
as(EN)-4-Print-RHI (2005-02-01)
Red Hat and the Red Hat "Shadow Man" logo are registered trademarks of Red Hat, Inc. in the United States and other
countries.
All other trademarks referencedherein are the property of their respective owners.
The GPG fingerprint of the security@redhat.comkey is:
CA 20 86 86 2B D6 9D FC 65 F6 EC C4 21 91 80 CD DB 42 A6 0E
Table of Contents
1. Using as ............................................................................................................................................ 1
2. Overview .......................................................................................................................................... 3
2.1. Structure of this Manual...................................................................................................15
2.2. The GNU Assembler........................................................................................................15
2.3. Object File Formats.......................................................................................................... 15
2.4. Command Line................................................................................................................. 16
2.5. Input Files ........................................................................................................................ 16
2.5.1. Filenames and Line-numbers ............................................................................16
2.6. Output (Object) File ......................................................................................................... 17
2.7. Error and Warning Messages...........................................................................................17
3. Command-Line Options............................................................................................................... 19
3.1. Enable Listings: -a[cdhlns] .........................................................................................19
3.2. -alternate ....................................................................................................................19
3.3. -D .....................................................................................................................................19
3.4. Work Faster: -f ................................................................................................................20
3.5. .include Search Path: -Ipath ......................................................................................20
3.6. Difference Tables: -K .......................................................................................................20
3.7. Include Local Labels: -L ................................................................................................. 20
3.8. Configuring listing output: -listing ............................................................................. 20
3.9. Assemble in MRI Compatibility Mode: -M .....................................................................21
3.10. Dependency Tracking: -MD ............................................................................................ 22
3.11. Name the Object File: -o ...............................................................................................23
3.12. Join Data and Text Sections: -R ..................................................................................... 23
3.13. Display Assembly Statistics: -statistics ................................................................. 23
3.14. Compatible Output: -traditional-format ..............................................................23
3.15. Announce Version: -v ...................................................................................................23
3.16. Control Warnings: -W , -warn , -no-warn , -fatal-warnings ..................................23
3.17. Generate Object File in Spite of Errors: -Z ...................................................................24
4. Syntax............................................................................................................................................. 25
4.1. Preprocessing ...................................................................................................................25
4.2. Whitespace.......................................................................................................................25
4.3. Comments ........................................................................................................................ 25
4.4. Symbols ...........................................................................................................................26
4.5. Statements........................................................................................................................ 26
4.6. Constants..........................................................................................................................27
4.6.1. Character Constants ..........................................................................................27
4.6.2. Number Constants............................................................................................. 28
5. Sections and Relocation................................................................................................................31
5.1. Background...................................................................................................................... 31
5.2. Linker Sections ................................................................................................................ 32
5.3. Assembler Internal Sections ............................................................................................ 33
5.4. Sub-Sections .................................................................................................................... 33
5.5. bss Section .......................................................................................................................34
6. Symbols .......................................................................................................................................... 35
6.1. Labels............................................................................................................................... 35
6.2. Giving Symbols Other Values..........................................................................................35
6.3. Symbol Names................................................................................................................. 35
6.3.1. Local Symbol Names ........................................................................................35
6.3.2. Dollar Local Labels........................................................................................... 36
6.4. The Special Dot Symbol ..................................................................................................37
6.5. Symbol Attributes ............................................................................................................ 37
6.5.1. Value .................................................................................................................37
6.5.2. Type...................................................................................................................37
6.5.3. Symbol Attributes: a.out ................................................................................37
6.5.4. Symbol Attributes for COFF ............................................................................38
6.5.5. Symbol Attributes for SOM.............................................................................. 38
7. Expressions ....................................................................................................................................39
7.1. Empty Expressions...........................................................................................................39
7.2. Integer Expressions..........................................................................................................39
7.2.1. Arguments......................................................................................................... 39
7.2.2. Operators........................................................................................................... 39
7.2.3. Prefix Operator..................................................................................................39
7.2.4. Infix Operators ..................................................................................................40
8. Assembler Directives..................................................................................................................... 43
8.1. .abort ............................................................................................................................. 43
8.2. .ABORT ............................................................................................................................. 43
8.3. .align abs-expr , abs-expr , abs-expr ...................................................................43
8.4. .ascii "string " . . .......................................................................................................43
8.5. .asciz "string " . . .......................................................................................................44
8.6. .balign[wl] abs-expr , abs-expr , abs-expr ........................................................44
8.7. .byte expressions ....................................................................................................... 44
8.8. .comm symbol , length ................................................................................................. 44
8.9. .cfi_startproc ........................................................................................................... 45
8.10. .cfi_endproc .............................................................................................................. 45
8.11. .cfi_def_cfa register , offset ............................................................................45
8.12. .cfi_def_cfa_register register ........................................................................ 45
8.13. .cfi_def_cfa_offset offset ................................................................................. 45
8.14. .cfi_adjust_cfa_offset offset .......................................................................... 45
8.15. .cfi_offset register , offset .............................................................................. 45
8.16. .cfi_rel_offset register , offset .....................................................................45
8.17. .cfi_window_save .....................................................................................................45
8.18. .cfi_escapeexpression [, .. . ].................................................................................46
8.19. .data subsection .......................................................................................................46
8.20. .def name .....................................................................................................................46
8.21. .desc symbol , abs-expression ...............................................................................46
8.22. .dim ...............................................................................................................................46
8.23. .double flonums ......................................................................................................... 46
8.24. .eject ...........................................................................................................................46
8.25. .else .............................................................................................................................46
8.26. .elseif ........................................................................................................................ 47
8.27. .end ...............................................................................................................................47
8.28. .endef ...........................................................................................................................47
8.29. .endfunc ...................................................................................................................... 47
8.30. .endif ...........................................................................................................................47
8.31. .equ symbol , expression .........................................................................................47
8.32. .equiv symbol , expression .....................................................................................47
8.33. .err ...............................................................................................................................48
8.34. .exitm ...........................................................................................................................48
8.35. .extern ........................................................................................................................ 48
8.36. .fail expression .......................................................................................................48
8.37. .file string ............................................................................................................... 48
8.38. .fill repeat , size , value .....................................................................................48
8.39. .float flonums ........................................................................................................... 48
8.40. .func name [,label ] ................................................................................................... 49
8.41. .global symbol , .globl symbol .............................................................................. 49
8.42. .hidden names .............................................................................................................49
8.43. .hword expressions ...................................................................................................49
8.44. .ident ...........................................................................................................................49
8.45. .if absolute expression .......................................................................................... 49
8.46. .incbin "file "[,skip [,count ]] ............................................................................ 51
8.47. .include "file " ........................................................................................................51
8.48. .int expressions .......................................................................................................51
8.49. .internal names ........................................................................................................ 51
8.50. .irp symbol ,values . . . .............................................................................................. 51
8.51. .irpc symbol ,values . . . ............................................................................................ 52
8.52. .lcomm symbol , length ............................................................................................. 52
8.53. .lflags ........................................................................................................................ 52
8.54. .line line-number ..................................................................................................... 52
8.55. .linkonce [type ] ......................................................................................................53
8.56. .ln line-number .........................................................................................................53
8.57. .mri val .......................................................................................................................53
8.58. .list .............................................................................................................................53
8.59. .long expressions ..................................................................................................... 54
8.60. .macro ...........................................................................................................................54
8.61. .altmacro .................................................................................................................... 55
8.62. .noaltmacro ................................................................................................................56
8.63. .nolist ........................................................................................................................ 56
8.64. .octa bignums .............................................................................................................56
8.65. .org new-lc , fill ..................................................................................................... 56
8.66. .p2align[wl] abs-expr , abs-expr , abs-expr ....................................................56
8.67. .previous .................................................................................................................... 57
8.68. .popsection ................................................................................................................57
8.69. .print string ............................................................................................................. 57
8.70. .protected names ...................................................................................................... 57
8.71. .psize lines , columns ............................................................................................. 57
8.72. .purgem name .............................................................................................................. 58
8.73. .pushsection name , subsection ............................................................................58
8.74. .quad bignums .............................................................................................................58
8.75. .rept count ................................................................................................................. 58
8.76. .sbttl "subheading " .................................................................................................58
8.77. .scl class ................................................................................................................... 59
8.78. .section name ............................................................................................................ 59
8.78.1. COFF Version .................................................................................................59
8.78.2. ELF Version ....................................................................................................60
8.79. .set symbol , expression .........................................................................................62
8.80. .short expressions ...................................................................................................62
8.81. .single flonums ......................................................................................................... 62
8.82. .size .............................................................................................................................63
8.82.1. COFF Version .................................................................................................63
8.82.2. ELF Version ....................................................................................................63
8.83. .sleb128 expressions ............................................................................................... 63
8.84. .skip size , fill .......................................................................................................63
8.85. .space size , fill ..................................................................................................... 63
8.86. .stabd, .stabn, .stabs ........................................................................................ 64
8.87. .string "str "...............................................................................................................65
8.88. .struct expression ...................................................................................................65
8.89. .subsection name ......................................................................................................65
8.90. .symver ........................................................................................................................ 65
8.91. .tag structname ......................................................................................................... 66
8.92. .text subsection .......................................................................................................66
8.93. .title "heading " ......................................................................................................66
8.94. .type .............................................................................................................................66
8.94.1. COFF Version .................................................................................................66
8.94.2. ELF Version ....................................................................................................67
8.95. .uleb128 expressions ............................................................................................... 67
8.96. .val addr .....................................................................................................................67
8.97. .version "string " .................................................................................................... 67
8.98. .vtable_entry table , offset ................................................................................68
8.99. .vtable_inherit child , parent ...........................................................................68
8.100. .weak names ............................................................................................................... 68
8.101. .word expressions ................................................................................................... 68
8.102. Deprecated Directives ..................................................................................................69
9. Machine Dependent Features ......................................................................................................71
10. AMD 29K Dependent Features..................................................................................................73
10.1. Options...........................................................................................................................73
10.2. Syntax ............................................................................................................................ 73
10.2.1. Macros.............................................................................................................73
10.2.2. Special Characters...........................................................................................73
10.2.3. Register Names ...............................................................................................73
10.3. Floating Point................................................................................................................. 74
10.4. AMD 29K Machine Directives......................................................................................74
10.5. Opcodes..........................................................................................................................74
11. Alpha Dependent Features.........................................................................................................75
11.1. Notes ..............................................................................................................................75
11.2. Options...........................................................................................................................75
11.3. Syntax ............................................................................................................................ 76
11.3.1. Special Characters...........................................................................................76
11.3.2. Register Names ...............................................................................................76
11.3.3. Relocations......................................................................................................76
11.4. Floating Point................................................................................................................. 78
11.5. Alpha Assembler Directives ..........................................................................................78
11.6. Opcodes..........................................................................................................................80
12. ARC Dependent Features...........................................................................................................83
12.1. Options...........................................................................................................................83
12.2. Syntax ............................................................................................................................ 83
12.2.1. Special Characters...........................................................................................83
12.2.2. Register Names ...............................................................................................83
12.3. Floating Point................................................................................................................. 84
12.4. ARC Machine Directives ............................................................................................... 84
12.5. Opcodes..........................................................................................................................85
13. ARM Dependent Features.......................................................................................................... 87
13.1. Options...........................................................................................................................87
13.2. Syntax ............................................................................................................................ 89
13.2.1. Special Characters...........................................................................................89
13.2.2. Register Names ...............................................................................................89
13.3. Floating Point................................................................................................................. 89
13.4. ARM Machine Directives .............................................................................................. 89
13.5. Opcodes..........................................................................................................................90
13.6. Mapping Symbols .......................................................................................................... 91
14. CRIS Dependent Features.......................................................................................................... 93
14.1. Command-line Options ..................................................................................................93
14.2. Instruction expansion .....................................................................................................93
14.3. Syntax ............................................................................................................................ 93
14.3.1. Special Characters...........................................................................................93
14.3.2. Symbols in position-independent code ........................................................... 94
14.3.3. Register names ................................................................................................95
14.3.4. Assembler Directives......................................................................................95
15. D10V Dependent Features..........................................................................................................97
15.1. D10V Options ................................................................................................................97
15.2. Syntax ............................................................................................................................ 97
15.2.1. Size Modifiers .................................................................................................97
15.2.2. Sub-Instructions .............................................................................................. 97
15.2.3. Special Characters...........................................................................................98
15.2.4. Register Names ...............................................................................................98
15.2.5. Addressing Modes ........................................................................................100
15.2.6. @WORD Modifier........................................................................................ 100
15.3. Floating Point............................................................................................................... 100
15.4. Opcodes........................................................................................................................101
16. D30V Dependent Features........................................................................................................103
16.1. D30V Options ..............................................................................................................103
16.2. Syntax ..........................................................................................................................103
16.2.1. Size Modifiers ............................................................................................... 103
16.2.2. Sub-Instructions ............................................................................................ 103
16.2.3. Special Characters.........................................................................................103
16.2.4. Guarded Execution........................................................................................105
16.2.5. Register Names .............................................................................................105
16.2.6. Addressing Modes ........................................................................................107
16.3. Floating Point............................................................................................................... 107
16.4. Opcodes........................................................................................................................107
17. H8/300 Dependent Features .....................................................................................................109
17.1. Options.........................................................................................................................109
17.2. Syntax ..........................................................................................................................109
17.2.1. Special Characters.........................................................................................109
17.2.2. Register Names .............................................................................................109
17.2.3. Addressing Modes ........................................................................................109
17.3. Floating Point............................................................................................................... 110
17.4. H8/300 Machine Directives .........................................................................................110
17.5. Opcodes........................................................................................................................111
18. H8/500 Dependent Features .....................................................................................................113
18.1. Options.........................................................................................................................113
18.2. Syntax ..........................................................................................................................113
18.2.1. Special Characters.........................................................................................113
18.2.2. Register Names .............................................................................................113
18.2.3. Addressing Modes ........................................................................................113
18.3. Floating Point............................................................................................................... 114
18.4. H8/500 Machine Directives .........................................................................................114
18.5. Opcodes........................................................................................................................114
19. HPPA Dependent Features.......................................................................................................117
19.1. Notes ............................................................................................................................117
19.2. Options.........................................................................................................................117
19.3. Syntax ..........................................................................................................................117
19.4. Floating Point............................................................................................................... 117
19.5. HPPA Assembler Directives ........................................................................................ 117
19.6. Opcodes........................................................................................................................121
20. ESA/390 Dependent Features .................................................................................................. 123
20.1. Notes ............................................................................................................................123
20.2. Options.........................................................................................................................123
20.3. Syntax ..........................................................................................................................123
20.4. Floating Point............................................................................................................... 124
20.5. ESA/390 Assembler Directives ................................................................................... 124
20.6. Opcodes........................................................................................................................125
21. 80386 Dependent Features .......................................................................................................127
21.1. Options.........................................................................................................................127
21.2. AT&T Syntax versus Intel Syntax ............................................................................... 127
21.3. Instruction Naming ......................................................................................................128
21.4. Register Naming ..........................................................................................................128
21.5. Instruction Prefixes ......................................................................................................129
21.6. Memory References .....................................................................................................130
21.7. Handling of Jump Instructions..................................................................................... 131
21.8. Floating Point............................................................................................................... 131
21.9. Intel’s MMX and AMD’s 3DNow! SIMD Operations ................................................ 132
21.10. Writing 16-bit Code ...................................................................................................132
21.11. AT&T Syntax bugs ....................................................................................................132
21.12. Specifying CPU Architecture ....................................................................................133
21.13. Notes ..........................................................................................................................133
22. Intel i860 Dependent Features .................................................................................................135
22.1. i860 Notes ....................................................................................................................135
22.2. i860 Command-line Options........................................................................................ 135
22.2.1. SVR4 compatibility options..........................................................................135
22.2.2. Other options.................................................................................................135
22.3. i860 Machine Directives .............................................................................................. 136
22.4. i860 Opcodes ............................................................................................................... 136
22.4.1. Other instruction support (pseudo-instructions) ........................................... 136
23. Intel 80960 Dependent Features .............................................................................................. 139
23.1. i960 Command-line Options........................................................................................ 139
23.2. Floating Point............................................................................................................... 140
23.3. i960 Machine Directives .............................................................................................. 140
23.4. i960 Opcodes ............................................................................................................... 140
23.4.1. callj ............................................................................................................141
23.4.2. Compare-and-Branch....................................................................................141
24. IP2K Dependent Features ........................................................................................................143
24.1. IP2K Options ............................................................................................................... 143
25. M32R Dependent Features....................................................................................................... 145
25.1. M32R Options.............................................................................................................. 145
25.2. M32R Directives..........................................................................................................147
25.3. M32R Warnings...........................................................................................................148
26. M680x0 Dependent Features.................................................................................................... 151
26.1. M680x0 Options .......................................................................................................... 151
26.2. Syntax ..........................................................................................................................153
26.3. Motorola Syntax........................................................................................................... 154
26.4. Floating Point............................................................................................................... 155
26.5. 680x0 Machine Directives ...........................................................................................156
26.6. Opcodes........................................................................................................................156
26.6.1. Branch Improvement..................................................................................... 156
26.6.2. Special Characters.........................................................................................158
27. M68HC11 and M68HC12 Dependent Features .....................................................................159
27.1. M68HC11 and M68HC12 Options ..............................................................................159
27.2. Syntax ..........................................................................................................................160
27.3. Symbolic Operand Modifiers ....................................................................................... 161
27.4. Assembler Directives...................................................................................................162
27.5. Floating Point............................................................................................................... 163
27.6. Opcodes........................................................................................................................163
27.6.1. Branch Improvement..................................................................................... 163
28. Motorola M88K Dependent Features...................................................................................... 165
28.1. M88K Machine Directives...........................................................................................165
29. MIPS Dependent Features ....................................................................................................... 167
29.1. Assembler options........................................................................................................167
29.2. MIPS ECOFF object code ...........................................................................................169
29.3. Directives for debugging information.......................................................................... 170
29.4. Directives to override the ISA level.............................................................................170
29.5. Directives for extending MIPS 16 bit instructions....................................................... 170
29.6. Directive to mark data as an instruction....................................................................... 170
29.7. Directives to save and restore options..........................................................................170
29.8. Directives to control generation of MIPS ASE instructions ........................................171
30. MMIX Dependent Features ..................................................................................................... 173
30.1. Command-line Options ................................................................................................173
30.2. Instruction expansion ...................................................................................................173
30.3. Syntax ..........................................................................................................................174
30.3.1. Special Characters.........................................................................................174
30.3.2. Symbols ........................................................................................................174
30.3.3. Register names ..............................................................................................175
30.3.4. Assembler Directives....................................................................................175
30.4. Differences to mmixal ................................................................................................. 177
31. MSP 430 Dependent Features.................................................................................................. 181
31.1. Options.........................................................................................................................181
31.2. Syntax ..........................................................................................................................181
31.2.1. Macros...........................................................................................................181
31.2.2. Special Characters.........................................................................................181
31.2.3. Register Names .............................................................................................181
31.2.4. Assembler Extensions................................................................................... 182
31.3. Floating Point............................................................................................................... 183
31.4. MSP 430 Machine Directives ......................................................................................183
31.5. Opcodes........................................................................................................................183
31.6. Profiling Capability......................................................................................................183
32. PDP-11 Dependent Features .................................................................................................... 187
32.1. Options.........................................................................................................................187
32.1.1. Code Generation Options..............................................................................187
32.1.2. Instruction Set Extension Options ................................................................187
32.1.3. CPU Model Options......................................................................................188
32.1.4. Machine Model Options ...............................................................................189
32.2. Assembler Directives...................................................................................................190
32.3. PDP-11 Assembly Language Syntax ........................................................................... 190
32.4. Instruction Naming ......................................................................................................191
32.5. Synthetic Instructions...................................................................................................191
33. picoJava Dependent Features ..................................................................................................193
33.1. Options.........................................................................................................................193
34. PowerPC Dependent Features .................................................................................................195
34.1. Options.........................................................................................................................195
34.2. PowerPC Assembler Directives...................................................................................196
35. Renesas / SuperH SH Dependent Features............................................................................. 197
35.1. Options.........................................................................................................................197
35.2. Syntax ..........................................................................................................................197
35.2.1. Special Characters.........................................................................................197
35.2.2. Register Names .............................................................................................197
35.2.3. Addressing Modes ........................................................................................198
35.3. Floating Point............................................................................................................... 199
35.4. SH Machine Directives ................................................................................................ 199
35.5. Opcodes........................................................................................................................199
36. SuperH SH64 Dependent Features.......................................................................................... 201
36.1. Options.........................................................................................................................201
36.2. Syntax ..........................................................................................................................201
36.2.1. Special Characters.........................................................................................202
36.2.2. Register Names .............................................................................................202
36.2.3. Addressing Modes ........................................................................................202
36.3. SH64 Machine Directives ............................................................................................ 202
36.4. Opcodes........................................................................................................................203
37. SPARC Dependent Features ....................................................................................................205
37.1. Options.........................................................................................................................205
37.2. Enforcing aligned data .................................................................................................205
37.3. Floating Point............................................................................................................... 206
37.4. Sparc Machine Directives ............................................................................................206
38. TIC54X Dependent Features ...................................................................................................209
38.1. Options.........................................................................................................................209
38.2. Blocking.......................................................................................................................209
38.3. Environment Settings................................................................................................... 209
38.4. Constants Syntax..........................................................................................................209
38.5. String Substitution ....................................................................................................... 209
38.6. Local Labels................................................................................................................. 210
38.7. Math Builtins ...............................................................................................................211
38.8. Extended Addressing ...................................................................................................213
38.9. Directives ..................................................................................................................... 213
38.10. Macros........................................................................................................................218
38.11. Memory-mapped Registers ........................................................................................ 219
39. Z8000 Dependent Features....................................................................................................... 221
39.1. Options.........................................................................................................................221
39.2. Syntax ..........................................................................................................................221
39.2.1. Special Characters.........................................................................................221
39.2.2. Register Names .............................................................................................221
39.2.3. Addressing Modes ........................................................................................221
39.3. Assembler Directives for the Z8000 ............................................................................ 222
39.4. Opcodes........................................................................................................................223
40. VAX Dependent Features .........................................................................................................225
40.1. VAX Command-Line Options .....................................................................................225
40.2. VAX Floating Point...................................................................................................... 226
40.3. Vax Machine Directives...............................................................................................226
40.4. VAX Opcodes ..............................................................................................................227
40.5. VAX Branch Improvement .......................................................................................... 227
40.6. VAX Operands.............................................................................................................229
40.7. Not Supported on VAX................................................................................................ 229
41. v850 Dependent Features ......................................................................................................... 231
41.1. Options.........................................................................................................................231
41.2. Syntax ..........................................................................................................................231
41.2.1. Special Characters.........................................................................................232
41.2.2. Register Names .............................................................................................232
41.3. Floating Point............................................................................................................... 234
41.4. V850 Machine Directives ............................................................................................234
41.5. Opcodes........................................................................................................................235
42. Xtensa Dependent Features...................................................................................................... 239
42.1. Command Line Options...............................................................................................239
42.2. Assembler Syntax ........................................................................................................239
42.2.1. Opcode Names ..............................................................................................240
42.2.2. Register Names .............................................................................................240
42.3. Xtensa Optimizations................................................................................................... 240
42.3.1. Using Density Instructions............................................................................240
42.3.2. Automatic Instruction Alignment .................................................................241
42.4. Xtensa Relaxation ........................................................................................................241
42.4.1. Conditional Branch Relaxation .....................................................................241
42.4.2. Function Call Relaxation .............................................................................. 242
42.4.3. Other Immediate Field Relaxation ................................................................ 242
42.5. Directives ..................................................................................................................... 243
42.5.1. density...........................................................................................................244
42.5.2. relax...............................................................................................................244
42.5.3. longcalls ........................................................................................................245
42.5.4. generics ......................................................................................................... 245
42.5.5. literal ............................................................................................................. 245
42.5.6. literal_position ..............................................................................................246
42.5.7. literal_prefix..................................................................................................246
42.5.8. freeregs.......................................................................................................... 246
42.5.9. frame .............................................................................................................247
43. Reporting Bugs.......................................................................................................................... 249
43.1. Have You Found a Bug? ..............................................................................................249
43.2. How to Report Bugs.....................................................................................................249
44. Acknowledgements ................................................................................................................... 253
A. GNU Free Documentation License ........................................................................................... 255
A.1. ADDENDUM: How to use this License for your documents.......................................259
Index.................................................................................................................................................261
Using as
Chapter 1.
Using as
This file is a user guide to the gnu assembler as version 2.15.92.0.2.
This document is distributed under the terms of the GNU Free Documentation License. A copy of the
license is included in the section entitled "GNU Free Documentation License".
2 Chapter 1. Using as
Chapter 2.
Overview
Here is a brief summary of how to invoke as . For details, Chapter 3 Command-Line Options .
as [-a [cdhlns ][=file ]] [--alternate ] [-D ]
[--defsym sym =val ] [-f ] [-g ] [--gstabs ] [--gstabs+ ]
[--gdwarf-2 ] [--help ] [-I dir ] [-J ] [-K ] [-L ]
[--listing-lhs-width =NUM ] [--listing-lhs-width2 =NUM ]
[--listing-rhs-width =NUM ] [--listing-cont-lines =NUM ]
[--keep-locals ] [-o objfile ] [-R ] [--statistics ] [-v ]
[-version ] [--version ] [-W ] [--warn ] [--fatal-warnings ]
[-w ] [-x ] [-Z ] [--target-help ] [target-options ]
[--|files ...]
Target Alpha options:
[-mcpu ]
[-mdebug | -no-mdebug ]
[-relax ] [-g ] [-Gsize ]
[-F ] [-32addr ]
Target ARC options:
[-marc[5|6|7|8] ]
[-EB |-EL ]
Target ARM options:
[-mcpu =processor [+extension ...]]
[-march =architecture [+extension ...]]
[-mfpu =floating-point-format ]
[-mfloat-abi =abi ]
[-meabi =ver ]
[-mthumb ]
[-EB |-EL ]
[-mapcs-32 |-mapcs-26 |-mapcs-float |
-mapcs-reentrant ]
[-mthumb-interwork ] [-moabi ] [-k ]
Target CRIS options:
[--underscore | --no-underscore ]
[--pic ] [-N ]
[--emulation=criself | --emulation=crisaout ]
Target D10V options:
[ -O]
Target D30V options:
[ -O| -n| -N ]
Target i386 options:
[ --32| --64] [ -n]
Target i960 options:
[ -ACA| -ACA_A| -ACB| -ACC| -AKA| -AKB|
-AKC| -AMC]
[ -b] [ -no-relax]
Target IP2K options:
[ -mip2022| -mip2022ext]
4 Chapter 2. Overview
Target M32R options:
[ --m32rx| --[no-]warn-explicit-parallel-conflicts|
--W[n]p]
Target M680X0 options:
[ -l] [ -m68000| -m68010| -m68020|...]
Target M68HC11 options:
[-m68hc11 |-m68hc12 |-m68hcs12 ]
[-mshort |-mlong ]
[-mshort-double |-mlong-double ]
[--force-long-branchs ] [--short-branchs ]
[--strict-direct-mode ] [--print-insn-syntax ]
[--print-opcodes ] [--generate-example ]
Target MCORE options:
[-jsri2bsr ] [-sifilter ] [-relax ]
[-mcpu=[210|340] ]
Target MIPS options:
[-nocpp ] [-EL ] [-EB ] [-O [optimization level ]]
[-g [debug level ]] [-G num ] [-KPIC ] [-call_shared ]
[-non_shared ] [-xgot ]
[-mabi =ABI ] [-32 ] [-n32 ] [-64 ] [-mfp32 ] [-mgp32 ]
[-march =CPU ] [-mtune =CPU ] [-mips1 ] [-mips2 ]
[-mips3 ] [-mips4 ] [-mips5 ] [-mips32 ] [-mips32r2 ]
[-mips64 ] [-mips64r2 ]
[-construct-floats ] [-no-construct-floats ]
[-trap ] [-no-break ] [-break ] [-no-trap ]
[-mfix7000 ] [-mno-fix7000 ]
[-mips16 ] [-no-mips16 ]
[-mips3d ] [-no-mips3d ]
[-mdmx ] [-no-mdmx ]
[-mdebug ] [-no-mdebug ]
[-mpdr ] [-mno-pdr ]
Target MMIX options:
[--fixed-special-register-names ] [--globalize-symbols ]
[--gnu-syntax ] [--relax ] [--no-predefined-symbols ]
[--no-expand ] [--no-merge-gregs ] [-x ]
[--linker-allocated-gregs ]
Target PDP11 options:
[-mpic |-mno-pic ] [-mall ] [-mno-extensions ]
[-mextension |-mno-extension ]
[-mcpu ] [-mmachine ]
Target picoJava options:
[ -mb| -me]
Target PowerPC options:
[ -mpwrx| -mpwr2| -mpwr| -m601| -mppc| -mppc32| -m603| -m604|
-m403| -m405| -mppc64| -m620| -mppc64bridge| -mbooke|
-mbooke32| -mbooke64]
[-mcom |-many |-maltivec ] [-memb ]
[-mregnames |-mno-regnames ]
[-mrelocatable |-mrelocatable-lib ]
[-mlittle |-mlittle-endian |-mbig |-mbig-endian ]
[-msolaris |-mno-solaris ]
Target SPARC options:
Chapter 2. Overview 5
[ -Av6| -Av7| -Av8| -Asparclet| -Asparclite
-Av8plus| -Av8plusa| -Av9| -Av9a]
[-xarch=v8plus |-xarch=v8plusa ] [-bump ]
[-32 |-64 ]
Target TIC54X options:
[-mcpu=54[123589] |-mcpu=54[56]lp ] [-mfar-mode |-mf ]
[-merrors-to-file
Target Xtensa options:
[--[no-]density ] [--[no-]relax ] [--[no-]generics ]
[--[no-]text-section-literals ]
[--[no-]target-align ] [--[no-]longcalls ]
filename
|-me
filename
]
-a[cdhlmns]
Turn on listings, in any of a variety of ways:
-ac
omit false conditionals
-ad
omit debugging directives
-ah
include high-level source
-al
include assembly
-am
include macro expansions
-an
omit forms processing
-as
include symbols
=file
set the name of the listing file
You may combine these options; for example, use -aln for assembly listing without forms processing. The =file option, if used, must be the last one. By itself, -a defaults to -ahls .
-alternate
Begin in alternate macro mode, see Section 8.61 .altmacro .
-D
Ignored. This option is accepted for script compatibility with calls to other assemblers.
6 Chapter 2. Overview
-defsym sym =value
Define the symbol sym to be value before assembling the input file. value must be an integer
constant. As in C, a leading 0x indicates a hexadecimal value, and a leading 0 indicates an octal
value.
-f
"fast"--skip whitespace and comment preprocessing (assume source is compiler output).
-g
-gen-debug
Generate debugging information for each assembler source line using whichever debug format is
preferred by the target. This currently means either STABS, ECOFF or DWARF2.
-gstabs
Generate stabs debugging information for each assembler line. This may help debugging assembler code, if the debugger can handle it.
-gstabs+
Generate stabs debugging information for each assembler line, with GNU extensions that probably only gdb can handle, and that could make other debuggers crash or refuse to read your
program. This may help debugging assembler code. Currently the only GNU extension is the
location of the current working directory at assembling time.
-gdwarf-2
Generate DWARF2 debugging information for each assembler line. This may help debugging
assembler code, ifthe debugger can handle it. Note--this option is only supported by some targets,
not all of them.
-help
Print a summary of the command line options and exit.
-target-help
Print a summary of all target specific options and exit.
-I dir
Add directory dir to the search list for .include directives.
-J
Don’t warn about signed overflow.
-K
Issue warnings when difference tables altered for long displacements.
-L
-keep-locals
Keep (in the symbol table) local symbols. On traditional a.out systems these start with L , but
different systems have different local label prefixes.
-listing-lhs-width=number
Set the maximum width, in words, of the output data column for an assembler listing to number .
Chapter 2. Overview 7
-listing-lhs-width2=number
Set the maximum width, in words, of the output data column for continuation lines in an assembler listing to number .
-listing-rhs-width=number
Set the maximum width of an input source line, as displayed in a listing, to number bytes.
-listing-cont-lines=number
Set the maximum number of lines printed in a listing for a single line of input to number + 1.
-o objfile
Name the object-file output from as objfile .
-R
Fold the data section into the text section.
-statistics
Print the maximum space (in bytes) and total time (in seconds) used by assembly.
-strip-local-absolute
Remove local absolute symbols from the outgoing symbol table.
-v
-version
Print the as version.
-version
Print the as version and exit.
-W
-no-warn
Suppress warning messages.
-fatal-warnings
Treat warnings as errors.
-warn
Don’t suppress warning messages or treat them as errors.
-w
Ignored.
-x
Ignored.
-Z
Generate an object file even after errors.
8 Chapter 2. Overview
- | files ...
Standard input, or source files to assemble.
The following options are available when as is configured for an ARC processor.
-marc[5|6|7|8]
This option selects the core processor variant.
-EB | -EL
Select either big-endian (-EB) or little-endian (-EL) output.
The following options are available when as is configured for the ARM processor family.
-mcpu=processor [+extension ...]
Specify which ARM processor variant is the target.
-march=architecture [+extension ...]
Specify which ARM architecture variant is used by the target.
-mfpu=floating-point-format
Select which Floating Point architecture is the target.
-mfloat-abi=abi
Select which floating point ABI is in use.
-mthumb
Enable Thumb only instruction decoding.
-mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant | -moabi
Select which procedure calling convention is in use.
-EB | -EL
Select either big-endian (-EB) or little-endian (-EL) output.
-mthumb-interwork
Specify that the code has been generated with interworking between Thumb and ARM code in
mind.
-k
Specify that PIC code has been generated.
See the info pages for documentation of the CRIS-specific options.
The following options are available when as is configured for a D10V processor.
-O
Optimize output by parallelizing instructions.
The following options are available when as is configured for a D30V processor.
Chapter 2. Overview 9
-O
Optimize output by parallelizing instructions.
-n
Warn when nops are generated.
-N
Warn when a nop after a 32-bit multiply instruction is generated.
The following options are available when as is configured for the Intel 80960 processor.
-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC
Specify which variant of the 960 architecture is the target.
-b
Add code to collect statistics about branches taken.
-no-relax
Do not alter compare-and-branch instructions for long displacements; error if necessary.
The following options are available when as is configured for the Ubicom IP2K series.
-mip2022ext
Specifies that the extended IP2022 instructions are allowed.
-mip2022
Restores the default behaviour, which restricts the permitted instructions to just the basic IP2022
ones.
The following options are available when as is configured for the Renesas M32R (formerly Mitsubishi
M32R) series.
-m32rx
Specify which processor in the M32R family is the target. The default is normally the M32R, but
this option changes it to the M32RX.
-warn-explicit-parallel-conflicts or -Wp
Produce warning messages when questionable parallel constructs are encountered.
-no-warn-explicit-parallel-conflicts or -Wnp
Do not produce warning messages when questionable parallel constructs are encountered.
The following options are available when as is configured for the Motorola 68000 series.
-l
Shorten references to undefined symbols, to one word instead of two.
10 Chapter 2. Overview
-m68000 | -m68008 | -m68010 | -m68020 | -m68030
| -m68040 | -m68060 | -m68302 | -m68331 | -m68332
| -m68333 | -m68340 | -mcpu32 | -m5200
Specify what processor in the 68000 family is the target. The default is normally the 68020, but
this can be changed at configuration time.
-m68881 | -m68882 | -mno-68881 | -mno-68882
The target machine does (or does not) have a floating-point coprocessor. The default is to assume
a coprocessor for 68020, 68030, and cpu32. Although the basic 68000 is not compatible with
the 68881, a combination of the two can be specified, since it’s possible to do emulation of the
coprocessor instructions with the main processor.
-m68851 | -mno-68851
The target machine does (or does not) have a memory-management unit coprocessor. The default
is to assume an MMU for 68020 and up.
For details about the PDP-11 machine dependent features options, see Section 32.1 Options .
-mpic | -mno-pic
Generate position-independent (or position-dependent) code. The default is -mpic .
-mall
-mall-extensions
Enable all instruction set extensions. This is the default.
-mno-extensions
Disable all instruction set extensions.
-mextension | -mno-extension
Enable (or disable) a particular instruction set extension.
-mcpu
Enable the instruction set extensions supported by a particular CPU, and disable all other extensions.
-mmachine
Enable the instruction set extensions supported by a particular machine model, and disable all
other extensions.
The following options are available when as is configured for a picoJava processor.
-mb
Generate "big endian" format output.
-ml
Generate "little endian" format output.
The following options are available when as is configured for the Motorola 68HC11 or 68HC12 series.
Chapter 2. Overview 11
-m68hc11 | -m68hc12 | -m68hcs12
Specify what processor is the target. The default is defined by the configuration option when
building the assembler.
-mshort
Specify to use the 16-bit integer ABI.
-mlong
Specify to use the 32-bit integer ABI.
-mshort-double
Specify to use the 32-bit double ABI.
-mlong-double
Specify to use the 64-bit double ABI.
-force-long-branchs
Relative branches are turned into absolute ones. This concerns conditional branches, unconditional branches and branches to a sub routine.
-S | -short-branchs
Do not turn relative branchs into absolute ones when the offset is out of range.
-strict-direct-mode
Do not turn the direct addressing mode into extended addressing mode when the instruction does
not support direct addressing mode.
-print-insn-syntax
Print the syntax of instruction in case of error.
-print-opcodes
print the list of instructions with syntax and then exit.
-generate-example
print an example of instruction for each possible instruction and then exit. This option is only
useful for testing as .
The following options are available when as is configured for the SPARC architecture:
-Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite
-Av8plus | -Av8plusa | -Av9 | -Av9a
Explicitly select a variant of the SPARC architecture.
-Av8plus and -Av8plusa select a 32 bit environment. -Av9 and -Av9a select a 64 bit envi-
ronment.
-Av8plusa and -Av9a enable the SPARC V9 instruction set with UltraSPARC extensions.
-xarch=v8plus | -xarch=v8plusa
For compatibility with the Solaris v9 assembler. These options are equivalent to -Av8plus and
-Av8plusa, respectively.
12 Chapter 2. Overview
-bump
Warn when the assembler switches to another architecture.
The following options are available when as is configured for the ’c54x architecture.
-mfar-mode
Enable extended addressing mode. All addresses and relocations will assume extended addressing (usually 23 bits).
-mcpu=CPU_VERSION
Sets the CPU version being compiled for.
-merrors-to-file FILENAME
Redirect error output to a file, for broken systems which don’t support such behaviour in the
shell.
The following options are available when as is configured for a mips processor.
-G num
This option sets the largest size of an object that can be referenced implicitly with the gp register.
It is only accepted for targets that use ECOFF format, such as a DECstation running Ultrix. The
default value is 8.
-EB
Generate "big endian" format output.
-EL
Generate "little endian" format output.
-mips1
-mips2
-mips3
-mips4
-mips5
-mips32
-mips32r2
-mips64
-mips64r2
Generate code for a particular mips Instruction Set Architecture level. -mips1 is an
alias for -march=r3000 , -mips2 is an alias for -march=r6000 , -mips3 is an alias for
-march=r4000 and -mips4 is an alias for -march=r8000. -mips5, -mips32, -mips32r2,
-mips64, and -mips64r2 correspond to generic MIPS V, MIPS32, MIPS32 Release 2,
MIPS64, and MIPS64 Release 2 ISA processors, respectively.
-march=CPU
Generate code for a particular mips cpu.
-mtune=cpu
Schedule and tune for a particular mips cpu.
Chapter 2. Overview 13
-mfix7000
-mno-fix7000
Cause nops to be inserted if the read of the destination register of an mfhi or mflo instruction
occurs in the following two instructions.
-mdebug
-no-mdebug
Cause stabs-style debugging output to go into an ECOFF-style .mdebug section instead of the
standard ELF .stabs sections.
-mpdr
-mno-pdr
Control generation of .pdr sections.
-mgp32
-mfp32
The register sizes are normally inferred from the ISA and ABI, but these flags force a certain
group of registers to be treated as 32 bits wide at all times. -mgp32 controls the size of generalpurpose registers and -mfp32 controls the size of floating-point registers.
-mips16
-no-mips16
Generate code for the MIPS 16 processor. This is equivalent to putting .set mips16 at the start
of the assembly file. -no-mips16 turns off this option.
-mips3d
-no-mips3d
Generate code for the MIPS-3D Application Specific Extension. This tells the assembler to accept MIPS-3D instructions. -no-mips3d turns off this option.
-mdmx
-no-mdmx
Generate code for the MDMX Application Specific Extension. This tells the assembler to accept
MDMX instructions. -no-mdmx turns off this option.
-construct-floats
-no-construct-floats
The -no-construct-floats option disables the construction of double width floating point
constants by loading the two halves of the value into the two single width floating point registers
that make up the double width register. By default -construct-floats is selected, allowing
construction of these floating point constants.
-emulation=name
This option causes as to emulate as configured for some other target, in all respects, including
output format (choosing between ELF and ECOFF only), handling of pseudo-opcodes which
may generate debugging information or store symbol table information, and default endianness.
The available configuration names are: mipsecoff , mipself , mipslecoff , mipsbecoff ,
mipslelf, mipsbelf. The first two do not alter the default endianness from that of the pri-
mary target for which the assembler was configured; the others change the default to little- or
big-endian as indicated by the b or l in the name. Using -EB or -EL will override the endianness
selection in any case.
14 Chapter 2. Overview
This option is currently supported only when the primary target as is configured for is a
mips ELF or ECOFF target. Furthermore, the primary target or others specified with
-enable-targets=... at configuration time must include support for the other format, if
both are to be available. For example, the Irix 5 configuration includes support for both.
Eventually, this option will support more configurations, with more fine-grained control over the
assembler’s behavior, and will be supported for more processors.
-nocpp
as ignores this option. It is accepted for compatibility with the native tools.
-trap
-no-trap
-break
-no-break
Control how to deal with multiplication overflow and division by zero. -trap or -no-break
(which are synonyms) take a trap exception (and only work for Instruction Set Architecture level
2 and higher); -break or -no-trap (also synonyms, and the default) take a break exception.
-n
When this option is used, as will issue a warning every time it generates a nop instruction from
a macro.
The following options are available when as is configured for an MCore processor.
-jsri2bsr
-nojsri2bsr
Enable or disable the JSRI to BSR transformation. By default this is enabled. The command line
option -nojsri2bsr can be used to disable it.
-sifilter
-nosifilter
Enable or disable the silicon filter behaviour. By default this is disabled. The default can be
overridden by the -sifilter command line option.
-relax
Alter jump instructions for long displacements.
-mcpu=[210|340]
Select the cpu type on the target hardware. This controls which instructions can be assembled.
-EB
Assemble for a big endian target.
-EL
Assemble for a little endian target.
See the info pages for documentation of the MMIX-specific options.
The following options are available when as is configured for an Xtensa processor.
-density | -no-density
Enable or disable use of instructions from the Xtensa code density option. This is enabled by
default when the Xtensa processor supports the code density option.
Chapter 2. Overview 15
-relax | -no-relax
Enable or disable instruction relaxation. This is enabled by default. Note: In the current implementation, these options also control whether assembler optimizations are performed, making
these options equivalent to -generics and -no-generics .
-generics | -no-generics
Enable or disable all assembler transformations of Xtensa instructions. The default is
-generics; -no-generics should be used only in the rare cases when the instructions must
be exactly as specified in the assembly source.
-text-section-literals | -no-text-section-literals
With -text-section-literals , literal pools are interspersed in the text section. The default
is -no-text-section-literals , which places literals in a separate section in the output file.
-target-align | -no-target-align
Enable or disable automatic alignment to reduce branch penalties at the expense of some code
density. The default is -target-align .
-longcalls | -no-longcalls
Enable or disable transformation of call instructions to allow calls across a greater range of
addresses. The default is -no-longcalls .
2.1. Structure of this Manual
This manual is intended to describe what you need to know to use gnu as . We cover the syntax
expected in source files, including notation for symbols, constants, and expressions; the directives
that as understands; and of course how to invoke as .
This manual also describes some of the machine-dependent features of various flavors of the assembler.
On the other hand, this manual is not intended as an introduction to programming in assembly
language--let alone programming in general! In a similar vein, we make no attempt to introduce the
machine architecture; we do not describe the instruction set, standard mnemonics, registers or addressing modes that are standard to a particular architecture. You may want to consult the manufacturer’s
machine architecture manual for this information.
2.2. The GNU Assembler
gnu as is really a family of assemblers. If you use (or have used) the gnu assembler on one architecture, you should find a fairly similar environment when you use it on another architecture. Each
version has much in common with the others, including object file formats, most assembler directives
(often called pseudo-ops ) and assembler syntax.
as is primarily intended to assemble the output of the gnu C compiler gcc for use by the linker ld.
Nevertheless, we’ve tried to make as assemble correctly everything that other assemblers for the same
machine would assemble. Any exceptions are documented explicitly (Chapter 9 Machine Dependent
Features ). This doesn’t mean as always uses the same syntax as another assembler for the same
architecture; for example, we know of several incompatible versions of 680x0 assembly language
syntax.
Unlike older assemblers, as is designed to assemble a source program in one pass of the source file.
This has a subtle impact on the .org directive (Section 8.65 .org new-lc , fill ).
16 Chapter 2. Overview
2.3. Object File Formats
The gnu assembler can be configured to produce several alternative object file formats. For the most
part, this does not affect how you write assembly language programs; but directives for debugging
symbols are typically different in different file formats. Section 6.5 Symbol Attributes .
2.4. Command Line
After the program name as , the command line may contain options and file names. Options may
appear in any order, and may be before, after, or between file names. The order of file names is
significant.
- (two hyphens) by itself names the standard input file explicitly, as one of the files for as to assemble.
Except for - any command line argument that begins with a hyphen (-) is an option. Each option
changes the behavior of as. No option changes the way another option works. An option is a followed by one or more letters; the case of the letter is important. All options are optional.
Some options expect exactly one file name to follow them. The file name may either immediately
follow the option’s letter (compatible with older assemblers) or it may be the next command argument
(gnu standard). These two command lines are equivalent:
as -o my-object-file.o mumble.s
as -omy-object-file.o mumble.s
2.5. Input Files
We use the phrase source program , abbreviated source , to describe the program input to one run of
as. The program may be in one or more files; how the source is partitioned into files doesn’t change
the meaning of the source.
The source program is a concatenation of the text in all the files, in the order specified.
Each time you run as it assembles exactly one source program. The source program is made up of
one or more files. (The standard input is also a file.)
You give as a command line that has zero or more input file names. The input files are read (from left
file name to right). A command line argument (in any position) that has no special meaning is taken
to be an input file name.
If you give as no file names it attempts to read one input file from the as standard input, which is
normally your terminal. You may have to type [ctl-D] to tell as there is no more program to assemble.
Use - if you need to explicitly name the standard input file in your command line.
If the source is empty, as produces a small, empty object file.
2.5.1. Filenames and Line-numbers
There are two ways of locating a line in the input file (or files) and either may be used in reporting
error messages. One way refers to a line number in a physical file; the other refers to a line number in
a "logical" file. Section 2.7 Error and Warning Messages.
Physical files are those files named in the command line given to as .
Logical files are simply names declared explicitly by assembler directives; they bear no relation to
physical files. Logical file names help error messages reflect the original source file, when as source