Using As: Dean Elsner, Jay Fenlason & Friends
Using As: Dean Elsner, Jay Fenlason & Friends
Using As: Dean Elsner, Jay Fenlason & Friends
(GNU Binutils)
Version 2.37
The Free Software Foundation Inc. thanks The Nice Computer Company of Australia for
loaning Dean Elsner to write the first (Vax) version of as for Project gnu. The proprietors,
management and staff of TNCCA thank FSF for distracting the boss while they got some
work done.
Table of Contents
1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Structure of this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.2 The GNU Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3 Object File Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.4 Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.5 Input Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.6 Output (Object) File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.7 Error and Warning Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2 Command-Line Options . . . . . . . . . . . . . . . . . . . . . . . 25
2.1 Enable Listings: -a[cdghlns] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2 --alternate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3 -D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.4 Work Faster: -f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5 .include Search Path: -I path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.6 Difference Tables: -K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.7 Include Local Symbols: -L . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.8 Configuring listing output: --listing . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.9 Assemble in MRI Compatibility Mode: -M . . . . . . . . . . . . . . . . . . . . . 27
2.10 Dependency Tracking: --MD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.11 Output Section Padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.12 Name the Object File: -o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.13 Join Data and Text Sections: -R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.14 Display Assembly Statistics: --statistics . . . . . . . . . . . . . . . . . . . 29
2.15 Compatible Output: --traditional-format . . . . . . . . . . . . . . . . . 29
2.16 Announce Version: -v . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.17 Control Warnings: -W, --warn, --no-warn, --fatal-warnings . . 29
2.18 Generate Object File in Spite of Errors: -Z . . . . . . . . . . . . . . . . . . . 30
3 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.1 Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2 Whitespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.3 Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.4 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.5 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.6 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.6.1 Character Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.6.1.1 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.6.1.2 Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.6.2 Number Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.6.2.1 Integers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.6.2.2 Bignums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.6.2.3 Flonums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
ii Using as
5 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.1 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2 Giving Symbols Other Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3 Symbol Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.4 The Special Dot Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.5 Symbol Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.5.1 Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.5.2 Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5.3 Symbol Attributes: a.out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5.3.1 Descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5.3.2 Other. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5.4 Symbol Attributes for COFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5.4.1 Primary Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5.4.2 Auxiliary Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5.5 Symbol Attributes for SOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.1 Empty Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2 Integer Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2.1 Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2.2 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2.3 Prefix Operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2.4 Infix Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7 Assembler Directives. . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.1 .abort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.2 .ABORT (COFF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.3 .align [abs-expr[, abs-expr[, abs-expr]]] . . . . . . . . . . . . . . . . 51
7.4 .altmacro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.5 .ascii "string". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.6 .asciz "string". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.7 .attach_to_group name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.8 .balign[wl] [abs-expr[, abs-expr[, abs-expr]]] . . . . . . . . . . 53
7.9 .bss subsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.10 Bundle directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.10.1 .bundle_align_mode abs-expr. . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.10.2 .bundle_lock and .bundle_unlock . . . . . . . . . . . . . . . . . . . . . 54
7.11 .byte expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.12 CFI directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.12.1 .cfi_sections section_list . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
iii
7.37 .file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.38 .fill repeat , size , value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.39 .float flonums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.40 .func name[,label] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.41 .global symbol, .globl symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.42 .gnu_attribute tag,value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.43 .hidden names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.44 .hword expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.45 .ident . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.46 .if absolute expression. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.47 .incbin "file"[,skip[,count]] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
7.48 .include "file". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.49 .int expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.50 .internal names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.51 .irp symbol,values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.52 .irpc symbol,values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.53 .lcomm symbol , length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.54 .lflags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.55 .line line-number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.56 .linkonce [type] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.57 .list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.58 .ln line-number. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.59 .loc fileno lineno [column] [options] . . . . . . . . . . . . . . . . . . . . 68
7.60 .loc_mark_labels enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7.61 .local names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7.62 .long expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7.63 .macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7.64 .mri val . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.65 .noaltmacro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.66 .nolist. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.67 .nop [size] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.68 .nops size[, control] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
7.69 .octa bignums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7.70 .offset loc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7.71 .org new-lc , fill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7.72 .p2align[wl] [abs-expr[, abs-expr[, abs-expr]]] . . . . . . . . 73
7.73 .popsection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
7.74 .previous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
7.75 .print string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
7.76 .protected names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
7.77 .psize lines , columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
7.78 .purgem name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
7.79 .pushsection name [, subsection] [,
"flags"[, @type[,arguments]]] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.80 .quad bignums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.81 .reloc offset, reloc_name[, expression] . . . . . . . . . . . . . . . . . 76
7.82 .rept count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.83 .sbttl "subheading" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
v
8 Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.1 gnu Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.1.1 Common gnu attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.1.2 M680x0 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.1.3 MIPS Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8.1.4 PowerPC Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8.1.5 IBM z Systems Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8.1.6 MSP430 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
8.2 Defining New Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
vi Using as
11 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . 391
AS Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
1
1 Overview
This manual is a user guide to the gnu assembler as.
Here is a brief summary of how to invoke as. For details, see Chapter 2 [Command-Line
Options], page 25.
as [-a[cdghlns][=file]] [–alternate] [-D]
[–compress-debug-sections] [–nocompress-debug-sections]
[–debug-prefix-map old=new]
[–defsym sym=val] [-f] [-g] [–gstabs]
[–gstabs+] [–gdwarf-<N>] [–gdwarf-sections]
[–gdwarf-cie-version=VERSION]
[–help] [-I dir] [-J]
[-K] [-L] [–listing-lhs-width=NUM]
[–listing-lhs-width2=NUM] [–listing-rhs-width=NUM]
[–listing-cont-lines=NUM] [–keep-locals]
[–no-pad-sections]
[-o objfile] [-R]
[–statistics]
[-v] [-version] [–version]
[-W] [–warn] [–fatal-warnings] [-w] [-x]
[-Z] [@FILE]
[–sectname-subst] [–size-check=[error|warning]]
[–elf-stt-common=[no|yes]]
[–generate-missing-build-notes=[no|yes]]
[–target-help] [target-options]
[–|files ...]
[-mginv] [-mno-ginv]
[-mloongson-mmi] [-mno-loongson-mmi]
[-mloongson-cam] [-mno-loongson-cam]
[-mloongson-ext] [-mno-loongson-ext]
[-mloongson-ext2] [-mno-loongson-ext2]
[-minsn32] [-mno-insn32]
[-mfix7000] [-mno-fix7000]
[-mfix-rm7000] [-mno-fix-rm7000]
[-mfix-vr4120] [-mno-fix-vr4120]
[-mfix-vr4130] [-mno-fix-vr4130]
[-mfix-r5900] [-mno-fix-r5900]
[-mdebug] [-no-mdebug]
[-mpdr] [-mno-pdr]
[-link-relax]
[-mnolink-relax]
[-mno-warn-regname-label]
Target RX options:
[-mlittle-endian|-mbig-endian]
[-m32bit-doubles|-m64bit-doubles]
[-muse-conventional-section-names]
[-msmall-data-limit]
[-mpid]
[-mrelax]
[-mint-register=number]
[-mgcc-abi|-mrx-abi]
[-mdsbt|-mno-dsbt] [-mpid=no|-mpid=near|-mpid=far]
[-mpic|-mno-pic]
@file Read command-line options from file. The options read are inserted in place
of the original @file option. If file does not exist, or cannot be read, then the
option will be treated literally, and not removed.
Options in file are separated by whitespace. A whitespace character may be
included in an option by surrounding the entire option in either single or double
quotes. Any character (including a backslash) may be included by prefixing the
character to be included with a backslash. The file may itself contain additional
@file options; any such options will be processed recursively.
-a[cdghlmns]
Turn on listings, in any of a variety of ways:
-ac omit false conditionals
-ad omit debugging directives
-ag include general information, like as version and options passed
-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
Chapter 1: Overview 7
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 7.4 [.altmacro], page 52.
--compress-debug-sections
Compress DWARF debug sections using zlib with SHF COMPRESSED from
the ELF ABI. The resulting object file may not be compatible with older linkers
and object file utilities. Note if compression would make a given section larger
then it is not compressed.
--compress-debug-sections=none
--compress-debug-sections=zlib
--compress-debug-sections=zlib-gnu
--compress-debug-sections=zlib-gabi
These options control how DWARF debug sections are compressed.
--compress-debug-sections=none is equivalent to --nocompress-debug-
sections. --compress-debug-sections=zlib and --compress-debug-
sections=zlib-gabi are equivalent to --compress-debug-sections.
--compress-debug-sections=zlib-gnu compresses DWARF debug sections
using zlib. The debug sections are renamed to begin with ‘.zdebug’. Note if
compression would make a given section larger then it is not compressed nor
renamed.
--nocompress-debug-sections
Do not compress DWARF debug sections. This is usually the default for all
targets except the x86/x86 64, but a configure time option can be used to
override this.
-D Ignored. This option is accepted for script compatibility with calls to other
assemblers.
--debug-prefix-map old=new
When assembling files in directory old, record debugging information describing
them as in new instead.
--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. The value of the symbol can be
overridden inside a source file via the use of a .set pseudo-op.
-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,
8 Using as
--elf-stt-common=no
--elf-stt-common=yes
These options control whether the ELF assembler should generate common
symbols with the STT_COMMON type. The default can be controlled by a configure
option --enable-elf-stt-common.
--generate-missing-build-notes=yes
--generate-missing-build-notes=no
These options control whether the ELF assembler should generate GNU Build
attribute notes if none are present in the input sources. The default can be
controlled by the --enable-generate-build-notes configure option.
--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. These symbols start with system-
specific local label prefixes, typically ‘.L’ for ELF systems or ‘L’ for traditional
a.out systems. See Section 5.3 [Symbol Names], page 43.
--listing-lhs-width=number
Set the maximum width, in words, of the output data column for an assembler
listing to number.
--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.
--no-pad-sections
Stop the assembler for padding the ends of output sections to the alignment of
that section. The default is to pad the sections, but this can waste space which
might be needed on targets which have tight memory constraints.
-o objfile
Name the object-file output from as objfile.
-R Fold the data section into the text section.
10 Using as
--sectname-subst
Honor substitution sequences in section names. See [.section name], page 78.
--statistics
Print the maximum space (in bytes) and total time (in seconds) used by assem-
bly.
--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.
-- | files ...
Standard input, or source files to assemble.
See Section 9.1.1 [AArch64 Options], page 96, for the options available when as is con-
figured for the 64-bit mode of the ARM Architecture (AArch64).
See Section 9.2.2 [Alpha Options], page 102, for the options available when as is config-
ured for an Alpha processor.
The following options are available when as is configured for an ARC processor.
-mcpu=cpu
This option selects the core processor variant.
-EB | -EL Select either big-endian (-EB) or little-endian (-EL) output.
-mcode-density
Enable Code Density extension instructions.
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.
Chapter 1: Overview 11
-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
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.
-mccs Turns on CodeComposer Studio assembly syntax compatibility mode.
-k Specify that PIC code has been generated.
See Section 9.6.1 [Blackfin Options], page 142, for the options available when as is
configured for the Blackfin processor family.
See Section 9.7.1 [BPF Options], page 146, for the options available when as is configured
for the Linux kernel BPF processor family.
See the info pages for documentation of the CRIS-specific options.
See Section 9.10.1 [C-SKY Options], page 159, for the options available when as is
configured for the C-SKY processor family.
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.
-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 Adapteva EPIPHANY
series.
See Section 9.13.1 [Epiphany Options], page 169, for the options available when as is
configured for an Epiphany processor.
See Section 9.16.1 [i386-Options], page 178, for the options available when as is configured
for an i386 processor.
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 M32C and
M16C processors.
-m32c Assemble M32C instructions.
12 Using as
-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 dis-
able 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.
See Section 9.37.1 [PRU Options], page 278, for the options available when as is config-
ured for a PRU processor.
The following options are available when as is configured for the Motorola 68HC11 or
68HC12 series.
-m68hc11 | -m68hc12 | -m68hcs12 | -mm9s12x | -mm9s12xg
Specify what processor is the target. The default is defined by the configuration
option when building the assembler.
--xgate-ramoffset
Instruct the linker to offset RAM addresses from S12X address space into
XGATE address space.
-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-branches
Relative branches are turned into absolute ones. This concerns conditional
branches, unconditional branches and branches to a sub routine.
-S | --short-branches
Do not turn relative branches 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.
14 Using as
--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:
-xarch=v8plus | -xarch=v8plusa
For compatibility with the Solaris v9 assembler. These options are equivalent
to -Av8plus and -Av8plusa, respectively.
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.
-mips1
-mips2
-mips3
-mips4
-mips5
-mips32
-mips32r2
-mips32r3
-mips32r5
-mips32r6
-mips64
-mips64r2
-mips64r3
-mips64r5
-mips64r6
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’, ‘-mips32r3’,
‘-mips32r5’, ‘-mips32r6’, ‘-mips64’, ‘-mips64r2’, ‘-mips64r3’, ‘-mips64r5’,
and ‘-mips64r6’ correspond to generic MIPS V, MIPS32, MIPS32 Release 2,
MIPS32 Release 3, MIPS32 Release 5, MIPS32 Release 6, MIPS64, MIPS64
Release 2, MIPS64 Release 3, MIPS64 Release 5, and MIPS64 Release 6 ISA
processors, respectively.
-march=cpu
Generate code for a particular MIPS CPU.
-mtune=cpu
Schedule and tune for a particular MIPS CPU.
-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.
-mfix-rm7000
-mno-fix-rm7000
Cause nops to be inserted if a dmult or dmultu instruction is followed by a load
instruction.
-mfix-r5900
-mno-fix-r5900
Do not attempt to schedule the preceding instruction into the delay slot of a
branch instruction placed at the end of a short loop of six instructions or fewer
and always schedule a nop instruction there instead. The short loop bug under
certain conditions causes loops to execute only once or twice, due to a hardware
bug in the R5900 chip.
16 Using as
-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 general-purpose registers and ‘-mfp32’ controls the
size of floating-point registers.
-mgp64
-mfp64 The register sizes are normally inferred from the ISA and ABI, but these flags
force a certain group of registers to be treated as 64 bits wide at all times.
‘-mgp64’ controls the size of general-purpose registers and ‘-mfp64’ controls the
size of floating-point registers.
-mfpxx The register sizes are normally inferred from the ISA and ABI, but using this
flag in combination with ‘-mabi=32’ enables an ABI variant which will operate
correctly with floating-point registers which are 32 or 64 bits wide.
-modd-spreg
-mno-odd-spreg
Enable use of floating-point operations on odd-numbered single-precision regis-
ters when supported by the ISA. ‘-mfpxx’ implies ‘-mno-odd-spreg’, otherwise
the default is ‘-modd-spreg’.
-mips16
-no-mips16
Generate code for the MIPS 16 processor. This is equivalent to putting .module
mips16 at the start of the assembly file. ‘-no-mips16’ turns off this option.
-mmips16e2
-mno-mips16e2
Enable the use of MIPS16e2 instructions in MIPS16 mode. This is equivalent to
putting .module mips16e2 at the start of the assembly file. ‘-mno-mips16e2’
turns off this option.
-mmicromips
-mno-micromips
Generate code for the microMIPS processor. This is equivalent to putting
.module micromips at the start of the assembly file. ‘-mno-micromips’ turns
off this option. This is equivalent to putting .module nomicromips at the start
of the assembly file.
-msmartmips
-mno-smartmips
Enables the SmartMIPS extension to the MIPS32 instruction set. This is
equivalent to putting .module smartmips at the start of the assembly file.
‘-mno-smartmips’ turns off this option.
Chapter 1: Overview 17
-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.
-mdsp
-mno-dsp Generate code for the DSP Release 1 Application Specific Extension. This tells
the assembler to accept DSP Release 1 instructions. ‘-mno-dsp’ turns off this
option.
-mdspr2
-mno-dspr2
Generate code for the DSP Release 2 Application Specific Extension. This
option implies ‘-mdsp’. This tells the assembler to accept DSP Release 2 in-
structions. ‘-mno-dspr2’ turns off this option.
-mdspr3
-mno-dspr3
Generate code for the DSP Release 3 Application Specific Extension. This
option implies ‘-mdsp’ and ‘-mdspr2’. This tells the assembler to accept DSP
Release 3 instructions. ‘-mno-dspr3’ turns off this option.
-mmsa
-mno-msa Generate code for the MIPS SIMD Architecture Extension. This tells the as-
sembler to accept MSA instructions. ‘-mno-msa’ turns off this option.
-mxpa
-mno-xpa Generate code for the MIPS eXtended Physical Address (XPA) Extension. This
tells the assembler to accept XPA instructions. ‘-mno-xpa’ turns off this option.
-mmt
-mno-mt Generate code for the MT Application Specific Extension. This tells the as-
sembler to accept MT instructions. ‘-mno-mt’ turns off this option.
-mmcu
-mno-mcu Generate code for the MCU Application Specific Extension. This tells the
assembler to accept MCU instructions. ‘-mno-mcu’ turns off this option.
-mcrc
-mno-crc Generate code for the MIPS cyclic redundancy check (CRC) Application Spe-
cific Extension. This tells the assembler to accept CRC instructions. ‘-mno-crc’
turns off this option.
-mginv
-mno-ginv
Generate code for the Global INValidate (GINV) Application Specific Exten-
sion. This tells the assembler to accept GINV instructions. ‘-mno-ginv’ turns
off this option.
18 Using as
-mloongson-mmi
-mno-loongson-mmi
Generate code for the Loongson MultiMedia extensions Instructions (MMI)
Application Specific Extension. This tells the assembler to accept MMI in-
structions. ‘-mno-loongson-mmi’ turns off this option.
-mloongson-cam
-mno-loongson-cam
Generate code for the Loongson Content Address Memory (CAM)
instructions. This tells the assembler to accept Loongson CAM instructions.
‘-mno-loongson-cam’ turns off this option.
-mloongson-ext
-mno-loongson-ext
Generate code for the Loongson EXTensions (EXT) instructions. This tells the
assembler to accept Loongson EXT instructions. ‘-mno-loongson-ext’ turns
off this option.
-mloongson-ext2
-mno-loongson-ext2
Generate code for the Loongson EXTensions R2 (EXT2) instructions. This
option implies ‘-mloongson-ext’. This tells the assembler to accept Loongson
EXT2 instructions. ‘-mno-loongson-ext2’ turns off this option.
-minsn32
-mno-insn32
Only use 32-bit instruction encodings when generating code for the microMIPS
processor. This option inhibits the use of any 16-bit instructions. This is equiv-
alent to putting .set insn32 at the start of the assembly file. ‘-mno-insn32’
turns off this option. This is equivalent to putting .set noinsn32 at the start of
the assembly file. By default ‘-mno-insn32’ is selected, allowing all instructions
to be used.
--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.
--relax-branch
--no-relax-branch
The ‘--relax-branch’ option enables the relaxation of out-of-range branches.
By default ‘--no-relax-branch’ is selected, causing any out-of-range branches
to produce an error.
-mignore-branch-isa
-mno-ignore-branch-isa
Ignore branch checks for invalid transitions between ISA modes. The semantics
of branches does not provide for an ISA mode switch, so in most cases the ISA
Chapter 1: Overview 19
mode a branch has been encoded for has to be the same as the ISA mode of
the branch’s target label. Therefore GAS has checks implemented that verify
in branch assembly that the two ISA modes match. ‘-mignore-branch-isa’
disables these checks. By default ‘-mno-ignore-branch-isa’ is selected, caus-
ing any invalid branch requiring a transition between ISA modes to produce an
error.
-mnan=encoding
Select between the IEEE 754-2008 (-mnan=2008) or the legacy (-mnan=legacy)
NaN encoding format. The latter is the default.
--emulation=name
This option was formerly used to switch between ELF and ECOFF output on
targets like IRIX 5 that supported both. MIPS ECOFF support was removed in
GAS 2.24, so the option now serves little purpose. It is retained for backwards
compatibility.
The available configuration names are: ‘mipself’, ‘mipslelf’ and ‘mipsbelf’.
Choosing ‘mipself’ now has no effect, since the output is always ELF.
‘mipslelf’ and ‘mipsbelf’ select little- and big-endian output respectively,
but ‘-EL’ and ‘-EB’ are now the preferred options instead.
-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.
20 Using as
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 Command-Line Options
This chapter describes command-line options available in all versions of the gnu assembler;
see Chapter 9 [Machine Dependencies], page 95, for options specific to particular machine
architectures.
If you are invoking as via the gnu C compiler, you can use the ‘-Wa’ option to pass
arguments through to the assembler. The assembler arguments must be separated from
each other (and the ‘-Wa’) by commas. For example:
gcc -c -g -O -Wa,-alh,-L file.c
This passes two options to the assembler: ‘-alh’ (emit a listing to standard output with
high-level and assembly source) and ‘-L’ (retain local symbols in the symbol table).
Usually you do not need to use this ‘-Wa’ mechanism, since many compiler command-
line options are automatically passed to the assembler by the compiler. (You can call the
gnu compiler driver with the ‘-v’ option to see precisely what options it passes to each
compilation pass, including the assembler.)
2.2 --alternate
Begin in alternate macro mode, see Section 7.4 [.altmacro], page 52.
26 Using as
2.3 -D
This option has no effect whatsoever, but it is accepted to make it more likely that scripts
written for other assemblers also work with as.
--listing-lhs-width=‘number’
Sets the maximum width, in words, of the first line of the hex byte dump. This
dump appears on the left hand side of the listing output.
--listing-lhs-width2=‘number’
Sets the maximum width, in words, of any further lines of the hex byte dump
for a given input source line. If this value is not specified, it defaults to being
the same as the value specified for ‘--listing-lhs-width’. If neither switch
is used the default is to one.
--listing-rhs-width=‘number’
Sets the maximum width, in characters, of the source line that is displayed
alongside the hex dump. The default value for this parameter is 100. The
source line is displayed on the right hand side of the listing output.
--listing-cont-lines=‘number’
Sets the maximum number of continuation lines of hex dump that will be dis-
played for a given single line of source input. The default value is 4.
• ORG pseudo-op
The m68k MRI ORG pseudo-op begins an absolute section at a given address. This
differs from the usual as .org pseudo-op, which changes the location within the current
section. Absolute sections are not supported by other object file formats. The address
of a section may be assigned within a linker script.
There are some other features of the MRI assembler which are not supported by as,
typically either because they are difficult or because they seem of little consequence. Some
of these may be supported in future releases.
• EBCDIC strings
EBCDIC strings are not supported.
• packed binary coded decimal
Packed binary coded decimal is not supported. This means that the DC.P and DCB.P
pseudo-ops are not supported.
• FEQU pseudo-op
The m68k FEQU pseudo-op is not supported.
• NOOBJ pseudo-op
The m68k NOOBJ pseudo-op is not supported.
• OPT branch control options
The m68k OPT branch control options—B, BRS, BRB, BRL, and BRW—are ignored. as
automatically relaxes all branches, whether forward or backward, to an appropriate
size, so these options serve no purpose.
• OPT list control options
The following m68k OPT list control options are ignored: C, CEX, CL, CRE, E, G, I, M,
MEX, MC, MD, X.
• other OPT options
The following m68k OPT options are ignored: NEST, O, OLD, OP, P, PCO, PCR, PCS, R.
• OPT D option is default
The m68k OPT D option is the default, unlike the MRI assembler. OPT NOD may be used
to turn it off.
• XREF pseudo-op.
The m68k XREF pseudo-op is ignored.
If you use the --fatal-warnings option, as considers files that generate warnings to be
in error.
You can switch these options off again by specifying --warn, which causes warnings to
be output as usual.
3 Syntax
This chapter describes the machine-independent syntax allowed in a source file. as syntax is
similar to what many other assemblers use; it is inspired by the BSD 4.2 assembler, except
that as does not assemble Vax bit-fields.
3.1 Preprocessing
The as internal preprocessor:
• adjusts and removes extra whitespace. It leaves one space or tab before the keywords
on a line, and turns any other whitespace on the line into a single space.
• removes all comments, replacing them with a single space, or an appropriate number
of newlines.
• converts character constants into the appropriate numeric values.
It does not do macro processing, include file handling, or anything else you may get
from your C compiler’s preprocessor. You can do include file processing with the .include
directive (see Section 7.48 [.include], page 66). You can use the gnu C compiler driver to
get other “CPP” style preprocessing by giving the input file a ‘.S’ suffix. See the ’Options
Controlling the Kind of Output’ section of the GCC manual for more details (https://
gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options)
Excess whitespace, comments, and character constants cannot be used in the portions
of the input text that are not preprocessed.
If the first line of an input file is #NO_APP or if you use the ‘-f’ option, whitespace
and comments are not removed from the input file. Within an input file, you can ask for
whitespace and comment removal in specific portions of the by putting a line that says
#APP before the text that may contain whitespace or comments, and putting a line that
says #NO_APP after this text. This feature is mainly intend to support asm statements in
compilers whose output is otherwise free of comments and whitespace.
3.2 Whitespace
Whitespace is one or more blanks or tabs, in any order. Whitespace is used to separate
symbols, and to make programs neater for people to read. Unless within character constants
(see Section 3.6.1 [Character Constants], page 33), any whitespace means the same as
exactly one space.
3.3 Comments
There are two ways of rendering comments to as. In both cases the comment is equivalent
to one space.
Anything from ‘/*’ through the next ‘*/’ is a comment. This means you may not nest
these comments.
/*
The only way to include a newline (’\n’) in a comment
is to use this sort of comment.
*/
32 Using as
3.4 Symbols
A symbol is one or more characters chosen from the set of all letters (both upper and
lower case), digits and the three characters ‘_.$’. On most machines, you can also use $
in symbol names; exceptions are noted in Chapter 9 [Machine Dependencies], page 95. No
symbol may begin with a digit. Case is significant. There is no length limit; all characters
are significant. Multibyte characters are supported. Symbols are delimited by characters
not in that set, or by the beginning of a file (since the source program must end with a
newline, the end of a file is not a possible symbol delimiter). See Chapter 5 [Symbols],
page 43.
Symbol names may also be enclosed in double quote " characters. In such cases any
characters are allowed, except for the NUL character. If a double quote character is to be
included in the symbol name it must be preceded by a backslash \ character.
3.5 Statements
A statement ends at a newline character (‘\n’) or a line separator character. The line
separator character is target specific and described in the Syntax section of each target’s
documentation. Not all targets support a line separator character. The newline or line
separator character is considered to be part of the preceding statement. Newlines and
separators within character constants are an exception: they do not end statements.
It is an error to end any statement with end-of-file: the last character of any input file
should be a newline.
Chapter 3: Syntax 33
3.6 Constants
A constant is a number, written so that its value is known by inspection, without knowing
any context. Like this:
.byte 74, 0112, 092, 0x4A, 0X4a, ’J, ’\J # All the same value.
.ascii "Ring the bell\7" # A string constant.
.octa 0x123456789abcdef0123456789ABCDEF0 # A bignum.
.float 0f-314159265358979323846264338327\
95028841971.693993751E-40 # - pi, a flonum.
3.6.1.1 Strings
A string is written between double-quotes. It may contain double-quotes or null characters.
The way to get special characters into a string is to escape these characters: precede them
with a backslash ‘\’ character. For example ‘\\’ represents one backslash: the first \ is
an escape which tells as to interpret the second character literally as a backslash (which
prevents as from recognizing the second \ as an escape character). The complete list of
escapes follows.
\b Mnemonic for backspace; for ASCII this is octal code 010.
backslash-f
Mnemonic for FormFeed; for ASCII this is octal code 014.
\n Mnemonic for newline; for ASCII this is octal code 012.
34 Using as
3.6.1.2 Characters
A single character may be written as a single quote immediately followed by that character.
Some backslash escapes apply to characters, \b, \f, \n, \r, \t, and \" with the same
meaning as for strings, plus \’ for a single quote. So if you want to write the character
backslash, you must write ’\\ where the first \ escapes the second \. As you can see, the
quote is an acute accent, not a grave accent. A newline immediately following an acute
accent is taken as a literal character and does not count as the end of a statement. The
value of a character constant in a numeric expression is the machine’s byte-wide code for
that character. as assumes your character code is ASCII: ’A means 65, ’B means 66, and
so on.
3.6.2.1 Integers
A binary integer is ‘0b’ or ‘0B’ followed by zero or more of the binary digits ‘01’.
An octal integer is ‘0’ followed by zero or more of the octal digits (‘01234567’).
Chapter 3: Syntax 35
A decimal integer starts with a non-zero digit followed by zero or more digits
(‘0123456789’).
A hexadecimal integer is ‘0x’ or ‘0X’ followed by one or more hexadecimal digits chosen
from ‘0123456789abcdefABCDEF’.
Integers have the usual values. To denote a negative integer, use the prefix operator ‘-’
discussed under expressions (see Section 6.2.3 [Prefix Operators], page 47).
3.6.2.2 Bignums
A bignum has the same syntax and semantics as an integer except that the number (or its
negative) takes more than 32 bits to represent in binary. The distinction is made because
in some places integers are permitted while bignums are not.
3.6.2.3 Flonums
A flonum represents a floating point number. The translation is indirect: a decimal floating
point number from the text is converted by as to a generic binary floating point number
of more than sufficient precision. This generic floating point number is converted to a
particular computer’s floating point format (or formats) by a portion of as specialized to
that computer.
A flonum is written by writing (in order)
• The digit ‘0’. (‘0’ is optional on the HPPA.)
• A letter, to tell as the rest of the number is a flonum. e is recommended. Case is not
important.
On the H8/300 and Renesas / SuperH SH architectures, the letter must be one of the
letters ‘DFPRSX’ (in upper or lower case).
On the ARC, the letter must be one of the letters ‘DFRS’ (in upper or lower case).
On the HPPA architecture, the letter must be ‘E’ (upper case only).
• An optional sign: either ‘+’ or ‘-’.
• An optional integer part: zero or more decimal digits.
• An optional fractional part: ‘.’ followed by zero or more decimal digits.
• An optional exponent, consisting of:
• An ‘E’ or ‘e’.
• Optional sign: either ‘+’ or ‘-’.
• One or more decimal digits.
At least one of the integer part or the fractional part must be present. The floating point
number has the usual base-10 value.
as does all processing using integers. Flonums are computed independently of any
floating point hardware in the computer running as.
37
4.1 Background
Roughly, a section is a range of addresses, with no gaps; all data “in” those addresses is
treated the same for some particular purpose. For example there may be a “read only”
section.
The linker ld reads many object files (partial programs) and combines their contents to
form a runnable program. When as emits an object file, the partial program is assumed to
start at address 0. ld assigns the final addresses for the partial program, so that different
partial programs do not overlap. This is actually an oversimplification, but it suffices to
explain how as uses sections.
ld moves blocks of bytes of your program to their run-time addresses. These blocks
slide to their run-time addresses as rigid units; their length does not change and neither
does the order of bytes within them. Such a rigid unit is called a section. Assigning run-
time addresses to sections is called relocation. It includes the task of adjusting mentions of
object-file addresses so they refer to the proper run-time addresses. For the H8/300, and for
the Renesas / SuperH SH, as pads sections if needed to ensure they end on a word (sixteen
bit) boundary.
An object file written by as has at least three sections, any of which may be empty.
These are named text, data and bss sections.
When it generates COFF or ELF output, as can also generate whatever other named
sections you specify using the ‘.section’ directive (see Section 7.85 [.section], page 77).
If you do not use any directives that place output in the ‘.text’ or ‘.data’ sections, these
sections still exist, but are empty.
When as generates SOM or ELF output for the HPPA, as can also generate what-
ever other named sections you specify using the ‘.space’ and ‘.subspace’ directives. See
HP9000 Series 800 Assembly Language Reference Manual (HP 92432-90001) for details on
the ‘.space’ and ‘.subspace’ assembler directives.
Additionally, as uses different names for the standard text, data, and bss sections
when generating SOM output. Program text is placed into the ‘$CODE$’ section, data
into ‘$DATA$’, and BSS into ‘$BSS$’.
Within the object file, the text section starts at address 0, the data section follows, and
the bss section follows the data section.
When generating either SOM or ELF output files on the HPPA, the text section starts
at address 0, the data section at address 0x4000000, and the bss section follows the data
section.
To let ld know which data changes when the sections are relocated, and how to change
that data, as also writes to the object file details of the relocation needed. To perform
relocation ld must know, each time an address in the object file is mentioned:
• Where in the object file is the beginning of this reference to an address?
• How long (in bytes) is this reference?
• Which section does the address refer to? What is the numeric value of
(address) − (start-address of section)?
38 Using as
absolute section
Address 0 of this section is always “relocated” to runtime address 0. This
is useful if you want to refer to an address that ld must not change when
relocating. In this sense we speak of absolute addresses being “unrelocatable”:
they do not change during relocation.
undefined section
This “section” is a catch-all for address references to objects not in the preceding
sections.
An idealized example of three relocatable sections follows. The example uses the tradi-
tional section names ‘.text’ and ‘.data’. Memory addresses are on the horizontal axis.
4.4 Sub-Sections
Assembled bytes conventionally fall into two sections: text and data. You may have separate
groups of data in named sections that you want to end up near to each other in the object
file, even though they are not contiguous in the assembler source. as allows you to use
subsections for this purpose. Within each section, there can be numbered subsections with
values from 0 to 8192. Objects assembled into the same subsection go into the object file
40 Using as
together with other objects in the same subsection. For example, a compiler might want
to store constants in the text section, but might not want to have them interspersed with
the program being assembled. In this case, the compiler could issue a ‘.text 0’ before each
section of code being output, and a ‘.text 1’ before each group of constants being output.
Subsections are optional. If you do not use subsections, everything goes in subsection
number zero.
Each subsection is zero-padded up to a multiple of four bytes. (Subsections may be
padded a different amount on different flavors of as.)
Subsections appear in your object file in numeric order, lowest numbered to highest.
(All this to be compatible with other people’s assemblers.) The object file contains no
representation of subsections; ld and other programs that manipulate object files see no
trace of them. They just see all your text subsections as a text section, and all your data
subsections as a data section.
To specify which subsection you want subsequent statements assembled into, use a nu-
meric argument to specify it, in a ‘.text expression’ or a ‘.data expression’ statement.
When generating COFF output, you can also use an extra subsection argument with arbi-
trary named sections: ‘.section name, expression’. When generating ELF output, you
can also use the .subsection directive (see Section 7.96 [SubSection], page 84) to spec-
ify a subsection: ‘.subsection expression’. Expression should be an absolute expression
(see Chapter 6 [Expressions], page 47). If you just say ‘.text’ then ‘.text 0’ is assumed.
Likewise ‘.data’ means ‘.data 0’. Assembly begins in text 0. For instance:
.text 0 # The default subsection is text 0 anyway.
.ascii "This lives in the first text subsection. *"
.text 1
.ascii "But this lives in the second text subsection."
.data 0
.ascii "This lives in the data section,"
.ascii "in the first data subsection."
.text 0
.ascii "This lives in the first text section,"
.ascii "immediately following the asterisk (*)."
Each section has a location counter incremented by one for every byte assembled into
that section. Because subsections are merely a convenience restricted to as there is no
concept of a subsection location counter. There is no way to directly manipulate a location
counter—but the .align directive changes it, and any label definition captures its current
value. The location counter of the section where statements are being assembled is said to
be the active location counter.
When assembling for a target which supports multiple sections, such as ELF or COFF,
you may switch into the .bss section and define symbols as usual; see Section 7.85
[.section], page 77. You may only assemble zero values into the section. Typically the
section will only contain symbol definitions and .skip directives (see Section 7.90 [.skip],
page 82).
43
5 Symbols
Symbols are a central concept: the programmer uses symbols to name things, the linker
uses symbols to link, and the debugger uses symbols to debug.
Warning: as does not place symbols in the object file in the same order they
were declared. This may break some debuggers.
5.1 Labels
A label is written as a symbol immediately followed by a colon ‘:’. The symbol then
represents the current value of the active location counter, and is, for example, a suitable
instruction operand. You are warned if you use the same symbol to represent two different
locations: the first definition overrides any other definitions.
On the HPPA, the usual form for a label need not be immediately followed by a colon,
but instead must start in column zero. Only one label may be defined on a single line.
To work around this, the HPPA version of as also provides a special directive .label for
defining labels more flexibly.
Local symbols are defined and used within the assembler, but they are normally not
saved in object files. Thus, they are not visible when debugging. You may use the ‘-L’
option (see Section 2.7 [Include Local Symbols], page 26) to retain the local symbols in the
object files.
Local Labels
Local labels are different from local symbols. Local labels help compilers and programmers
use names temporarily. They create symbols which are guaranteed to be unique over the
entire scope of the input source code and which can be referred to by a simple notation.
To define a local label, write a label of the form ‘N:’ (where N represents any non-negative
integer). To refer to the most recent previous definition of that label write ‘Nb’, using the
same number as when you defined the label. To refer to the next definition of a local label,
write ‘Nf’. The ‘b’ stands for “backwards” and the ‘f’ stands for “forwards”.
There is no restriction on how you can use these labels, and you can reuse them too. So
that it is possible to repeatedly define the same local label (using the same number ‘N’),
although you can only refer to the most recently defined local label of that number (for a
backwards reference) or the next definition of a specific local label for a forward reference.
It is also worth noting that the first 10 local labels (‘0:’. . . ‘9:’) are implemented in a slightly
more efficient manner than the others.
Here is an example:
1: branch 1f
2: branch 1b
1: branch 2f
2: branch 1b
Which is the equivalent of:
label_1: branch label_3
label_2: branch label_1
label_3: branch label_4
label_4: branch label_3
Local label names are only a notational device. They are immediately transformed into
more conventional symbol names before the assembler uses them. The symbol names are
stored in the symbol table, appear in error messages, and are optionally emitted to the
object file. The names are constructed using these parts:
local label prefix
All local symbols begin with the system-specific local label prefix. Normally
both as and ld forget symbols that start with the local label prefix. These
labels are used for symbols you are never intended to see. If you use the ‘-L’
option then as retains these symbols in the object file. If you also instruct ld
to retain these symbols, you may use them in debugging.
number This is the number that was used in the local label definition. So if the label is
written ‘55:’ then the number is ‘55’.
C-B This unusual character is included so you do not accidentally invent a symbol
of the same name. The character has ASCII value of ‘\002’ (control-B).
ordinal number
This is a serial number to keep the labels distinct. The first definition of ‘0:’
gets the number ‘1’. The 15th definition of ‘0:’ gets the number ‘15’, and so on.
Chapter 5: Symbols 45
Likewise the first definition of ‘1:’ gets the number ‘1’ and its 15th definition
gets ‘15’ as well.
So for example, the first 1: may be named .L1C-B1, and the 44th 3: may be named
.L3C-B44.
5.5.1 Value
The value of a symbol is (usually) 32 bits. For a symbol which labels a location in the
text, data, bss or absolute sections the value is the number of addresses from the start of
that section to the label. Naturally for text, data and bss sections the value of a symbol
changes as ld changes section base addresses during linking. Absolute symbols’ values do
not change during linking: that is why they are called absolute.
The value of an undefined symbol is treated in a special way. If it is 0 then the symbol
is not defined in this assembler source file, and ld tries to determine its value from other
files linked into the same program. You make this kind of symbol simply by mentioning a
symbol name without defining it. A non-zero value represents a .comm common declaration.
The value is how much common storage to reserve, in bytes (addresses). The symbol refers
to the first address of the allocated storage.
46 Using as
5.5.2 Type
The type attribute of a symbol contains relocation (section) information, any flag settings
indicating that a symbol is external, and (optionally), other information for linkers and
debuggers. The exact format depends on the object-code output format in use.
5.5.3.2 Other
This is an arbitrary 8-bit value. It means nothing to as.
6 Expressions
An expression specifies an address or numeric value. Whitespace may precede and/or follow
an expression.
The result of an expression must be an absolute number, or else an offset into a particular
section. If an expression is not absolute, and there is not enough information when as sees
the expression to know its section, a second pass over the source program might be necessary
to interpret the expression—but the second pass is currently not implemented. as aborts
with an error message in this situation.
6.2.1 Arguments
Arguments are symbols, numbers or subexpressions. In other contexts arguments are some-
times called “arithmetic operands”. In this manual, to avoid confusing them with the
“instruction operands” of the machine language, we use the term “argument” to refer to
parts of expressions only, reserving the word “operand” to refer only to machine instruction
operands.
Symbols are evaluated to yield {section NNN } where section is one of text, data, bss,
absolute, or undefined. NNN is a signed, 2’s complement 32 bit integer.
Numbers are usually integers.
A number can be a flonum or bignum. In this case, you are warned that only the low
order 32 bits are used, and as pretends these 32 bits are an integer. You may write integer-
manipulating instructions that act on exotic constants, compatible with other assemblers.
Subexpressions are a left parenthesis ‘(’ followed by an integer expression, followed by a
right parenthesis ‘)’; or a prefix operator followed by an argument.
6.2.2 Operators
Operators are arithmetic functions, like + or %. Prefix operators are followed by an argu-
ment. Infix operators appear between their arguments. Operators may be preceded and/or
followed by whitespace.
|| Logical Or.
These two logical operations can be used to combine the results of sub
expressions. Note, unlike the comparison operators a true result returns a
value of 1 but a false results does still return 0. Also note that the logical
or operator has a slightly lower precedence than logical and.
In short, it’s only meaningful to add or subtract the offsets in an address; you can only
have a defined section in one of the two arguments.
51
7 Assembler Directives
All assembler directives have names that begin with a period (‘.’). The names are case
insensitive for most targets, and usually written in lower case.
This chapter discusses directives that are available regardless of the target machine
configuration for the gnu assembler. Some machine configurations provide additional di-
rectives. See Chapter 9 [Machine Dependencies], page 95.
7.1 .abort
This directive stops the assembly immediately. It is for compatibility with other assemblers.
The original idea was that the assembly language source would be piped into the assembler.
If the sender of the source quit, it could use this directive tells as to quit also. One day
.abort will not be supported.
directives, described later, which have a consistent behavior across all architectures (but
are specific to GAS).
7.4 .altmacro
Enable alternate macro mode, enabling:
String delimiters
You can write strings delimited in these other ways besides "string":
next bundle. As a corollary, it’s an error if any single instruction’s encoding is longer than
the bundle size.
7.12.3 .cfi_endproc
.cfi_endproc is used at the end of a function where it closes its unwind entry previously
opened by .cfi_startproc, and emits it to .eh_frame.
7.12.5 .cfi_personality_id id
cfi_personality_id defines a personality routine by its index as defined in a compact un-
winding format. Only valid when generating compact EH frames (i.e. with .cfi_sections
eh_frame_entry.
The optional align argument specifies the alignment required. The alignment is specified
as a power of two, as with the .p2align directive.
Here, we want the .cfi directives to affect only the rows corresponding to the instruc-
tions before label. This means we’d have to add multiple .cfi directives after label to
recreate the original save locations of the registers, as well as setting the CFA back to the
value of rbp. This would be clumsy, and result in a larger binary size. Instead, we can
write:
je label
popq %rbx
.cfi_remember_state
.cfi_restore %rbx
popq %r12
.cfi_restore %r12
popq %rbp
.cfi_restore %rbp
.cfi_def_cfa %rsp, 8
ret
label:
.cfi_restore_state
/* Do something else */
That way, the rules for the instructions after label will be the same as before the first
.cfi_restore without having to use multiple .cfi directives.
7.12.22 .cfi_signal_frame
Mark current function as signal trampoline.
7.12.23 .cfi_window_save
SPARC register window has been saved.
58 Using as
The usefulness of equating a register to a fixed label is probably limited to the return
address register. Here, it can be useful to mark a code segment that has only one return
address which is reached by a direct branch and no copy of the return address exists in
memory or another register.
When using ELF or (as a GNU extension) PE, the .comm directive takes an optional
third argument. This is the desired alignment of the symbol, specified for ELF as a byte
boundary (for example, an alignment of 16 means that the least significant 4 bits of the
address should be zero), and for PE as a power of two (for example, an alignment of 5
means aligned to a 32-byte boundary). The alignment must be an absolute expression, and
it must be a power of two. If ld allocates uninitialized memory for the common symbol, it
will use the alignment when placing the symbol. If no alignment is specified, as will set the
alignment to the largest power of two less than or equal to the size of the symbol, up to a
maximum of 16 on ELF, or the default section alignment of 4 on PE1 .
The syntax for .comm differs slightly on the HPPA. The syntax is ‘symbol .comm,
length’; symbol is optional.
1
This is not the same as the executable image file alignment controlled by ld’s ‘--section-alignment’
option; image file sections in PE are aligned to multiples of 4096, which is far too large an alignment for
ordinary variables. It is rather the default alignment for (non-debug) sections within object (‘*.o’) files,
which are less strictly aligned.
Chapter 7: Assembler Directives 59
7.20 .dim
This directive is generated by compilers to include auxiliary debugging information in the
symbol table. It is only permitted inside .def/.endef pairs.
7.22 .eject
Force a page break at this point, when generating assembly listings.
7.23 .else
.else is part of the as support for conditional assembly; see Section 7.46 [.if], page 64. It
marks the beginning of a section of code to be assembled if the condition for the preceding
.if was false.
7.24 .elseif
.elseif is part of the as support for conditional assembly; see Section 7.46 [.if], page 64.
It is shorthand for beginning a new .if block that would otherwise fill the entire .else
section.
Chapter 7: Assembler Directives 61
7.25 .end
.end marks the end of the assembly file. as does not process anything in the file past the
.end directive.
7.26 .endef
This directive flags the end of a symbol definition begun with .def.
7.27 .endfunc
.endfunc marks the end of a function specified with .func.
7.28 .endif
.endif is part of the as support for conditional assembly; it marks the end of a block of
code that is only assembled conditionally. See Section 7.46 [.if], page 64.
7.32 .err
If as assembles a .err directive, it will print an error message and, unless the -Z option was
used, it will not generate an object file. This can be used to signal an error in conditionally
compiled code.
62 Using as
7.34 .exitm
Exit early from the current macro definition. See Section 7.63 [Macro], page 69.
7.35 .extern
.extern is accepted in the source program—for compatibility with other assemblers—but
it is ignored. as treats all undefined symbols as external.
7.37 .file
There are two different versions of the .file directive. Targets that support DWARF2
line number information use the DWARF2 version of .file. Other targets use the default
version.
Default Version
This version of the .file directive tells as that we are about to start a new logical file.
The syntax is:
.file string
string is the new file name. In general, the filename is recognized whether or not it is
surrounded by quotes ‘"’; but if you wish to specify an empty file name, you must give the
quotes–"". This statement may go away in future: it is only recognized to be compatible
with old as programs.
DWARF2 Version
When emitting DWARF2 line number information, .file assigns filenames to the .debug_
line file name table. The syntax is:
.file fileno filename
The fileno operand should be a unique positive integer to use as the index of the entry
in the table. The filename operand is a C string literal enclosed in double quotes. The
filename can include directory elements. If it does, then the directory will be added to the
directory table and the basename will be added to the file table.
The detail of filename indices is exposed to the user because the filename table is shared
with the .debug_info section of the DWARF2 debugging information, and thus the user
must know the exact indices that table entries will have.
Chapter 7: Assembler Directives 63
If DWARF-5 support has been enabled via the -gdwarf-5 option then an extended
version of the file is also allowed:
.file fileno [dirname] filename [md5 value]
With this version a separate directory name is allowed, although if this is used then
filename should not contain any directory components. In addtion an md5 hash value of
the contents of filename can be provided. This will be stored in the the file table as well,
and can be used by tools reading the debug information to verify that the contents of the
source file match the contents of the compiled file.
7.45 .ident
This directive is used by some assemblers to place tags in object files. The behavior of
this directive varies depending on the target. When using the a.out object file format, as
simply accepts the directive for source-file compatibility with existing assemblers, but does
not emit anything for it. When using COFF, comments are emitted to the .comment or
.rdata section, depending on the target. When using ELF, comments are emitted to the
.comment section.
of the line. Strings which contain whitespace should be quoted. The string
comparison is case sensitive.
.ifeq absolute expression
Assembles the following section of code if the argument is zero.
.ifeqs string1,string2
Another form of .ifc. The strings must be quoted using double quotes.
.ifge absolute expression
Assembles the following section of code if the argument is greater than or equal
to zero.
.ifgt absolute expression
Assembles the following section of code if the argument is greater than zero.
.ifle absolute expression
Assembles the following section of code if the argument is less than or equal to
zero.
.iflt absolute expression
Assembles the following section of code if the argument is less than zero.
.ifnb text
Like .ifb, but the sense of the test is reversed: this assembles the following
section of code if the operand is non-blank (non-empty).
.ifnc string1,string2.
Like .ifc, but the sense of the test is reversed: this assembles the following
section of code if the two strings are not the same.
.ifndef symbol
.ifnotdef symbol
Assembles the following section of code if the specified symbol has not been
defined. Both spelling variants are equivalent. Note a symbol which has been
referenced but not yet defined is considered to be undefined.
.ifne absolute expression
Assembles the following section of code if the argument is not equal to zero (in
other words, this is equivalent to .if).
.ifnes string1,string2
Like .ifeqs, but the sense of the test is reversed: this assembles the following
section of code if the two strings are not the same.
7.54 .lflags
as accepts this directive, for compatibility with other assemblers, but ignores it.
This directive is only supported by a few object file formats; as of this writing, the only
object file format which supports it is the Portable Executable format used on Windows
NT.
The type argument is optional. If specified, it must be one of the following strings. For
example:
.linkonce same_size
Not all types may be supported on all object file formats.
discard Silently discard duplicate sections. This is the default.
one_only Warn if there are duplicate sections, but still keep only one copy.
same_size
Warn if any of the duplicates have different sizes.
same_contents
Warn if any of the duplicates do not have exactly the same contents.
7.57 .list
Control (in conjunction with the .nolist directive) whether or not assembly listings are
generated. These two directives maintain an internal counter (which is zero initially).
.list increments the counter, and .nolist decrements it. Assembly listings are generated
whenever the counter is greater than zero.
By default, listings are disabled. When you enable them (with the ‘-a’ command-line
option; see Chapter 2 [Command-Line Options], page 25), the initial value of the listing
counter is one.
is_stmt value
This option will set the is_stmt register in the .debug_line state machine to
value, which must be either 0 or 1.
isa value This directive will set the isa register in the .debug_line state machine to
value, which must be an unsigned integer.
discriminator value
This directive will set the discriminator register in the .debug_line state
machine to value, which must be an unsigned integer.
view value
This option causes a row to be added to .debug_line in reference to the cur-
rent address (which might not be the same as that of the following assembly
instruction), and to associate value with the view register in the .debug_line
state machine. If value is a label, both the view register and the label are set
to the number of prior .loc directives at the same program location. If value
is the literal 0, the view register is set to zero, and the assembler asserts that
there aren’t any prior .loc directives at the same program location. If value
is the literal -0, the assembler arrange for the view register to be reset in this
row, even if there are prior .loc directives at the same program location.
7.63 .macro
The commands .macro and .endm allow you to define macros that generate assembly output.
For example, this definition specifies a macro sum that puts a sequence of numbers into
memory:
.macro sum from=0, to=5
.long \from
70 Using as
.if \to-\from
sum "(\from+1)",\to
.endif
.endm
With that definition, ‘SUM 0,5’ is equivalent to this assembly input:
.long 0
.long 1
.long 2
.long 3
.long 4
.long 5
.macro macname
.macro macname macargs ...
Begin the definition of a macro called macname. If your macro definition re-
quires arguments, specify their names after the macro name, separated by com-
mas or spaces. You can qualify the macro argument to indicate whether all
invocations must specify a non-blank value (through ‘:req’), or whether it
takes all of the remaining arguments (through ‘:vararg’). You can supply a
default value for any macro argument by following the name with ‘=deflt’. You
cannot define two macros with the same macname unless it has been subject
to the .purgem directive (see Section 7.78 [Purgem], page 75) between the two
definitions. For example, these are all valid .macro statements:
.macro comm
Begin the definition of a macro called comm, which takes no argu-
ments.
.macro plus1 p, p1
.macro plus1 p p1
Either statement begins the definition of a macro called plus1,
which takes two arguments; within the macro definition, write ‘\p’
or ‘\p1’ to evaluate the arguments.
.macro reserve_str p1=0 p2
Begin the definition of a macro called reserve_str, with two argu-
ments. The first argument has a default value, but not the second.
After the definition is complete, you can call the macro either as
‘reserve_str a,b’ (with ‘\p1’ evaluating to a and ‘\p2’ evaluating
to b), or as ‘reserve_str ,b’ (with ‘\p1’ evaluating as the default,
in this case ‘0’, and ‘\p2’ evaluating to b).
.macro m p1:req, p2=0, p3:vararg
Begin the definition of a macro called m, with at least three ar-
guments. The first argument must always have a value specified,
but not the second, which instead has a default value. The third
formal will get assigned all remaining arguments specified at invo-
cation time.
Chapter 7: Assembler Directives 71
When you call a macro, you can specify the argument values either
by position, or by keyword. For example, ‘sum 9,17’ is equivalent
to ‘sum to=17, from=9’.
Note that since each of the macargs can be an identifier exactly as any other
one permitted by the target architecture, there may be occasional problems if
the target hand-crafts special meanings to certain characters when they occur
in a special position. For example, if the colon (:) is generally permitted to
be part of a symbol name, but the architecture specific code special-cases it
when occurring as the final character of a symbol (to denote a label), then
the macro parameter replacement code will have no way of knowing that and
consider the whole construct (including the colon) an identifier, and check only
this identifier for being the subject to parameter substitution. So for example
this macro definition:
.macro label l
\l:
.endm
might not work as expected. Invoking ‘label foo’ might not create a label
called ‘foo’ but instead just insert the text ‘\l:’ into the assembler source,
probably generating an error about an unrecognised identifier.
Similarly problems might occur with the period character (‘.’) which is often
allowed inside opcode names (and hence identifier names). So for example
constructing a macro to build an opcode from a base name and a length specifier
like this:
.macro opcode base length
\base.\length
.endm
and invoking it as ‘opcode store l’ will not create a ‘store.l’ instruction but
instead generate some kind of error as the assembler tries to interpret the text
‘\base.\length’.
There are several possible ways around this problem:
Insert white space
If it is possible to use white space characters then this is the simplest
solution. eg:
.macro label l
\l :
.endm
Use ‘\()’ The string ‘\()’ can be used to separate the end of a macro argu-
ment from the following text. eg:
.macro opcode base length
\base\().\length
.endm
Use the alternate macro syntax mode
In the alternative macro syntax mode the ampersand character (‘&’)
can be used as a separator. eg:
72 Using as
.altmacro
.macro label l
l&:
.endm
Note: this problem of correctly identifying string parameters to pseudo ops
also applies to the identifiers used in .irp (see Section 7.51 [Irp], page 66) and
.irpc (see Section 7.52 [Irpc], page 66) as well.
.endm Mark the end of a macro definition.
.exitm Exit early from the current macro definition.
\@ as maintains a counter of how many macros it has executed in this pseudo-
variable; you can copy that number to your output with ‘\@’, but only within
a macro definition.
LOCAL name [ , ... ]
Warning: LOCAL is only available if you select “alternate macro syntax” with
‘--alternate’ or .altmacro. See Section 7.4 [.altmacro], page 52.
7.65 .noaltmacro
Disable alternate macro mode. See Section 7.4 [Altmacro], page 52.
7.66 .nolist
Control (in conjunction with the .list directive) whether or not assembly listings are
generated. These two directives maintain an internal counter (which is zero initially).
.list increments the counter, and .nolist decrements it. Assembly listings are generated
whenever the counter is greater than zero.
be absolute and positive. These bytes do not affect the generation of DWARF debug line
information.
The optional control argument specifies a size limit for a single no-op instruction. If not
provided then a value of 0 is assumed. The valid values of control are between 0 and 4 in
16-bit mode, between 0 and 7 when tuning for older processors in 32-bit mode, between 0
and 11 in 64-bit mode or when tuning for newer processors in 32-bit mode. When 0 is used,
the no-op instruction size limit is set to the maximum supported size.
The second expression (also absolute) gives the fill value to be stored in the padding
bytes. It (and the comma) may be omitted. If it is omitted, the padding bytes are normally
zero. However, on most systems, if the section is marked as containing code and the fill
value is omitted, the space is filled with no-op instructions.
The third expression is also absolute, and is also optional. If it is present, it is the
maximum number of bytes that should be skipped by this alignment directive. If doing
the alignment would require skipping more bytes than the specified maximum, then the
alignment is not done at all. You can omit the fill value (the second argument) entirely by
simply using two commas after the required alignment; this can be useful if you want the
alignment to be filled with no-op instructions when appropriate.
The .p2alignw and .p2alignl directives are variants of the .p2align directive. The
.p2alignw directive treats the fill pattern as a two byte word value. The .p2alignl di-
rectives treats the fill pattern as a four byte longword value. For example, .p2alignw
2,0x368d will align to a multiple of 4. If it skips two bytes, they will be filled in with
the value 0x368d (the exact placement of the bytes depends upon the endianness of the
processor). If it skips 1 or 3 bytes, the fill value is undefined.
7.73 .popsection
This is one of the ELF section stack manipulation directives. The others are .section
(see Section 7.85 [Section], page 77), .subsection (see Section 7.96 [SubSection], page 84),
.pushsection (see Section 7.79 [PushSection], page 76), and .previous (see Section 7.74
[Previous], page 74).
This directive replaces the current section (and subsection) with the top section (and
subsection) on the section stack. This section is popped off the stack.
7.74 .previous
This is one of the ELF section stack manipulation directives. The others are .section
(see Section 7.85 [Section], page 77), .subsection (see Section 7.96 [SubSection], page 84),
.pushsection (see Section 7.79 [PushSection], page 76), and .popsection (see Section 7.73
[PopSection], page 74).
This directive swaps the current section (and subsection) with most recently referenced
section/subsection pair prior to this one. Multiple .previous directives in a row will flip
between two sections (and their subsections). For example:
.section A
.subsection 1
.word 0x1234
.subsection 2
.word 0x5678
.previous
.word 0x9abc
Will place 0x1234 and 0x9abc into subsection 1 and 0x5678 into subsection 2 of section
A. Whilst:
.section A
.subsection 1
# Now in section A subsection 1
.word 0x1234
Chapter 7: Assembler Directives 75
.section B
.subsection 0
# Now in section B subsection 0
.word 0x5678
.subsection 1
# Now in section B subsection 1
.word 0x9abc
.previous
# Now in section B subsection 0
.word 0xdef0
Will place 0x1234 into section A, 0x5678 and 0xdef0 into subsection 0 of section B and
0x9abc into subsection 1 of section B.
In terms of the section stack, this directive swaps the current section with the top section
on the section stack.
This directive affects subsequent pages, as well as the current page if it appears within
ten lines of the top of a page.
COFF Version
For COFF targets, the .section directive is used in one of the following ways:
.section name[, "flags"]
.section name[, subsection]
If the optional argument is quoted, it is taken as flags to use for the section. Each flag
is a single character. The following flags are recognized:
b bss section (uninitialized data)
n section is not loaded
w writable section
d data section
e exclude section from linking
r read-only section
x executable section
s shared section (meaningful for PE targets)
a ignored. (For compatibility with the ELF version)
y section is not readable (meaningful for PE targets)
0-9 single-digit power-of-two section alignment (GNU extension)
If no flags are specified, the default flags depend upon the section name. If the section
name is not recognized, the default will be for the section to be loaded and writable. Note
the n and w flags remove attributes from the section, rather than adding them, so if they
are used on their own it will be as if no flags had been specified at all.
If the optional argument to the .section directive is not quoted, it is taken as a sub-
section number (see Section 4.4 [Sub-Sections], page 39).
78 Using as
ELF Version
This is one of the ELF section stack manipulation directives. The others are .subsection
(see Section 7.96 [SubSection], page 84), .pushsection (see Section 7.79 [PushSection],
page 76), .popsection (see Section 7.73 [PopSection], page 74), and .previous (see
Section 7.74 [Previous], page 74).
For ELF targets, the .section directive is used like this:
.section name [, "flags"[, @type[,flag_specific_arguments]]]
If the ‘--sectname-subst’ command-line option is provided, the name argument may
contain a substitution sequence. Only %S is supported at the moment, and substitutes the
current section name. For example:
.macro exception_code
.section %S.exception
[exception code here]
.previous
.endm
.text
[code]
exception_code
[...]
.section .init
[init code]
exception_code
[...]
The two exception_code invocations above would create the .text.exception and
.init.exception sections respectively. This is useful e.g. to discriminate between ancillary
sections that are tied to setup code to be discarded after use from ancillary sections that
need to stay resident without having to define multiple exception_code macros just for
that purpose.
The optional flags argument is a quoted string which may contain any combination of
the following characters:
a section is allocatable
d section is a GNU MBIND section
e section is excluded from executable and shared library.
o section references a symbol defined in another section (the linked-to section) in
the same file.
w section is writable
x section is executable
M section is mergeable
S section contains zero terminated strings
G section is a member of a section group
T section is used for thread-local-storage
? section is a member of the previously-current section’s group, if any
Chapter 7: Assembler Directives 79
R retained section (apply SHF GNU RETAIN to prevent linker garbage collec-
tion, GNU ELF extension)
<number> a numeric value indicating the bits to be set in the ELF section header’s flags
field. Note - if one or more of the alphabetic characters described above is also
included in the flags field, their bit values will be ORed into the resulting value.
<target specific>
some targets extend this list with their own flag characters
Note - once a section’s flags have been set they cannot be changed. There are a few
exceptions to this rule however. Processor and application specific flags can be added to an
already defined section. The .interp, .strtab and .symtab sections can have the allocate
flag (a) set after they are initially defined, and the .note-GNU-stack section may have the
executable (x) flag added. Also note that the .attach_to_group directive can be used to
add a section to a group even if the section was not originally declared to be part of that
group.
The optional type argument may contain one of the following constants:
@progbits
section contains data
@nobits section does not contain data (i.e., section only occupies space)
@note section contains data which is used by things other than the program
@init_array
section contains an array of pointers to init functions
@fini_array
section contains an array of pointers to finish functions
@preinit_array
section contains an array of pointers to pre-init functions
@<number>
a numeric value to be set as the ELF section header’s type field.
@<target specific>
some targets extend this list with their own types
Many targets only support the first three section types. The type may be enclosed in
double quotes if necessary.
Note on targets where the @ character is the start of a comment (eg ARM) then another
character is used instead. For example the ARM port uses the % character.
Note - some sections, eg .text and .data are considered to be special and have fixed
types. Any attempt to declare them with a different type will generate an error from the
assembler.
If flags contains the M symbol then the type argument must be specified as well as an
extra argument—entsize—like this:
.section name , "flags"M, @type, entsize
Sections with the M flag but not S flag must contain fixed size constants, each entsize
octets long. Sections with both M and S must contain zero terminated strings where each
80 Using as
character is entsize bytes long. The linker may remove duplicates within sections with the
same name, same entity size and same flags. entsize must be an absolute expression. For
sections with both M and S, a string which is a suffix of a larger string is considered a
duplicate. Thus "def" will be merged with "abcdef"; A reference to the first "def" will
be changed to a reference to "abcdef"+3.
If flags contains the o flag, then the type argument must be present along with an
additional field like this:
.section name,"flags"o,@type,SymbolName|SectionIndex
The SymbolName field specifies the symbol name which the section references. Alter-
natively a numeric SectionIndex can be provided. This is not generally a good idea as
section indicies are rarely known at assembly time, but the facility is provided for testing
purposes. An index of zero is allowed. It indicates that the linked-to section has already
been discarded.
Note: If both the M and o flags are present, then the fields for the Merge flag should
come first, like this:
.section name,"flags"Mo,@type,entsize,SymbolName
If flags contains the G symbol then the type argument must be present along with an
additional field like this:
.section name , "flags"G, @type, GroupName[, linkage]
The GroupName field specifies the name of the section group to which this particular
section belongs. The optional linkage field can contain:
comdat indicates that only one copy of this section should be retained
.gnu.linkonce
an alias for comdat
Note: if both the M and G flags are present then the fields for the Merge flag should
come first, like this:
.section name , "flags"MG, @type, entsize, GroupName[, linkage]
If both o flag and G flag are present, then the SymbolName field for o comes first, like
this:
.section name,"flags"oG,@type,SymbolName,GroupName[,linkage]
If flags contains the ? symbol then it may not also contain the G symbol and the Group-
Name or linkage fields should not be present. Instead, ? says to consider the section that’s
current before this directive. If that section used G, then the new section will use G with
those same GroupName and linkage fields implicitly. If not, then the ? symbol has no effect.
The optional unique,<number> argument must come last. It assigns <number> as a unique
section ID to distinguish different sections with the same section name like these:
.section name,"flags",@type,unique,<number>
.section name,"flags"G,@type,GroupName,[linkage],unique,<number>
.section name,"flags"MG,@type,entsize,GroupName[,linkage],unique,<number>
The valid values of <number> are between 0 and 4294967295.
If no flags are specified, the default flags depend upon the section name. If the section
name is not recognized, the default will be for the section to have none of the above flags:
it will not be allocated in memory, nor writable, nor executable. The section will contain
data.
Chapter 7: Assembler Directives 81
For ELF targets, the assembler supports another type of .section directive for compat-
ibility with the Solaris assembler:
.section "name"[, flags...]
Note that the section name is quoted. There may be a sequence of comma separated
flags:
#alloc section is allocatable
#write section is writable
#execinstr
section is executable
#exclude section is excluded from executable and shared library.
#tls section is used for thread local storage
This directive replaces the current section and subsection. See the contents of the gas
testsuite directory gas/testsuite/gas/elf for some examples of how this directive and
the other section stack directives work.
7.89 .size
This directive is used to set the size associated with a symbol.
COFF Version
For COFF targets, the .size directive is only permitted inside .def/.endef pairs. It is
used like this:
.size expression
ELF Version
For ELF targets, the .size directive is used like this:
.size name , expression
This directive sets the size associated with a symbol name. The size in bytes is computed
from expression which can make use of label arithmetic. This directive is typically used to
set the size of function symbols.
other An absolute expression. The symbol’s “other” attribute is set to the low 8 bits
of this expression.
desc An absolute expression. The symbol’s descriptor is set to the low 16 bits of this
expression.
value An absolute expression which becomes the symbol’s value.
If a warning is detected while reading a .stabd, .stabn, or .stabs statement, the
symbol has probably already been created; you get a half-formed symbol in your object file.
This is compatible with earlier assemblers!
.stabd type , other , desc
The “name” of the symbol generated is not even an empty string. It is a null
pointer, for compatibility. Older assemblers used a null pointer so they didn’t
waste space in object files with empty strings.
The symbol’s value is set to the location counter, relocatably. When your
program is linked, the value of this symbol is the address of the location counter
when the .stabd was assembled.
.stabn type , other , desc , value
The name of the symbol is set to the empty string "".
.stabs string , type , other , desc , value
All five fields are specified.
This would define the symbol field1 to have the value 0, the symbol field2 to have
the value 4, and the symbol field3 to have the value 8. Assembly would be left in the
absolute section, and you would need to use a .section directive of some sort to change to
some other section before further assembly.
7.97 .symver
Use the .symver directive to bind symbols to specific version nodes within a source file.
This is only supported on ELF platforms, and is typically used when assembling files to be
linked into a shared library. There are cases where it may make sense to use this in objects
to be bound into an application itself so as to override a versioned symbol from a shared
library.
For ELF targets, the .symver directive can be used like this:
.symver name, name2@nodename[ ,visibility]
If the original symbol name is defined within the file being assembled, the .symver
directive effectively creates a symbol alias with the name name2@nodename, and in fact
the main reason that we just don’t try and create a regular alias is that the @ character
isn’t permitted in symbol names. The name2 part of the name is the actual name of the
symbol by which it will be externally referenced. The name name itself is merely a name of
convenience that is used so that it is possible to have definitions for multiple versions of a
function within a single source file, and so that the compiler can unambiguously know which
version of a function is being mentioned. The nodename portion of the alias should be the
name of a node specified in the version script supplied to the linker when building a shared
library. If you are attempting to override a versioned symbol from a shared library, then
nodename should correspond to the nodename of the symbol you are trying to override.
The optional argument visibility updates the visibility of the original symbol. The valid
visibilities are local, hidden, and remove. The local visibility makes the original symbol
a local symbol (see Section 7.61 [Local], page 69). The hidden visibility sets the visibility
of the original symbol to hidden (see Section 7.43 [Hidden], page 64). The remove visibility
removes the original symbol from the symbol table. If visibility isn’t specified, the original
symbol is unchanged.
If the symbol name is not defined within the file being assembled, all references to name
will be changed to name2@nodename. If no reference to name is made, name2@nodename
will be removed from the symbol table.
Another usage of the .symver directive is:
.symver name, name2@@nodename
Chapter 7: Assembler Directives 85
In this case, the symbol name must exist and be defined within the file being assembled.
It is similar to name2@nodename. The difference is name2@@nodename will also be used
to resolve references to name2 by the linker.
The third usage of the .symver directive is:
.symver name, name2@@@nodename
When name is not defined within the file being assembled, it is treated as
name2@nodename. When name is defined within the file being assembled, the symbol
name, name, will be changed to name2@@nodename.
7.102 .type
This directive is used to set the type of a symbol.
COFF Version
For COFF targets, this directive is permitted only within .def/.endef pairs. It is used
like this:
.type int
This records the integer int as the type attribute of a symbol table entry.
ELF Version
For ELF targets, the .type directive is used like this:
.type name , type description
86 Using as
This sets the type of symbol name to be either a function symbol or an object symbol.
There are five different syntaxes supported for the type description field, in order to provide
compatibility with various other assemblers.
Because some of the characters used in these syntaxes (such as ‘@’ and ‘#’) are comment
characters for some architectures, some of the syntaxes below do not work on all architec-
tures. The first variant will be accepted by the GNU assembler on all architectures so that
variant should be used for maximum portability, if you do not need to assemble your code
with other assemblers.
The syntaxes supported are:
.type <name> STT_<TYPE_IN_UPPER_CASE>
.type <name>,#<type>
.type <name>,@<type>
.type <name>,%<type>
.type <name>,"<type>"
The types supported are:
STT_FUNC
function Mark the symbol as being a function name.
STT_GNU_IFUNC
gnu_indirect_function
Mark the symbol as an indirect function when evaluated during reloc processing.
(This is only supported on assemblers targeting GNU systems).
STT_OBJECT
object Mark the symbol as being a data object.
STT_TLS
tls_object
Mark the symbol as being a thread-local data object.
STT_COMMON
common Mark the symbol as being a common data object.
STT_NOTYPE
notype Does not mark the symbol in any way. It is supported just for completeness.
gnu_unique_object
Marks the symbol as being a globally unique data object. The dynamic linker
will make sure that in the entire process there is just one symbol with this
name and type in use. (This is only supported on assemblers targeting GNU
systems).
Changing between incompatible types other than from/to STT NOTYPE will result in
a diagnostic. An intermediate change to STT NOTYPE will silence this.
Note: Some targets support extra types in addition to those listed above.
8 Object Attributes
as assembles source files written for a specific architecture into object files for that architec-
ture. But not all object files are alike. Many architectures support incompatible variations.
For instance, floating point arguments might be passed in floating point registers if the
object file requires hardware floating point support—or floating point arguments might be
passed in integer registers if the object file supports processors with no hardware floating
point unit. Or, if two objects are built for different generations of the same architecture,
the combination may require the newer generation at run-time.
This information is useful during and after linking. At link time, ld can warn about
incompatible object files. After link time, tools like gdb can use it to process the linked file
correctly.
Compatibility information is recorded as a series of object attributes. Each attribute has
a vendor, tag, and value. The vendor is a string, and indicates who sets the meaning of the
tag. The tag is an integer, and indicates what property the attribute describes. The value
may be a string or an integer, and indicates how the property affects this object. Missing
attributes are the same as attributes with a zero value or empty string value.
Object attributes were developed as part of the ABI for the ARM Architecture. The file
format is documented in ELF for the ARM Architecture.
-mno-verbose-error
This option disables verbose error messages in AArch64 gas.
9.1.3 Syntax
Chapter 9: Machine Dependent Features 99
9.1.3.3 Relocations
Relocations for ‘MOVZ’ and ‘MOVK’ instructions can be generated by prefixing the label with
‘#:abs_g2:’ etc. For example to load the 48-bit absolute address of foo into x0:
movz x0, #:abs_g2:foo // bits 32-47, overflow check
movk x0, #:abs_g1_nc:foo // bits 16-31, no overflow check
movk x0, #:abs_g0_nc:foo // bits 0-15, no overflow check
Relocations for ‘ADRP’, and ‘ADD’, ‘LDR’ or ‘STR’ instructions can be generated by prefixing
the label with ‘:pg_hi21:’ and ‘#:lo12:’ respectively.
For example to use 33-bit (+/-4GB) pc-relative addressing to load the address of foo into
x0:
adrp x0, :pg_hi21:foo
add x0, x0, #:lo12:foo
Or to load the value of foo into x0:
adrp x0, :pg_hi21:foo
ldr x0, [x0, #:lo12:foo]
Note that ‘:pg_hi21:’ is optional.
adrp x0, foo
is equivalent to
adrp x0, :pg_hi21:foo
.variant_pcs symbol
This directive marks symbol referencing a function that may follow a variant
procedure call standard with different register usage convention from the base
procedure call standard.
.xword expressions
The .xword directive produces 64 bit values. This is the same as the .dword
directive.
.cfi_b_key_frame
The .cfi_b_key_frame directive inserts a ’B’ character into the CIE corre-
sponding to the current frame’s FDE, meaning that its return address has been
signed with the B-key. If two frames are signed with differing keys then they
will not share the same CIE. This information is intended to be used by the
stack unwinder in order to properly authenticate return addresses.
9.1.6 Opcodes
GAS implements all the standard AArch64 opcodes. It also implements several pseudo
opcodes, including several synthetic load instructions.
LDR =
ldr <register> , =<expression>
The constant expression will be placed into the nearest literal pool (if it not
already there) and a PC-relative LDR instruction will be generated.
For more information on the AArch64 instruction set and assembly language notation,
see ‘ARMv8 Instruction Set Overview’ available at http://infocenter.arm.com.
9.2.2 Options
-mcpu This option specifies the target processor. If an attempt is made to assemble an
instruction which will not execute on the target processor, the assembler may
either expand the instruction as a macro or issue an error message. This option
is equivalent to the .arch directive.
The following processor names are recognized: 21064, 21064a, 21066, 21068,
21164, 21164a, 21164pc, 21264, 21264a, 21264b, ev4, ev5, lca45, ev5, ev56,
pca56, ev6, ev67, ev68. The special name all may be used to allow the
assembler to accept instructions valid for any Alpha processor.
In order to support existing practice in OSF/1 with respect to .arch, and exist-
ing practice within MILO (the Linux ARC bootloader), the numbered processor
names (e.g. 21064) enable the processor-specific PALcode instructions, while
the “electro-vlasic” names (e.g. ev4) do not.
-mdebug
-no-mdebug
Enables or disables the generation of .mdebug encapsulation for stabs directives
and procedure descriptors. The default is to automatically enable .mdebug
when the first stabs directive is seen.
-relax This option forces all relocations to be put into the object file, instead of saving
space and resolving some relocations at assembly time. Note that this option
does not propagate all symbol arithmetic into the object file, because not all
symbol arithmetic can be represented. However, the option can still be useful
in specific applications.
-replace
-noreplace
Enables or disables the optimization of procedure calls, both at assemblage and
at link time. These options are only available for VMS targets and -replace
is the default. See section 1.4.1 of the OpenVMS Linker Utility Manual.
-g This option is used when the compiler generates debug information. When gcc
is using mips-tfile to generate debug information for ECOFF, local labels
must be passed through to the object file. Otherwise this option has no effect.
-Gsize A local common symbol larger than size is placed in .bss, while smaller symbols
are placed in .sbss.
-F
-32addr These options are ignored for backward compatibility.
Chapter 9: Machine Dependent Features 103
9.2.3 Syntax
The assembler syntax closely follow the Alpha Reference Manual; assembler directives and
general syntax closely follow the OSF/1 and OpenVMS syntax, with a few differences for
ELF.
9.2.3.3 Relocations
Some of these relocations are available for ECOFF, but mostly only for ELF. They are
modeled after the relocation format introduced in Digital Unix 4.0, but there are additions.
The format is ‘!tag’ or ‘!tag!number’ where tag is the name of the relocation. In some
cases number is used to relate specific instructions.
The relocation is placed at the end of the instruction like so:
ldah $0,a($29) !gprelhigh
lda $0,a($0) !gprellow
ldq $1,b($29) !literal!100
ldl $2,0($1) !lituse_base!100
!literal
!literal!N
Used with an ldq instruction to load the address of a symbol from the GOT.
A sequence number N is optional, and if present is used to pair lituse relo-
cations with this literal relocation. The lituse relocations are used by the
linker to optimize the code based on the final location of the symbol.
Note that these optimizations are dependent on the data flow of the program.
Therefore, if any lituse is paired with a literal relocation, then all uses of
the register set by the literal instruction must also be marked with lituse
relocations. This is because the original literal instruction may be deleted or
transformed into another instruction.
Also note that there may be a one-to-many relationship between literal and
lituse, but not a many-to-one. That is, if there are two code paths that load
up the same address and feed the value to a single use, then the use may not
use a lituse relocation.
104 Using as
!lituse_base!N
Used with any memory format instruction (e.g. ldl) to indicate that the literal
is used for an address load. The offset field of the instruction must be zero.
During relaxation, the code may be altered to use a gp-relative load.
!lituse_jsr!N
Used with a register branch format instruction (e.g. jsr) to indicate that the
literal is used for a call. During relaxation, the code may be altered to use a
direct branch (e.g. bsr).
!lituse_jsrdirect!N
Similar to lituse_jsr, but also that this call cannot be vectored through a
PLT entry. This is useful for functions with special calling conventions which
do not allow the normal call-clobbered registers to be clobbered.
!lituse_bytoff!N
Used with a byte mask instruction (e.g. extbl) to indicate that only the low 3
bits of the address are relevant. During relaxation, the code may be altered to
use an immediate instead of a register shift.
!lituse_addr!N
Used with any other instruction to indicate that the original address is in fact
used, and the original ldq instruction may not be altered or deleted. This is
useful in conjunction with lituse_jsr to test whether a weak symbol is defined.
ldq $27,foo($29) !literal!1
beq $27,is_undef !lituse_addr!1
jsr $26,($27),foo !lituse_jsr!1
!lituse_tlsgd!N
Used with a register branch format instruction to indicate that the literal is
the call to __tls_get_addr used to compute the address of the thread-local
storage variable whose descriptor was loaded with !tlsgd!N.
!lituse_tlsldm!N
Used with a register branch format instruction to indicate that the literal is the
call to __tls_get_addr used to compute the address of the base of the thread-
local storage block for the current module. The descriptor for the module must
have been loaded with !tlsldm!N.
!gpdisp!N
Used with ldah and lda to load the GP from the current address, a-la the ldgp
macro. The source register for the ldah instruction must contain the address
of the ldah instruction. There must be exactly one lda instruction paired with
the ldah instruction, though it may appear anywhere in the instruction stream.
The immediate operands must be zero.
bsr $26,foo
ldah $29,0($26) !gpdisp!1
lda $29,0($29) !gpdisp!1
!gprelhigh
Used with an ldah instruction to add the high 16 bits of a 32-bit displacement
from the GP.
Chapter 9: Machine Dependent Features 105
!gprellow
Used with any memory format instruction to add the low 16 bits of a 32-bit
displacement from the GP.
!gprel Used with any memory format instruction to add a 16-bit displacement from
the GP.
!samegp Used with any branch format instruction to skip the GP load at the target
address. The referenced symbol must have the same GP as the source object
file, and it must be declared to either not use $27 or perform a standard GP
load in the first two instructions via the .prologue directive.
!tlsgd
!tlsgd!N Used with an lda instruction to load the address of a TLS descriptor for a
symbol in the GOT.
The sequence number N is optional, and if present it used to pair the descriptor
load with both the literal loading the address of the __tls_get_addr function
and the lituse_tlsgd marking the call to that function.
For proper relaxation, both the tlsgd, literal and lituse relocations must
be in the same extended basic block. That is, the relocation with the lowest
address must be executed first at runtime.
!tlsldm
!tlsldm!N
Used with an lda instruction to load the address of a TLS descriptor for the
current module in the GOT.
Similar in other respects to tlsgd.
!gotdtprel
Used with an ldq instruction to load the offset of the TLS symbol within its
module’s thread-local storage block. Also known as the dynamic thread pointer
offset or dtp-relative offset.
!dtprelhi
!dtprello
!dtprel Like gprel relocations except they compute dtp-relative offsets.
!gottprel
Used with an ldq instruction to load the offset of the TLS symbol from the
thread pointer. Also known as the tp-relative offset.
!tprelhi
!tprello
!tprel Like gprel relocations except they compute tp-relative offsets.
The which argument should be either no, indicating that $27 is not used, or
std, indicating that the first two instructions of the function perform a GP
load.
One might use this directive instead of .prologue if you are also using dwarf2
CFI directives.
.gprel32 expression
Computes the difference between the address in expression and the GP for the
current object file, and stores it in 4 bytes. In addition to being smaller than a
full 8 byte address, this also does not require a dynamic relocation when used
in a shared library.
.t_floating expression
Stores expression as an ieee double precision value.
.s_floating expression
Stores expression as an ieee single precision value.
.f_floating expression
Stores expression as a VAX F format value.
.g_floating expression
Stores expression as a VAX G format value.
.d_floating expression
Stores expression as a VAX D format value.
.set feature
Enables or disables various assembler features. Using the positive name of the
feature enables while using ‘nofeature’ disables.
at Indicates that macro expansions may clobber the assembler tem-
porary ($at or $28) register. Some macros may not be expanded
without this and will generate an error message if noat is in effect.
When at is in effect, a warning will be generated if $at is used by
the programmer.
macro Enables the expansion of macro instructions. Note that variants of
real instructions, such as br label vs br $31,label are considered
alternate forms and not macros.
move
reorder
volatile These control whether and how the assembler may re-order instruc-
tions. Accepted for compatibility with the OSF/1 assembler, but
as does not do instruction scheduling, so these features are ignored.
The following directives are recognized for compatibility with the OSF/1 assembler but
are ignored.
.proc .aproc
.reguse .livereg
.option .aent
.ugen .eflag
.alias .noalias
108 Using as
9.2.6 Opcodes
For detailed information on the Alpha machine instruction set, see the Alpha Architecture
Handbook located at
ftp://ftp.digital.com/pub/Digital/info/semiconductor/literature/alphaahb.pdf
Chapter 9: Machine Dependent Features 109
9.3.2 Syntax
9.3.2.1 Special Characters
% A register name can optionally be prefixed by a ‘%’ character. So register %r0
is equivalent to r0 in the assembly code.
# The presence of a ‘#’ character within a line (but not at the start of a line)
indicates the start of a comment that extends to the end of the current line.
Note: if a line starts with a ‘#’ character then it can also be a logical line num-
ber directive (see Section 3.3 [Comments], page 31) or a preprocessor control
command (see Section 3.1 [Preprocessing], page 31).
@ Prefixing an operand with an ‘@’ specifies that the operand is a symbol and not
a register. This is how the assembler disambiguates the use of an ARC register
name as a symbol. So the instruction
mov r0, @r0
moves the address of symbol r0 into register r0.
‘ The ‘‘’ (backtick) character is used to separate statements on a single line.
- Used as a separator to obtain a sequence of commands from a C preprocessor
macro.
Chapter 9: Machine Dependent Features 111
bta_link_build
Build configuration for: BTA Registers. Auxiliary register address 0x63.
vecbase_ac_build
Build configuration for: Interrupts. Auxiliary register address 0x68.
rf_build Build configuration for: Core Registers. Auxiliary register address 0x6e.
dccm_build
DCCM RAM Configuration Register. Auxiliary register address 0xc1.
Additional auxiliary register names are defined according to the processor architecture
version and extensions selected by the options.
For example:
.extCondCode is_busy,0x14
add.is_busy r1,r2,r3
will only execute the add instruction if the condition code value is 0x14.
.extCoreRegister name, regnum, mode, shortcut
Specifies an extension core register named name as a synonym for the register
numbered regnum. The register number must be between 32 and 59. The third
argument, mode, indicates whether the register is readable and/or writable and
is one of:
r Read only;
w Write only;
r|w Read and write.
The final parameter, shortcut indicates whether the register has a short cut in
the pipeline. The valid values are:
can_shortcut
The register has a short cut in the pipeline;
cannot_shortcut
The register does not have a short cut in the pipeline.
For example:
.extCoreRegister mlo, 57, r , can_shortcut
defines a read only extension core register, mlo, which is register 57, and can
short cut the pipeline.
.extInstruction name, opcode, subopcode, suffixclass, syntaxclass
ARC allows the user to specify extension instructions. These extension in-
structions are not macros; the assembler creates encodings for use of these
instructions according to the specification by the user.
The first argument, name, gives the name of the instruction.
The second argument, opcode, is the opcode to be used (bits 31:27 in the
encoding).
The third argument, subopcode, is the sub-opcode to be used, but the correct
value also depends on the fifth argument, syntaxclass
The fourth argument, suffixclass, determines the kinds of suffixes to be allowed.
Valid values are:
SUFFIX_NONE
No suffixes are permitted;
SUFFIX_COND
Conditional suffixes are permitted;
SUFFIX_FLAG
Flag setting suffixes are permitted.
Chapter 9: Machine Dependent Features 115
SUFFIX_COND|SUFFIX_FLAG
Both conditional and flag setting suffices are permitted.
The fifth and final argument, syntaxclass, determines the syntax class for the
instruction. It can have the following values:
SYNTAX_2OP
Two Operand Instruction;
SYNTAX_3OP
Three Operand Instruction.
SYNTAX_1OP
One Operand Instruction.
SYNTAX_NOP
No Operand Instruction.
The syntax class may be followed by ‘|’ and one of the following modifiers.
OP1_MUST_BE_IMM
Modifies syntax class SYNTAX_3OP, specifying that the first operand
of a three-operand instruction must be an immediate (i.e., the result
is discarded). This is usually used to set the flags using specific
instructions and not retain results.
OP1_IMM_IMPLIED
Modifies syntax class SYNTAX_20P, specifying that there is an im-
plied immediate destination operand which does not appear in the
syntax.
For example, if the source code contains an instruction like:
inst r1,r2
the first argument is an implied immediate (that is, the result is
discarded). This is the same as though the source code were: inst
0,r1,r2.
For example, defining a 64-bit multiplier with immediate operands:
.extInstruction mp64, 0x07, 0x2d, SUFFIX_COND|SUFFIX_FLAG,
SYNTAX_3OP|OP1_MUST_BE_IMM
which specifies an extension instruction named mp64 with 3 operands. It sets
the flags and can be used with a condition code, for which the first operand is
an immediate, i.e. equivalent to discarding the result of the operation.
A two operands instruction variant would be:
.extInstruction mul64, 0x07, 0x2d, SUFFIX_COND,
SYNTAX_2OP|OP1_IMM_IMPLIED
which describes a two operand instruction with an implicit first immediate
operand. The result of this operation would be discarded.
.arc_attribute tag, value
Set the ARC object attribute tag to value.
116 Using as
9.3.6 Opcodes
For information on the ARC instruction set, see ARC Programmers Reference Manual,
available where you download the processor IP library.
Chapter 9: Machine Dependent Features 117
-march=architecture[+extension...]
This option specifies the target architecture. The assembler will issue an
error message if an attempt is made to assemble an instruction which will
not execute on the target architecture. The following architecture names are
recognized: armv1, armv2, armv2a, armv2s, armv3, armv3m, armv4, armv4xm,
armv4t, armv4txm, armv5, armv5t, armv5txm, armv5te, armv5texp, armv6,
armv6j, armv6k, armv6z, armv6kz, armv6-m, armv6s-m, armv7, armv7-a,
armv7ve, armv7-r, armv7-m, armv7e-m, armv8-a, armv8.1-a, armv8.2-a,
armv8.3-a, armv8-r, armv8.4-a, armv8.5-a, armv8-m.base, armv8-m.main,
armv8.1-m.main, armv8.6-a, iwmmxt, iwmmxt2 and xscale. If both -mcpu
and -march are specified, the assembler will use the setting for -mcpu.
The architecture option can be extended with a set extension options. These
extensions are context sensitive, i.e. the same extension may mean different
things when used with different architectures. When used together with a -mfpu
option, the union of both feature enablement is taken. See their availability and
meaning below:
For armv5te, armv5texp, armv5tej, armv6, armv6j, armv6k, armv6z, armv6kz,
armv6zk, armv6t2, armv6kt2 and armv6zt2:
+fp: Enables VFPv2 instructions. +nofp: Disables all FPU instrunctions.
For armv7:
+fp: Enables VFPv3 instructions with 16 double-word registers. +nofp: Dis-
ables all FPU instructions.
For armv7-a:
Chapter 9: Machine Dependent Features 119
+dsp: Enables DSP Extension. +fp: Enables single-precision only VFPv5 in-
structions with 16 double-word registers. +fp.dp: Enables VFPv5 instructions
with 16 double-word registers. +cdecp0 (CDE extensions for v8-m architec-
ture with coprocessor 0), +cdecp1 (CDE extensions for v8-m architecture with
coprocessor 1), +cdecp2 (CDE extensions for v8-m architecture with coproces-
sor 2), +cdecp3 (CDE extensions for v8-m architecture with coprocessor 3),
+cdecp4 (CDE extensions for v8-m architecture with coprocessor 4), +cdecp5
(CDE extensions for v8-m architecture with coprocessor 5), +cdecp6 (CDE ex-
tensions for v8-m architecture with coprocessor 6), +cdecp7 (CDE extensions
for v8-m architecture with coprocessor 7), +nofp: Disables all FPU instructions.
+nodsp: Disables DSP Extension.
For armv8.1-m.main:
+dsp: Enables DSP Extension. +fp: Enables single and half precision scalar
Floating Point Extensions for Armv8.1-M Mainline with 16 double-word reg-
isters. +fp.dp: Enables double precision scalar Floating Point Extensions for
Armv8.1-M Mainline, implies +fp. +mve: Enables integer only M-profile Vector
Extension for Armv8.1-M Mainline, implies +dsp. +mve.fp: Enables Floating
Point M-profile Vector Extension for Armv8.1-M Mainline, implies +mve and
+fp. +nofp: Disables all FPU instructions. +nodsp: Disables DSP Extension.
+nomve: Disables all M-profile Vector Extensions.
For armv8-a:
+crc: Enables CRC32 Extension. +simd: Enables VFP and NEON for Armv8-
A. +crypto: Enables Cryptography Extensions for Armv8-A, implies +simd.
+sb: Enables Speculation Barrier Instruction for Armv8-A. +predres: Enables
Execution and Data Prediction Restriction Instruction for Armv8-A. +nofp:
Disables all FPU, NEON and Cryptography Extensions. +nocrypto: Disables
Cryptography Extensions.
For armv8.1-a:
+simd: Enables VFP and NEON for Armv8.1-A. +crypto: Enables Cryptogra-
phy Extensions for Armv8-A, implies +simd. +sb: Enables Speculation Barrier
Instruction for Armv8-A. +predres: Enables Execution and Data Prediction
Restriction Instruction for Armv8-A. +nofp: Disables all FPU, NEON and
Cryptography Extensions. +nocrypto: Disables Cryptography Extensions.
For armv8.2-a and armv8.3-a:
+simd: Enables VFP and NEON for Armv8.1-A. +fp16: Enables FP16 Exten-
sion for Armv8.2-A, implies +simd. +fp16fml: Enables FP16 Floating Point
Multiplication Variant Extensions for Armv8.2-A, implies +fp16. +crypto:
Enables Cryptography Extensions for Armv8-A, implies +simd. +dotprod: En-
ables Dot Product Extensions for Armv8.2-A, implies +simd. +sb: Enables
Speculation Barrier Instruction for Armv8-A. +predres: Enables Execution
and Data Prediction Restriction Instruction for Armv8-A. +nofp: Disables all
FPU, NEON, Cryptography and Dot Product Extensions. +nocrypto: Disables
Cryptography Extensions.
For armv8.4-a:
Chapter 9: Machine Dependent Features 121
+simd: Enables VFP and NEON for Armv8.1-A and Dot Product Extensions
for Armv8.2-A. +fp16: Enables FP16 Floating Point and Floating Point Mul-
tiplication Variant Extensions for Armv8.2-A, implies +simd. +crypto: En-
ables Cryptography Extensions for Armv8-A, implies +simd. +sb: Enables
Speculation Barrier Instruction for Armv8-A. +predres: Enables Execution
and Data Prediction Restriction Instruction for Armv8-A. +nofp: Disables all
FPU, NEON, Cryptography and Dot Product Extensions. +nocryptp: Disables
Cryptography Extensions.
For armv8.5-a:
+simd: Enables VFP and NEON for Armv8.1-A and Dot Product Extensions
for Armv8.2-A. +fp16: Enables FP16 Floating Point and Floating Point Multi-
plication Variant Extensions for Armv8.2-A, implies +simd. +crypto: Enables
Cryptography Extensions for Armv8-A, implies +simd. +nofp: Disables all
FPU, NEON, Cryptography and Dot Product Extensions. +nocryptp: Dis-
ables Cryptography Extensions.
-mfpu=floating-point-format
This option specifies the floating point format to assemble for. The assembler
will issue an error message if an attempt is made to assemble an instruction
which will not execute on the target floating point unit. The following
format options are recognized: softfpa, fpe, fpe2, fpe3, fpa, fpa10,
fpa11, arm7500fe, softvfp, softvfp+vfp, vfp, vfp10, vfp10-r0, vfp9,
vfpxd, vfpv2, vfpv3, vfpv3-fp16, vfpv3-d16, vfpv3-d16-fp16, vfpv3xd,
vfpv3xd-d16, vfpv4, vfpv4-d16, fpv4-sp-d16, fpv5-sp-d16, fpv5-d16,
fp-armv8, arm1020t, arm1020e, arm1136jf-s, maverick, neon, neon-vfpv3,
neon-fp16, neon-vfpv4, neon-fp-armv8, crypto-neon-fp-armv8,
neon-fp-armv8.1 and crypto-neon-fp-armv8.1.
In addition to determining which instructions are assembled, this option also
affects the way in which the .double assembler directive behaves when assem-
bling little-endian code.
The default is dependent on the processor selected. For Architecture 5 or later,
the default is to assemble for VFP instructions; for earlier architectures the
default is to assemble for FPA instructions.
-mfp16-format=format
This option specifies the half-precision floating point format to use when assem-
bling floating point numbers emitted by the .float16 directive. The following
format options are recognized: ieee, alternative. If ieee is specified then the
IEEE 754-2008 half-precision floating point format is used, if alternative is
specified then the Arm alternative half-precision format is used. If this option
is set on the command line then the format is fixed and cannot be changed
with the float16_format directive. If this value is not set then the IEEE 754-
2008 format is used until the format is explicitly set with the float16_format
directive.
-mthumb This option specifies that the assembler should start assembling Thumb in-
structions; that is, it should behave as though the file starts with a .code 16
directive.
122 Using as
-mthumb-interwork
This option specifies that the output generated by the assembler should be
marked as supporting interworking. It also affects the behaviour of the ADR and
ADRL pseudo opcodes.
-mimplicit-it=never
-mimplicit-it=always
-mimplicit-it=arm
-mimplicit-it=thumb
The -mimplicit-it option controls the behavior of the assembler when con-
ditional instructions are not enclosed in IT blocks. There are four possible
behaviors. If never is specified, such constructs cause a warning in ARM code
and an error in Thumb-2 code. If always is specified, such constructs are ac-
cepted in both ARM and Thumb-2 code, where the IT instruction is added
implicitly. If arm is specified, such constructs are accepted in ARM code and
cause an error in Thumb-2 code. If thumb is specified, such constructs cause
a warning in ARM code and are accepted in Thumb-2 code. If you omit this
option, the behavior is equivalent to -mimplicit-it=arm.
-mapcs-26
-mapcs-32
These options specify that the output generated by the assembler should be
marked as supporting the indicated version of the Arm Procedure. Calling
Standard.
-matpcs This option specifies that the output generated by the assembler should be
marked as supporting the Arm/Thumb Procedure Calling Standard. If enabled
this option will cause the assembler to create an empty debugging section in
the object file called .arm.atpcs. Debuggers can use this to determine the ABI
being used by.
-mapcs-float
This indicates the floating point variant of the APCS should be used. In this
variant floating point arguments are passed in FP registers rather than integer
registers.
-mapcs-reentrant
This indicates that the reentrant variant of the APCS should be used. This
variant supports position independent code.
-mfloat-abi=abi
This option specifies that the output generated by the assembler should be
marked as using specified floating point ABI. The following values are recog-
nized: soft, softfp and hard.
-meabi=ver
This option specifies which EABI version the produced object files should con-
form to. The following values are recognized: gnu, 4 and 5.
-EB This option specifies that the output generated by the assembler should be
marked as being encoded for a big-endian processor.
Chapter 9: Machine Dependent Features 123
Note: If a program is being built for a system with big-endian data and little-
endian instructions then it should be assembled with the -EB option, (all of
it, code and data) and then linked with the --be8 option. This will reverse
the endianness of the instructions back to little-endian, but leave the data as
big-endian.
-EL This option specifies that the output generated by the assembler should be
marked as being encoded for a little-endian processor.
-k This option specifies that the output of the assembler should be marked as
position-independent code (PIC).
--fix-v4bx
Allow BX instructions in ARMv4 code. This is intended for use with the linker
option of the same name.
-mwarn-deprecated
-mno-warn-deprecated
Enable or disable warnings about using deprecated options or features. The
default is to warn.
-mwarn-syms
-mno-warn-syms
Enable or disable warnings about symbols that match the names of ARM in-
structions. The default is to warn.
9.4.2 Syntax
9.4.2.1 Instruction Set Syntax
Two slightly different syntaxes are support for ARM and THUMB instructions. The default,
divided, uses the old style where ARM and THUMB instructions had their own, separate
syntaxes. The new, unified syntax, which can be selected via the .syntax directive, and
has the following main features:
• Immediate operands do not require a # prefix.
• The IT instruction may appear, and if it does it is validated against subsequent condi-
tional affixes. In ARM mode it does not generate machine code, in THUMB mode it
does.
• For ARM instructions the conditional affixes always appear at the end of the instruc-
tion. For THUMB instructions conditional affixes can be used, but only inside the
scope of an IT instruction.
• All of the instructions new to the V6T2 architecture (and later) are available. (Only a
few such instructions can be written in the divided syntax).
• The .N and .W suffixes are recognized and honored.
• All instructions set the flags if and only if they have an s affix.
124 Using as
interprets the ‘@’ character as a "line comment" start, so ‘: align’ is used instead. For
example:
vld1.8 {q0}, [r0, :128]
x .dn d2.f32
y .dn d3.f32
z .dn d4.f32[1]
vmul x,y,z
This is equivalent to writing the following:
vmul.f32 d2,d3,d4[1]
Aliases created using dn or qn can be destroyed using unreq.
.eabi_attribute tag, value
Set the EABI object attribute tag to value.
The tag is either an attribute number, or one of the following: Tag_
CPU_raw_name, Tag_CPU_name, Tag_CPU_arch, Tag_CPU_arch_profile,
Tag_ARM_ISA_use, Tag_THUMB_ISA_use, Tag_FP_arch, Tag_WMMX_
arch, Tag_Advanced_SIMD_arch, Tag_MVE_arch, Tag_PCS_config,
Tag_ABI_PCS_R9_use, Tag_ABI_PCS_RW_data, Tag_ABI_PCS_RO_data,
Tag_ABI_PCS_GOT_use, Tag_ABI_PCS_wchar_t, Tag_ABI_FP_rounding, Tag_
ABI_FP_denormal, Tag_ABI_FP_exceptions, Tag_ABI_FP_user_exceptions,
Tag_ABI_FP_number_model, Tag_ABI_align_needed, Tag_ABI_align_
preserved, Tag_ABI_enum_size, Tag_ABI_HardFP_use, Tag_ABI_VFP_args,
Tag_ABI_WMMX_args, Tag_ABI_optimization_goals, Tag_ABI_FP_
optimization_goals, Tag_compatibility, Tag_CPU_unaligned_access,
Tag_FP_HP_extension, Tag_ABI_FP_16bit_format, Tag_MPextension_
use, Tag_DIV_use, Tag_nodefaults, Tag_also_compatible_with,
Tag_conformance, Tag_T2EE_use, Tag_Virtualization_use
The value is either a number, "string", or number, "string" depending on
the tag.
Note - the following legacy values are also accepted by tag: Tag_VFP_arch, Tag_
ABI_align8_needed, Tag_ABI_align8_preserved, Tag_VFP_HP_extension,
.even This directive aligns to an even-numbered address.
.extend expression [, expression]*
.ldouble expression [, expression]*
These directives write 12byte long double floating-point values to the output
section. These are not compatible with current ARM processors or ABIs.
.float16 value [,...,value_n]
Place the half precision floating point representation of one or more floating-
point values into the current section. The exact format of the encoding is
specified by .float16_format. If the format has not been explicitly set yet
(either via the .float16_format directive or the command line option) then
the IEEE 754-2008 format is used.
.float16_format format
Set the format to use when encoding float16 values emitted by the .float16
directive. Once the format has been set it cannot be changed. format should be
one of the following: ieee (encode in the IEEE 754-2008 half precision format)
or alternative (encode in the Arm alternative half precision format).
Chapter 9: Machine Dependent Features 127
.fnend Marks the end of a function with an unwind table entry. The unwind index
table entry is created when this directive is processed.
If no personality routine has been specified then standard personality routine
0 or 1 will be used, depending on the number of unwind opcodes required.
.fnstart Marks the start of a function with an unwind table entry.
.force_thumb
This directive forces the selection of Thumb instructions, even if the target
processor does not support those instructions
.fpu name Select the floating-point unit to assemble for. Valid values for name are the
same as for the -mfpu command-line option.
.handlerdata
Marks the end of the current function, and the start of the exception table entry
for that function. Anything between this directive and the .fnend directive will
be added to the exception table entry.
Must be preceded by a .personality or .personalityindex directive.
.inst opcode [ , ... ]
.inst.n opcode [ , ... ]
.inst.w opcode [ , ... ]
Generates the instruction corresponding to the numerical value opcode.
.inst.n and .inst.w allow the Thumb instruction size to be specified
explicitly, overriding the normal encoding rules.
.ldouble expression [, expression]*
See .extend.
.ltorg This directive causes the current contents of the literal pool to be dumped into
the current section (which is assumed to be the .text section) at the current
location (aligned to a word boundary). GAS maintains a separate literal pool
for each section and each sub-section. The .ltorg directive will only affect the
literal pool of the current section and sub-section. At the end of assembly all
remaining, un-empty literal pools will automatically be dumped.
Note - older versions of GAS would dump the current literal pool any time a
section change occurred. This is no longer done, since it prevents accurate
control of the placement of literal pools.
.movsp reg [, #offset]
Tell the unwinder that reg contains an offset from the current stack pointer. If
offset is not specified then it is assumed to be zero.
.object_arch name
Override the architecture recorded in the EABI object attribute section. Valid
values for name are the same as for the .arch directive. Typically this is useful
when code uses runtime detection of CPU features.
.packed expression [, expression]*
This directive writes 12-byte packed floating-point values to the output section.
These are not compatible with current ARM processors or ABIs.
128 Using as
.pad #count
Generate unwinder annotations for a stack adjustment of count bytes. A posi-
tive value indicates the function prologue allocated stack space by decrementing
the stack pointer.
.personality name
Sets the personality routine for the current function to name.
.personalityindex index
Sets the personality routine for the current function to the EABI standard
routine number index
.pool This is a synonym for .ltorg.
name .req register name
This creates an alias for register name called name. For example:
foo .req r0
.save reglist
Generate unwinder annotations to restore the registers in reglist. The format
of reglist is the same as the corresponding store-multiple instruction.
core registers
.save {r4, r5, r6, lr}
stmfd sp!, {r4, r5, r6, lr}
FPA registers
.save f4, 2
sfmfd f4, 2, [sp]!
VFP registers
.save {d8, d9, d10}
fstmdx sp!, {d8, d9, d10}
iWMMXt registers
.save {wr10, wr11}
wstrd wr11, [sp, #-8]!
wstrd wr10, [sp, #-8]!
or
.save wr11
wstrd wr11, [sp, #-8]!
.save wr10
wstrd wr10, [sp, #-8]!
9.4.5 Opcodes
as implements all the standard ARM opcodes. It also implements several pseudo opcodes,
including several synthetic load instructions.
NOP
nop
This pseudo op will always evaluate to a legal ARM instruction that does noth-
ing. Currently it will evaluate to MOV r0, r0.
LDR
ldr <register> , = <expression>
If expression evaluates to a numeric constant then a MOV or MVN instruction
will be used in place of the LDR instruction, if the constant can be generated
by either of these instructions. Otherwise the constant will be placed into the
nearest literal pool (if it not already there) and a PC relative LDR instruction
will be generated.
ADR
adr <register> <label>
This instruction will load the address of label into the indicated register. The
instruction will evaluate to a PC relative ADD or SUB instruction depending
upon where the label is located. If the label is out of range, or if it is not
defined in the same file (and section) as the ADR instruction, then an error will
be generated. This instruction will not make use of the literal pool.
If label is a thumb function symbol, and thumb interworking has been enabled
via the -mthumb-interwork option then the bottom bit of the value stored into
register will be set. This allows the following sequence to work as expected:
adr r0, thumb_function
blx r0
ADRL
adrl <register> <label>
This instruction will load the address of label into the indicated register. The
instruction will evaluate to one or two PC relative ADD or SUB instructions
depending upon where the label is located. If a second instruction is not needed
a NOP instruction will be generated in its place, so that this instruction is
always 8 bytes long.
If the label is out of range, or if it is not defined in the same file (and section)
as the ADRL instruction, then an error will be generated. This instruction will
not make use of the literal pool.
If label is a thumb function symbol, and thumb interworking has been enabled
via the -mthumb-interwork option then the bottom bit of the value stored into
register will be set.
Chapter 9: Machine Dependent Features 131
For information on the ARM or Thumb instruction sets, see ARM Software Development
Toolkit Reference Manual, Advanced RISC Machines Ltd.
9.4.7 Unwinding
The ABI for the ARM Architecture specifies a standard format for exception unwind infor-
mation. This information is used when an exception is thrown to determine where control
should be transferred. In particular, the unwind information is used to determine which
function called the function that threw the exception, and which function called that one,
and so forth. This information is also used to restore the values of callee-saved registers in
the function catching the exception.
If you are writing functions in assembly code, and those functions call other functions
that throw exceptions, you must use assembly pseudo ops to ensure that appropriate ex-
ception unwind information is generated. Otherwise, if one of the functions called by your
assembly code throws an exception, the run-time library will be unable to unwind the stack
through your assembly code and your program will not behave correctly.
To illustrate the use of these pseudo ops, we will examine the code that G++ generates
for the following C++ input:
void callee (int *);
int
caller ()
{
int i;
callee (&i);
return i;
}
This example does not show how to throw or catch an exception from assembly code.
That is a much more complex operation and should always be done in a high-level language,
such as C++, that directly supports exceptions.
The code generated by one particular version of G++ when compiling the example above
is:
_Z6callerv:
132 Using as
.fnstart
.LFB2:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, uses_anonymous_args = 0
stmfd sp!, {fp, lr}
.save {fp, lr}
.LCFI0:
.setfp fp, sp, #4
add fp, sp, #4
.LCFI1:
.pad #8
sub sp, sp, #8
.LCFI2:
sub r3, fp, #8
mov r0, r3
bl _Z6calleePi
ldr r3, [fp, #-8]
mov r0, r3
sub sp, fp, #4
ldmfd sp!, {fp, lr}
bx lr
.LFE2:
.fnend
Of course, the sequence of instructions varies based on the options you pass to GCC
and on the version of GCC in use. The exact instructions are not important since we are
focusing on the pseudo ops that are used to generate unwind information.
An important assumption made by the unwinder is that the stack frame does not change
during the body of the function. In particular, since we assume that the assembly code does
not itself throw an exception, the only point where an exception can be thrown is from a
call, such as the bl instruction above. At each call site, the same saved registers (including
lr, which indicates the return address) must be located in the same locations relative to
the frame pointer.
The .fnstart (see [.fnstart pseudo op], page 127) pseudo op appears immediately before
the first instruction of the function while the .fnend (see [.fnend pseudo op], page 126)
pseudo op appears immediately after the last instruction of the function. These pseudo ops
specify the range of the function.
Only the order of the other pseudos ops (e.g., .setfp or .pad) matters; their exact
locations are irrelevant. In the example above, the compiler emits the pseudo ops with
particular instructions. That makes it easier to understand the code, but it is not required
for correctness. It would work just as well to emit all of the pseudo ops other than .fnend
in the same order, but immediately after .fnstart.
The .save (see [.save pseudo op], page 128) pseudo op indicates registers that have been
saved to the stack so that they can be restored before the function returns. The argument to
the .save pseudo op is a list of registers to save. If a register is “callee-saved” (as specified
by the ABI) and is modified by the function you are writing, then your code must save
Chapter 9: Machine Dependent Features 133
the value before it is modified and restore the original value before the function returns.
If an exception is thrown, the run-time library restores the values of these registers from
their locations on the stack before returning control to the exception handler. (Of course, if
an exception is not thrown, the function that contains the .save pseudo op restores these
registers in the function epilogue, as is done with the ldmfd instruction above.)
You do not have to save callee-saved registers at the very beginning of the function and
you do not need to use the .save pseudo op immediately following the point at which the
registers are saved. However, if you modify a callee-saved register, you must save it on the
stack before modifying it and before calling any functions which might throw an exception.
And, you must use the .save pseudo op to indicate that you have done so.
The .pad (see [.pad], page 127) pseudo op indicates a modification of the stack pointer
that does not save any registers. The argument is the number of bytes (in decimal) that
are subtracted from the stack pointer. (On ARM CPUs, the stack grows downwards, so
subtracting from the stack pointer increases the size of the stack.)
The .setfp (see [.setfp pseudo op], page 128) pseudo op indicates the register that
contains the frame pointer. The first argument is the register that is set, which is typically
fp. The second argument indicates the register from which the frame pointer takes its value.
The third argument, if present, is the value (in decimal) added to the register specified by
the second argument to compute the value of the frame pointer. You should not modify
the frame pointer in the body of the function.
If you do not use a frame pointer, then you should not use the .setfp pseudo op. If you
do not use a frame pointer, then you should avoid modifying the stack pointer outside of
the function prologue. Otherwise, the run-time library will be unable to find saved registers
when it is unwinding the stack.
The pseudo ops described above are sufficient for writing assembly code that calls func-
tions which may throw exceptions. If you need to know more about the object-file format
used to represent unwind information, you may consult the Exception Handling ABI for
the ARM Architecture available from http://infocenter.arm.com.
134 Using as
9.5.2 Syntax
9.5.2.1 Special Characters
The presence of a ‘;’ anywhere on a line indicates the start of a comment that extends to
the end of that line.
If a ‘#’ appears as the first character of a line, the whole line is treated as a comment, but
in this case the line can also be a logical line number directive (see Section 3.3 [Comments],
page 31) or a preprocessor control command (see Section 3.1 [Preprocessing], page 31).
The ‘$’ character can be used instead of a newline to separate statements.
lo8
This modifier allows you to use bits 0 through 7 of an address expression as an
8 bit relocatable expression.
hi8
This modifier allows you to use bits 7 through 15 of an address expression as
an 8 bit relocatable expression. This is useful with, for example, the AVR ‘ldi’
instruction and ‘lo8’ modifier.
For example
ldi r26, lo8(sym+10)
ldi r27, hi8(sym+10)
Chapter 9: Machine Dependent Features 137
hh8
This modifier allows you to use bits 16 through 23 of an address expression as
an 8 bit relocatable expression. Also, can be useful for loading 32 bit constants.
hlo8
Synonym of ‘hh8’.
hhi8
This modifier allows you to use bits 24 through 31 of an expression as an 8
bit expression. This is useful with, for example, the AVR ‘ldi’ instruction and
‘lo8’, ‘hi8’, ‘hlo8’, ‘hhi8’, modifier.
For example
ldi r26, lo8(285774925)
ldi r27, hi8(285774925)
ldi r28, hlo8(285774925)
ldi r29, hhi8(285774925)
; r29,r28,r27,r26 = 285774925
pm_lo8
This modifier allows you to use bits 0 through 7 of an address expression as
an 8 bit relocatable expression. This modifier is useful for addressing data or
code from Flash/Program memory by two-byte words. The use of ‘pm_lo8’ is
similar to ‘lo8’.
pm_hi8
This modifier allows you to use bits 8 through 15 of an address expression as
an 8 bit relocatable expression. This modifier is useful for addressing data or
code from Flash/Program memory by two-byte words.
For example, when setting the AVR ‘Z’ register with the ‘ldi’ instruction for
subsequent use by the ‘ijmp’ instruction:
ldi r30, pm_lo8(sym)
ldi r31, pm_hi8(sym)
ijmp
pm_hh8
This modifier allows you to use bits 15 through 23 of an address expression as
an 8 bit relocatable expression. This modifier is useful for addressing data or
code from Flash/Program memory by two-byte words.
9.5.3 Opcodes
For detailed information on the AVR machine instruction set, see www.atmel.com/
products/AVR.
as implements all the standard AVR opcodes. The following table summarizes the AVR
opcodes, and their arguments.
Legend:
r any register
d ‘ldi’ register (r16-r31)
v ‘movw’ even register (r0, r2, ..., r28, r30)
a ‘fmul’ register (r16-r23)
w ‘adiw’ register (r24,r26,r28,r30)
138 Using as
1001010010001000 clc
1001010011011000 clh
1001010011111000 cli
1001010010101000 cln
1001010011001000 cls
1001010011101000 clt
1001010010111000 clv
1001010010011000 clz
1001010000001000 sec
1001010001011000 seh
1001010001111000 sei
1001010000101000 sen
1001010001001000 ses
1001010001101000 set
1001010000111000 sev
1001010000011000 sez
100101001SSS1000 bclr S
100101000SSS1000 bset S
1001010100001001 icall
1001010000001001 ijmp
1001010111001000 lpm ?
1001000ddddd010+ lpm r,z
1001010111011000 elpm ?
1001000ddddd011+ elpm r,z
0000000000000000 nop
1001010100001000 ret
1001010100011000 reti
1001010110001000 sleep
1001010110011000 break
1001010110101000 wdr
1001010111101000 spm
000111rdddddrrrr adc r,r
000011rdddddrrrr add r,r
001000rdddddrrrr and r,r
000101rdddddrrrr cp r,r
000001rdddddrrrr cpc r,r
000100rdddddrrrr cpse r,r
001001rdddddrrrr eor r,r
001011rdddddrrrr mov r,r
100111rdddddrrrr mul r,r
001010rdddddrrrr or r,r
000010rdddddrrrr sbc r,r
Chapter 9: Machine Dependent Features 139
1001010rrrrr0111 ror r
1001010rrrrr0010 swap r
00000001ddddrrrr movw v,v
00000010ddddrrrr muls d,d
000000110ddd0rrr mulsu a,a
000000110ddd1rrr fmul a,a
000000111ddd0rrr fmuls a,a
000000111ddd1rrr fmulsu a,a
1001001ddddd0000 sts i,r
1001000ddddd0000 lds r,i
10o0oo0dddddbooo ldd r,b
100!000dddddee-+ ld r,e
10o0oo1rrrrrbooo std b,r
100!001rrrrree-+ st e,r
1001010100011001 eicall
1001010000011001 eijmp
-mno-fdpic
-mnopic Disable -mfdpic.
9.6.2 Syntax
Special Characters
Assembler input is free format and may appear anywhere on the line. One
instruction may extend across multiple lines or more than one instruction may
appear on the same line. White space (space, tab, comments or newline) may
appear anywhere between tokens. A token must not have embedded spaces.
Tokens include numbers, register names, keywords, user identifiers, and also
some multicharacter special symbols like "+=", "/*" or "||".
Comments are introduced by the ‘#’ character and extend to the end of the
current line. If the ‘#’ appears as the first character of a line, the whole line is
treated as a comment, but in this case the line can also be a logical line num-
ber directive (see Section 3.3 [Comments], page 31) or a preprocessor control
command (see Section 3.1 [Preprocessing], page 31).
Instruction Delimiting
A semicolon must terminate every instruction. Sometimes a complete instruc-
tion will consist of more than one operation. There are two cases where this
occurs. The first is when two general operations are combined. Normally a
comma separates the different parts, as in
a0= r3.h * r2.l, a1 = r3.l * r2.h ;
The second case occurs when a general instruction is combined with one or two
memory references for joint issue. The latter portions are set off by a "||"
token.
a0 = r3.h * r2.l || r1 = [p3++] || r4 = [i2++];
Multiple instructions can occur on the same line. Each must be terminated by
a semicolon character.
Chapter 9: Machine Dependent Features 143
Register Names
The assembler treats register names and instruction keywords in a case insensi-
tive manner. User identifiers are case sensitive. Thus, R3.l, R3.L, r3.l and r3.L
are all equivalent input to the assembler.
Register names are reserved and may not be used as program identifiers.
Some operations (such as "Move Register") require a register pair. Register
pairs are always data registers and are denoted using a colon, eg., R3:2. The
larger number must be written firsts. Note that the hardware only supports
odd-even pairs, eg., R7:6, R5:4, R3:2, and R1:0.
Some instructions (such as –SP (Push Multiple)) require a group of adjacent
registers. Adjacent registers are denoted in the syntax by the range enclosed
in parentheses and separated by a colon, eg., (R7:3). Again, the larger number
appears first.
Portions of a particular register may be individually specified. This is written
with a dot (".") following the register name and then a letter denoting the
desired portion. For 32-bit registers, ".H" denotes the most significant ("High")
portion. ".L" denotes the least-significant portion. The subdivisions of the 40-
bit registers are described later.
Accumulators
The set of 40-bit registers A1 and A0 that normally contain data that is being
manipulated. Each accumulator can be accessed in four ways.
one 40-bit register
The register will be referred to as A1 or A0.
one 32-bit register
The registers are designated as A1.W or A0.W.
two 16-bit registers
The registers are designated as A1.H, A1.L, A0.H or A0.L.
one 8-bit register
The registers are designated as A1.X or A0.X for the bits that
extend beyond bit 31.
Data Registers
The set of 32-bit registers (R0, R1, R2, R3, R4, R5, R6 and R7) that normally
contain data for manipulation. These are abbreviated as D-register or Dreg.
Data registers can be accessed as 32-bit registers or as two independent 16-bit
registers. The least significant 16 bits of each register is called the "low" half
and is designated with ".L" following the register name. The most significant
16 bits are called the "high" half and is designated with ".H" following the
name.
R7.L, r2.h, r4.L, R0.H
Pointer Registers
The set of 32-bit registers (P0, P1, P2, P3, P4, P5, SP and FP) that normally
contain byte addresses of data structures. These are abbreviated as P-register
or Preg.
p2, p5, fp, sp
144 Using as
Stack Pointer SP
The stack pointer contains the 32-bit address of the last occupied byte location
in the stack. The stack grows by decrementing the stack pointer.
Frame Pointer FP
The frame pointer contains the 32-bit address of the previous frame pointer in
the stack. It is located at the top of a frame.
Loop Top LT0 and LT1. These registers contain the 32-bit address of the top of a zero
overhead loop.
Loop Count
LC0 and LC1. These registers contain the 32-bit counter of the zero overhead
loop executions.
Loop Bottom
LB0 and LB1. These registers contain the 32-bit address of the bottom of a
zero overhead loop.
Index Registers
The set of 32-bit registers (I0, I1, I2, I3) that normally contain byte addresses
of data structures. Abbreviated I-register or Ireg.
Modify Registers
The set of 32-bit registers (M0, M1, M2, M3) that normally contain offset values
that are added and subtracted to one of the index registers. Abbreviated as
Mreg.
Length Registers
The set of 32-bit registers (L0, L1, L2, L3) that normally contain the length
in bytes of the circular buffer. Abbreviated as Lreg. Clear the Lreg to disable
circular addressing for the corresponding Ireg.
Base Registers
The set of 32-bit registers (B0, B1, B2, B3) that normally contain the base
address in bytes of the circular buffer. Abbreviated as Breg.
Floating Point
The Blackfin family has no hardware floating point but the .float directive gen-
erates ieee floating point numbers for use with software floating point libraries.
Blackfin Opcodes
For detailed information on the Blackfin machine instruction set, see the Black-
fin Processor Instruction Set Reference.
9.6.3 Directives
The following directives are provided for compatibility with the VDSP assembler.
.byte2 Initializes a two byte data object.
This maps to the .short directive.
.byte4 Initializes a four byte data object.
This maps to the .int directive.
Chapter 9: Machine Dependent Features 145
9.7.2 Syntax
9.7.2.1 Special Characters
The presence of a ‘;’ on a line indicates the start of a comment that extends to the end of
the current line. If a ‘#’ appears as the first character of a line, the whole line is treated as
a comment.
Statements and assembly directives are separated by newlines.
9.7.4 Opcodes
In the instruction descriptions below the following field descriptors are used:
%d Destination general-purpose register whose role is to be destination of an oper-
ation.
%s Source general-purpose register whose role is to be the source of an operation.
disp16 16-bit signed PC-relative offset, measured in number of 64-bit words, minus
one.
disp32 32-bit signed PC-relative offset, measured in number of 64-bit words, minus
one.
offset16 Signed 16-bit immediate.
imm32 Signed 32-bit immediate.
imm64 Signed 64-bit immediate.
stxw [%d+offset16], %s
Generic 32-bit store.
stxh [%d+offset16], %s
Generic 16-bit store.
stxb [%d+offset16], %s
Generic 8-bit store.
Store from immediates instructions:
stddw [%d+offset16], imm32
Store immediate as 64-bit.
stdw [%d+offset16], imm32
Store immediate as 32-bit.
stdh [%d+offset16], imm32
Store immediate as 16-bit.
stdb [%d+offset16], imm32
Store immediate as 8-bit.
jslt %d,(%s|imm32),disp16
Jump if signed lesser.
jsle %d,(%s|imm32),disp16
Jump if signed lesser or equal.
A call instruction is provided in order to perform calls to other eBPF functions, or to
external kernel helpers:
call (disp32|imm32)
Jump and link to the offset disp32, or to the kernel helper function identified
by imm32.
Finally:
exit Terminate the eBPF program.
‘Displacement Operand: l’
24 bits.
For example:
1 movw $_myfun@c,r1
2 movd $_myfun@c,(r2,r1)
3 _myfun_ptr:
.long _myfun@c
loadd _myfun_ptr, (r1,r0)
jal (r1,r0)
This .long directive, the address of _myfunc, shifted right by 1 at link time.
This loads the address of _data1, into global offset table (ie GOT) and its off-
set value from GOT loads into register-pair r2-r1.
This loads the address of _myfun, shifted right by 1, into global off-
set table (ie GOT) and its offset value from GOT loads into register-pair r1-
r0.
section with insufficient alignment. This placement checking does not catch any case where
the multiply instruction is dangerously placed because it is located in a delay-slot. The
--mul-bug-abort command-line option turns off the checking.
9.9.3 Symbols
Some symbols are defined by the assembler. They’re intended to be used in conditional
assembly, for example:
.if ..asm.arch.cris.v32
code for CRIS v32
.elseif ..asm.arch.cris.common_v10_v32
code common to CRIS v32 and CRIS v10
.elseif ..asm.arch.cris.v10 | ..asm.arch.cris.any_v0_v10
code for v10
.else
.error "Code needs to be added here."
.endif
These symbols are defined in the assembler, reflecting command-line options, either when
specified or the default. They are always defined, to 0 or 1.
..asm.arch.cris.any_v0_v10
This symbol is non-zero when --march=v0_v10 is specified or the default.
..asm.arch.cris.common_v10_v32
Set according to the option --march=common_v10_v32.
..asm.arch.cris.v10
Reflects the option --march=v10.
..asm.arch.cris.v32
Corresponds to --march=v10.
Speaking of symbols, when a symbol is used in code, it can have a suffix modifying its
value for use in position-independent code. See Section 9.9.4.2 [CRIS-Pic], page 156.
9.9.4 Syntax
There are different aspects of the CRIS assembly syntax.
156 Using as
GOT
Attaching this suffix to a symbol in an instruction causes the symbol to be
entered into the global offset table. The value is a 32-bit index for that sym-
bol into the global offset table. The name of the corresponding relocation is
‘R_CRIS_32_GOT’. Example: move.d [$r0+extsym:GOT],$r9
GOT16
Same as for ‘GOT’, but the value is a 16-bit index into the global offset ta-
ble. The corresponding relocation is ‘R_CRIS_16_GOT’. Example: move.d
[$r0+asymbol:GOT16],$r10
PLT
This suffix is used for function symbols. It causes a procedure linkage table,
an array of code stubs, to be created at the time the shared object is created
or linked against, together with a global offset table entry. The value is a pc-
relative offset to the corresponding stub code in the procedure linkage table.
This arrangement causes the run-time symbol resolver to be called to look up
and set the value of the symbol the first time the function is called (at latest;
depending environment variables). It is only safe to leave the symbol unresolved
this way if all references are function calls. The name of the relocation is
‘R_CRIS_32_PLT_PCREL’. Example: add.d fnname:PLT,$pc
PLTG
Chapter 9: Machine Dependent Features 157
Like PLT, but the value is relative to the beginning of the global offset
table. The relocation is ‘R_CRIS_32_PLT_GOTREL’. Example: move.d
fnname:PLTG,$r3
GOTPLT
Similar to ‘PLT’, but the value of the symbol is a 32-bit index into the global
offset table. This is somewhat of a mix between the effect of the ‘GOT’ and
the ‘PLT’ suffix; the difference to ‘GOT’ is that there will be a procedure linkage
table entry created, and that the symbol is assumed to be a function entry
and will be resolved by the run-time resolver as with ‘PLT’. The relocation is
‘R_CRIS_32_GOTPLT’. Example: jsr [$r0+fnname:GOTPLT]
GOTPLT16
A variant of ‘GOTPLT’ giving a 16-bit value. Its relocation name is
‘R_CRIS_16_GOTPLT’. Example: jsr [$r0+fnname:GOTPLT16]
GOTOFF
This suffix must only be attached to a local symbol, but may be used in an
expression adding an offset. The value is the address of the symbol relative to
the start of the global offset table. The relocation name is ‘R_CRIS_32_GOTREL’.
Example: move.d [$r0+localsym:GOTOFF],r3
register_prefix
This directive makes a ‘$’ character prefix on all registers manda-
tory. It overrides a previous setting, including the corresponding
effect of the option --underscore.
leading_underscore
This is an assertion directive, emitting an error if the
--no-underscore option is in effect.
no_leading_underscore
This is the opposite of the .syntax leading_underscore directive
and emits an error if the option --underscore is in effect.
.arch ARGUMENT
This is an assertion directive, giving an error if the specified ARGUMENT is
not the same as the specified or default value for the --march=architecture
option (see [march-option], page 154).
Chapter 9: Machine Dependent Features 159
-mnolrw
-mno-lrw Enable/disable transformation of lrw instructions into a movih/ori pair.
-melrw
-mno-elrw
Enable/disable extended lrw instructions. This option is enabled by default for
CK800-series processors.
-mlaf
-mliterals-after-func
-mno-laf
-mno-literals-after-func
Enable/disable placement of literal pools after each function.
-mlabr
-mliterals-after-br
-mno-labr
-mnoliterals-after-br
Enable/disable placement of literal pools after unconditional branches. This
option is enabled by default.
-mistack
-mno-istack
Enable/disable interrupt stack instructions. This option is enabled by default
on CK801, CK802, and CK802 processors.
The following options explicitly enable certain optional instructions. These features are
also enabled implicitly by using -mcpu= to specify a processor that supports it.
-mhard-float
Enable hard float instructions.
-mmp Enable multiprocessor instructions.
-mcp Enable coprocessor instructions.
-mcache Enable cache prefetch instruction.
-msecurity
Enable C-SKY security instructions.
-mtrust Enable C-SKY trust instructions.
-mdsp Enable DSP instructions.
-medsp Enable enhanced DSP instructions.
-mvdsp Enable vector DSP instructions.
9.10.2 Syntax
as implements the standard C-SKY assembler syntax documented in the C-SKY V2 CPU
Applications Binary Interface Standards Manual.
Chapter 9: Machine Dependent Features 161
‘-O’ The D10V can often execute two sub-instructions in parallel. When this option
is used, as will attempt to optimize its output by detecting when instructions
can be executed in parallel.
‘--nowarnswap’
To optimize execution performance, as will sometimes swap the order of in-
structions. Normally this generates a warning. When this option is used, no
warning will be generated when instructions are swapped.
‘--gstabs-packing’
‘--no-gstabs-packing’
as packs adjacent short instructions into a single packed instruction.
‘--no-gstabs-packing’ turns instruction packing off if ‘--gstabs’ is specified
as well; ‘--gstabs-packing’ (the default) turns instruction packing on even
when ‘--gstabs’ is specified.
9.11.2 Syntax
The D10V syntax is based on the syntax in Mitsubishi’s D10V architecture manual. The
differences are detailed below.
9.11.2.2 Sub-Instructions
The D10V assembler takes as input a series of instructions, either one-per-line, or in the
special two-per-line format described in the next section. Some of these instructions will
be short-form or sub-instructions. These sub-instructions can be packed into a single in-
struction. The assembler will do this automatically. It will also detect when it should not
pack instructions. For example, when a label is defined, the next instruction will never be
packaged with the previous one. Whenever a branch and link instruction is called, it will
not be packaged with the next instruction so the return address will be valid. Nops are
automatically inserted when necessary.
162 Using as
If you do not want the assembler automatically making these decisions, you can control
the packaging and execution type (parallel or sequential) with the special execution symbols
described in the next section.
‘||’ Parallel
The D10V syntax allows either one instruction per line, one instruction per line with the
execution symbol, or two instructions per line. For example
ld2w r2,@r8+ ||
mac a0,r0,r7
Two-line format. Execute these in parallel.
ld2w r2,@r8+
mac a0,r0,r7
Two-line format. Execute these sequentially. Assembler will put them in the
proper containers.
Since ‘$’ has no special meaning, you may use it in symbol names.
Chapter 9: Machine Dependent Features 163
9.11.4 Opcodes
For detailed information on the D10V machine instruction set, see D10V Architecture: A
VLIW Microprocessor for Multimedia Applications (Mitsubishi Electric Corp.). as imple-
ments all the standard D10V opcodes. The only changes are those described in the section
on size modifiers
Chapter 9: Machine Dependent Features 165
9.12.2 Syntax
The D30V syntax is based on the syntax in Mitsubishi’s D30V architecture manual. The
differences are detailed below.
9.12.2.2 Sub-Instructions
The D30V assembler takes as input a series of instructions, either one-per-line, or in the
special two-per-line format described in the next section. Some of these instructions will
be short-form or sub-instructions. These sub-instructions can be packed into a single in-
struction. The assembler will do this automatically. It will also detect when it should not
pack instructions. For example, when a label is defined, the next instruction will never be
packaged with the previous one. Whenever a branch and link instruction is called, it will
not be packaged with the next instruction so the return address will be valid. Nops are
automatically inserted when necessary.
If you do not want the assembler automatically making these decisions, you can control
the packaging and execution type (parallel or sequential) with the special execution symbols
described in the next section.
If a ‘#’ appears as the first character of a line, the whole line is treated as a comment, but
in this case the line could also be a logical line number directive (see Section 3.3 [Comments],
page 31) or a preprocessor control command (see Section 3.1 [Preprocessing], page 31).
Sub-instructions may be executed in order, in reverse-order, or in parallel. Instructions
listed in the standard one-per-line format will be executed sequentially unless you use the
‘-O’ option.
To specify the executing order, use the following symbols:
‘->’ Sequential with instruction on the left first.
‘<-’ Sequential with instruction on the right first.
‘||’ Parallel
The D30V syntax allows either one instruction per line, one instruction per line with the
execution symbol, or two instructions per line. For example
abs r2,r3 -> abs r4,r5
Execute these sequentially. The instruction on the right is in the right container
and is executed second.
abs r2,r3 <- abs r4,r5
Execute these reverse-sequentially. The instruction on the right is in the right
container, and is executed first.
abs r2,r3 || abs r4,r5
Execute these in parallel.
ldw r2,@(r3,r4) ||
mulx r6,r8,r9
Two-line format. Execute these in parallel.
mulx a0,r8,r9
stw r2,@(r3,r4)
Two-line format. Execute these sequentially unless ‘-O’ option is used. If the
‘-O’ option is used, the assembler will determine if the instructions could be
done in parallel (the above two instructions can be done in parallel), and if so,
emit them as parallel instructions. The assembler will put them in the proper
containers. In the above example, the assembler will put the ‘stw’ instruction
in left container and the ‘mulx’ instruction in the right container.
stw r2,@(r3,r4) ->
mulx a0,r8,r9
Two-line format. Execute the ‘stw’ instruction followed by the ‘mulx’ instruc-
tion sequentially. The first instruction goes in the left container and the second
instruction goes into right container. The assembler will give an error if the
machine ordering constraints are violated.
stw r2,@(r3,r4) <-
mulx a0,r8,r9
Same as previous example, except that the ‘mulx’ instruction is executed before
the ‘stw’ instruction.
Since ‘$’ has no special meaning, you may use it in symbol names.
Chapter 9: Machine Dependent Features 167
9.12.4 Opcodes
For detailed information on the D30V machine instruction set, see D30V Architecture: A
VLIW Microprocessor for Multimedia Applications (Mitsubishi Electric Corp.). as imple-
ments all the standard D30V opcodes. The only changes are those described in the section
on size modifiers
Chapter 9: Machine Dependent Features 169
-h-tick-hex
Support H’00 style hex constants in addition to 0x00 style.
-mach=name
Sets the H8300 machine variant. The following machine names are recognised:
h8300h, h8300hn, h8300s, h8300sn, h8300sx and h8300sxn.
9.14.2 Syntax
9.14.2.1 Special Characters
‘;’ is the line comment character.
‘$’ can be used instead of a newline to separate statements. Therefore you may not use
‘$’ in symbol names on the H8/300.
rn Register direct
@rn Register indirect
@(d, rn)
@(d:16, rn)
@(d:24, rn)
Register indirect: 16-bit or 24-bit displacement d from register n. (24-bit dis-
placements are only meaningful on the H8/300H.)
@rn+ Register indirect with post-increment
@-rn Register indirect with pre-decrement
Chapter 9: Machine Dependent Features 171
@aa
@aa:8
@aa:16
@aa:24 Absolute address aa. (The address size ‘:24’ only makes sense on the H8/300H.)
#xx
#xx:8
#xx:16
#xx:32 Immediate data xx. You may specify the ‘:8’, ‘:16’, or ‘:32’ for clarity, if you
wish; but as neither requires this nor uses it—the data size required is taken
from context.
@@aa
@@aa:8 Memory indirect. You may specify the ‘:8’ for clarity, if you wish; but as
neither requires this nor uses it.
9.14.5 Opcodes
For detailed information on the H8/300 machine instruction set, see H8/300 Series Program-
ming Manual. For information specific to the H8/300H, see H8/300H Series Programming
Manual (Renesas).
as implements all the standard H8/300 opcodes. No additional pseudo-instructions are
needed on this family.
Four H8/300 instructions (add, cmp, mov, sub) are defined with variants using the suffixes
‘.b’, ‘.w’, and ‘.l’ to specify the size of a memory operand. as supports these suffixes, but
does not require them; since one of the operands is always a register, as can deduce the
correct size.
For example, since r0 refers to a 16-bit register,
mov r0,@foo
is equivalent to
mov.w r0,@foo
If you use the size suffixes, as issues a warning when the suffix and the register size do
not match.
Chapter 9: Machine Dependent Features 173
9.15.2 Options
as has no machine-dependent command-line options for the HPPA.
9.15.3 Syntax
The assembler syntax closely follows the HPPA instruction set reference manual; assembler
directives and general syntax closely follow the HPPA assembly language reference manual,
with a few noteworthy differences.
First, a colon may immediately follow a label definition. This is simply for compatibility
with how most assembly language programmers write code.
Some obscure expression parsing problems may affect hand written code which uses the
spop instructions, or code which makes significant use of the ! line separator.
as is much less forgiving about missing arguments and other similar oversights than the
HP assembler. as notifies you of missing arguments as syntax errors; this is regarded as a
feature, not a bug.
Finally, as allows you to use an external symbol without explicitly importing the symbol.
Warning: in the future this will be an error for HPPA targets.
Special characters for HPPA targets include:
‘;’ is the line comment character.
‘!’ can be used instead of a newline to separate statements.
Since ‘$’ has no special meaning, you may use it in symbol names.
.enter .locct
.leave .macro
.listoff
Beyond those implemented for compatibility, as supports one additional assembler di-
rective for the HPPA: .param. It conveys register argument locations for static functions.
Its syntax closely follows the .export directive.
These are the additional directives in as for the HPPA:
.block n
.blockz n Reserve n bytes of storage, and initialize them to zero.
.call Mark the beginning of a procedure call. Only the special case with no arguments
is allowed.
.callinfo [ param=value, ... ] [ flag, ... ]
Specify a number of parameters and flags that define the environment for a
procedure.
param may be any of ‘frame’ (frame size), ‘entry_gr’ (end of general regis-
ter range), ‘entry_fr’ (end of float register range), ‘entry_sr’ (end of space
register range).
The values for flag are ‘calls’ or ‘caller’ (proc has subroutines), ‘no_calls’
(proc does not call subroutines), ‘save_rp’ (preserve return pointer), ‘save_sp’
(proc preserves stack pointer), ‘no_unwind’ (do not unwind this proc),
‘hpux_int’ (proc is interrupt routine).
.code Assemble into the standard section called ‘$TEXT$’, subsection ‘$CODE$’.
.copyright "string"
In the SOM object format, insert string into the object code, marked as a
copyright string.
.copyright "string"
In the ELF object format, insert string into the object code, marked as a version
string.
.enter Not yet supported; the assembler rejects programs containing this directive.
.entry Mark the beginning of a procedure.
.exit Mark the end of a procedure.
.export name [ ,typ ] [ ,param=r ]
Make a procedure name available to callers. typ, if present, must be one
of ‘absolute’, ‘code’ (ELF only, not SOM), ‘data’, ‘entry’, ‘data’, ‘entry’,
‘millicode’, ‘plabel’, ‘pri_prog’, or ‘sec_prog’.
param, if present, provides either relocation information for the procedure ar-
guments and result, or a privilege level. param may be ‘argwn’ (where n ranges
from 0 to 3, and indicates one of four one-word arguments); ‘rtnval’ (the pro-
cedure’s result); or ‘priv_lev’ (privilege level). For arguments or the result, r
specifies how to relocate, and must be one of ‘no’ (not relocatable), ‘gr’ (argu-
ment is in general register), ‘fr’ (in floating point register), or ‘fu’ (upper half
of float register). For ‘priv_lev’, r is an integer.
Chapter 9: Machine Dependent Features 175
.half n Define a two-byte integer constant n; synonym for the portable as directive
.short.
.label name
Define name as a label for the current assembly location.
.leave Not yet supported; the assembler rejects programs containing this directive.
.origin lc
Advance location counter to lc. Synonym for the as portable directive .org.
.spnum secnam
Allocate four bytes of storage, and initialize them with the section number of
the section named secnam. (You can define the section number with the HPPA
.space directive.)
.string "str"
Copy the characters in the string str to the object file. See Section 3.6.1.1
[Strings], page 33, for information on escape sequences you can use in as strings.
Warning! The HPPA version of .string differs from the usual as definition:
it does not write a zero byte after copying str.
.stringz "str"
Like .string, but appends a zero byte after copying str to object file.
176 Using as
.version "str"
Write str as version identifier in object code.
9.15.6 Opcodes
For detailed information on the HPPA machine instruction set, see PA-RISC Architecture
and Instruction Set Reference Manual (HP 09740-90039).
178 Using as
9.16.1 Options
The i386 version of as has a few machine dependent options:
--32 | --x32 | --64
Select the word size, either 32 bits or 64 bits. ‘--32’ implies Intel i386 archi-
tecture, while ‘--x32’ and ‘--64’ imply AMD x86-64 architecture with 32-bit
or 64-bit word-size respectively.
These options are only available with the ELF object file format, and require
that the necessary BFD support has been included (on a 32-bit platform you
have to add –enable-64-bit-bfd to configure enable 64-bit usage and use x86-64
as target platform).
-n By default, x86 GAS replaces multiple nop instructions used for alignment
within code sections with multi-byte nop instructions such as leal
0(%esi,1),%esi. This switch disables the optimization if a single byte nop
(0x90) is explicitly specified as the fill byte for alignment.
--divide On SVR4-derived platforms, the character ‘/’ is treated as a comment character,
which means that it cannot be used in expressions. The ‘--divide’ option turns
‘/’ into a normal character. This does not disable ‘/’ at the beginning of a line
starting a comment, or affect using ‘#’ for starting a comment.
-march=CPU[+EXTENSION...]
This option specifies the target processor. The assembler will issue an error
message if an attempt is made to assemble an instruction which will not ex-
ecute on the target processor. The following processor names are recognized:
i8086, i186, i286, i386, i486, i586, i686, pentium, pentiumpro, pentiumii,
pentiumiii, pentium4, prescott, nocona, core, core2, corei7, l1om, k1om,
iamcu, k6, k6_2, athlon, opteron, k8, amdfam10, bdver1, bdver2, bdver3,
bdver4, znver1, znver2, znver3, btver1, btver2, generic32 and generic64.
In addition to the basic instruction set, the assembler can be told to
accept various extension mnemonics. For example, -march=i686+sse4+vmx
extends i686 with sse4 and vmx. The following extensions are currently
supported: 8087, 287, 387, 687, no87, no287, no387, no687, cmov, nocmov,
fxsr, nofxsr, mmx, nommx, sse, sse2, sse3, sse4a, ssse3, sse4.1,
sse4.2, sse4, nosse, nosse2, nosse3, nosse4a, nossse3, nosse4.1,
nosse4.2, nosse4, avx, avx2, noavx, noavx2, adx, rdseed, prfchw, smap,
mpx, sha, rdpid, ptwrite, cet, gfni, vaes, vpclmulqdq, prefetchwt1,
clflushopt, se1, clwb, movdiri, movdir64b, enqcmd, serialize, tsxldtrk,
kl, nokl, widekl, nowidekl, hreset, avx512f, avx512cd, avx512er,
avx512pf, avx512vl, avx512bw, avx512dq, avx512ifma, avx512vbmi,
avx512_4fmaps, avx512_4vnniw, avx512_vpopcntdq, avx512_vbmi2,
avx512_vnni, avx512_bitalg, avx512_vp2intersect, tdx, avx512_bf16,
avx_vnni, noavx512f, noavx512cd, noavx512er, noavx512pf, noavx512vl,
Chapter 9: Machine Dependent Features 179
WARNING: Don’t use this for production code - due to CPU errata the result-
ing code may not work on certain models.
-mevexlig=128
-mevexlig=256
-mevexlig=512
These options control how the assembler should encode length-ignored (LIG)
EVEX instructions. -mevexlig=128 will encode LIG EVEX instructions with
128bit vector length, which is the default. -mevexlig=256 and -mevexlig=512
will encode LIG EVEX instructions with 256bit and 512bit vector length, re-
spectively.
-mevexwig=0
-mevexwig=1
These options control how the assembler should encode w-ignored (WIG) EVEX
instructions. -mevexwig=0 will encode WIG EVEX instructions with evex.w =
0, which is the default. -mevexwig=1 will encode WIG EVEX instructions with
evex.w = 1.
-mmnemonic=att
-mmnemonic=intel
This option specifies instruction mnemonic for matching instructions. The
.att_mnemonic and .intel_mnemonic directives will take precedent.
-msyntax=att
-msyntax=intel
This option specifies instruction syntax when processing instructions. The
.att_syntax and .intel_syntax directives will take precedent.
-mnaked-reg
This option specifies that registers don’t require a ‘%’ prefix. The .att_syntax
and .intel_syntax directives will take precedent.
-madd-bnd-prefix
This option forces the assembler to add BND prefix to all branches, even if such
prefix was not explicitly specified in the source code.
-mno-shared
On ELF target, the assembler normally optimizes out non-PLT relocations
against defined non-weak global branch targets with default visibility. The
‘-mshared’ option tells the assembler to generate code which may go into a
shared library where all non-weak global branch targets with default visibility
can be preempted. The resulting code is slightly bigger. This option only affects
the handling of branch instructions.
-mbig-obj
On PE/COFF target this option forces the use of big object file format, which
allows more than 32768 sections.
-momit-lock-prefix=no
-momit-lock-prefix=yes
These options control how the assembler should encode lock prefix. This option
is intended as a workaround for processors, that fail on lock prefix. This option
Chapter 9: Machine Dependent Features 181
-mlfence-before-indirect-branch=none
-mlfence-before-indirect-branch=all
-mlfence-before-indirect-branch=register
-mlfence-before-indirect-branch=memory
These options control whether the assembler should generate lfence before in-
direct near branch instructions. -mlfence-before-indirect-branch=all will
generate lfence before indirect near branch via register and issue a warning
before indirect near branch via memory. It also implicitly sets -mlfence-
before-ret=shl when there’s no explicit -mlfence-before-ret=. -mlfence-
before-indirect-branch=register will generate lfence before indirect near
branch via register. -mlfence-before-indirect-branch=memory will issue a
warning before indirect near branch via memory. -mlfence-before-indirect-
branch=none will not generate lfence nor issue warning, which is the default.
Note that lfence won’t be generated before indirect near branch via register with
-mlfence-after-load=yes since lfence will be generated after loading branch
target register.
-mlfence-before-ret=none
-mlfence-before-ret=shl
-mlfence-before-ret=or
-mlfence-before-ret=yes
-mlfence-before-ret=not
These options control whether the assembler should generate lfence before
ret. -mlfence-before-ret=or will generate generate or instruction with
lfence. -mlfence-before-ret=shl/yes will generate shl instruction with
lfence. -mlfence-before-ret=not will generate not instruction with lfence.
-mlfence-before-ret=none will not generate lfence, which is the default.
-mx86-used-note=no
-mx86-used-note=yes
These options control whether the assembler should generate
GNU PROPERTY X86 ISA 1 USED and GNU PROPERTY X86 FEATURE 2 USED
GNU property notes. The default can be controlled by the --enable-x86-
used-note configure option.
-mevexrcig=rne
-mevexrcig=rd
-mevexrcig=ru
-mevexrcig=rz
These options control how the assembler should encode SAE-only EVEX in-
structions. -mevexrcig=rne will encode RC bits of EVEX instruction with 00,
which is the default. -mevexrcig=rd, -mevexrcig=ru and -mevexrcig=rz will
encode SAE-only EVEX instructions with 01, 10 and 11 RC bits, respectively.
-mamd64
-mintel64
This option specifies that the assembler should accept only AMD64 or Intel64
ISA in 64-bit mode. The default is to accept common, Intel64 only and AMD64
ISAs.
Chapter 9: Machine Dependent Features 183
9.16.4 i386-Mnemonics
9.16.4.1 Instruction Naming
Instruction mnemonics are suffixed with one character modifiers which specify the size of
operands. The letters ‘b’, ‘w’, ‘l’ and ‘q’ specify byte, word, long and quadruple word
operands. If no suffix is specified by an instruction then as tries to fill in the missing
suffix based on the destination register operand (the last one by convention). Thus, ‘mov
%ax, %bx’ is equivalent to ‘movw %ax, %bx’; also, ‘mov $1, %bx’ is equivalent to ‘movw $1,
bx’. Note that this is incompatible with the AT&T Unix assembler which assumes that a
missing mnemonic suffix implies long operand size. (This incompatibility does not affect
compiler output since compilers always explicitly specify the mnemonic suffix.)
When there is no sizing suffix and no (suitable) register operands to deduce the size of
memory operands, with a few exceptions and where long operand size is possible in the first
place, operand size will default to long in 32- and 64-bit modes. Similarly it will default to
short in 16-bit mode. Noteworthy exceptions are
• Instructions with an implicit on-stack operand as well as branches, which default to
quad in 64-bit mode.
• Sign- and zero-extending moves, which default to byte size source operands.
• Floating point insns with integer operands, which default to short (for perhaps historical
reasons).
• CRC32 with a 64-bit destination, which defaults to a quad source operand.
Different encoding options can be specified via pseudo prefixes:
• ‘{disp8}’ – prefer 8-bit displacement.
• ‘{disp32}’ – prefer 32-bit displacement.
• ‘{disp16}’ – prefer 16-bit displacement.
• ‘{load}’ – prefer load-form instruction.
• ‘{store}’ – prefer store-form instruction.
• ‘{vex}’ – encode with VEX prefix.
• ‘{vex3}’ – encode with 3-byte VEX prefix.
• ‘{evex}’ – encode with EVEX prefix.
• ‘{rex}’ – prefer REX prefix for integer and legacy vector instructions (x86-64 only).
Note that this differs from the ‘rex’ prefix which generates REX prefix unconditionally.
• ‘{nooptimize}’ – disable instruction size optimization.
Mnemonics of Intel VNNI instructions are encoded with the EVEX prefix by default.
The pseudo ‘{vex}’ prefix can be used to encode mnemonics of Intel VNNI instructions
with the VEX prefix.
The Intel-syntax conversion instructions
• ‘cbw’ — sign-extend byte in ‘%al’ to word in ‘%ax’,
• ‘cwde’ — sign-extend word in ‘%ax’ to long in ‘%eax’,
• ‘cwd’ — sign-extend word in ‘%ax’ to long in ‘%dx:%ax’,
• ‘cdq’ — sign-extend dword in ‘%eax’ to quad in ‘%edx:%eax’,
186 Using as
• the 6 section registers ‘%cs’ (code section), ‘%ds’ (data section), ‘%ss’ (stack section),
‘%es’, ‘%fs’, and ‘%gs’.
• the 5 processor control registers ‘%cr0’, ‘%cr2’, ‘%cr3’, ‘%cr4’, and ‘%cr8’.
• the 6 debug registers ‘%db0’, ‘%db1’, ‘%db2’, ‘%db3’, ‘%db6’, and ‘%db7’.
• the 2 test registers ‘%tr6’ and ‘%tr7’.
• the 8 floating point register stack ‘%st’ or equivalently ‘%st(0)’, ‘%st(1)’, ‘%st(2)’,
‘%st(3)’, ‘%st(4)’, ‘%st(5)’, ‘%st(6)’, and ‘%st(7)’. These registers are overloaded
by 8 MMX registers ‘%mm0’, ‘%mm1’, ‘%mm2’, ‘%mm3’, ‘%mm4’, ‘%mm5’, ‘%mm6’ and ‘%mm7’.
• the 8 128-bit SSE registers registers ‘%xmm0’, ‘%xmm1’, ‘%xmm2’, ‘%xmm3’, ‘%xmm4’, ‘%xmm5’,
‘%xmm6’ and ‘%xmm7’.
The AMD x86-64 architecture extends the register set by:
• enhancing the 8 32-bit registers to 64-bit: ‘%rax’ (the accumulator), ‘%rbx’, ‘%rcx’,
‘%rdx’, ‘%rdi’, ‘%rsi’, ‘%rbp’ (the frame pointer), ‘%rsp’ (the stack pointer)
• the 8 extended registers ‘%r8’–‘%r15’.
• the 8 32-bit low ends of the extended registers: ‘%r8d’–‘%r15d’.
• the 8 16-bit low ends of the extended registers: ‘%r8w’–‘%r15w’.
• the 8 8-bit low ends of the extended registers: ‘%r8b’–‘%r15b’.
• the 4 8-bit registers: ‘%sil’, ‘%dil’, ‘%bpl’, ‘%spl’.
• the 8 debug registers: ‘%db8’–‘%db15’.
• the 8 128-bit SSE registers: ‘%xmm8’–‘%xmm15’.
With the AVX extensions more registers were made available:
• the 16 256-bit SSE ‘%ymm0’–‘%ymm15’ (only the first 8 available in 32-bit mode). The
bottom 128 bits are overlaid with the ‘xmm0’–‘xmm15’ registers.
The AVX512 extensions added the following registers:
• the 32 512-bit registers ‘%zmm0’–‘%zmm31’ (only the first 8 available in 32-bit mode).
The bottom 128 bits are overlaid with the ‘%xmm0’–‘%xmm31’ registers and the first 256
bits are overlaid with the ‘%ymm0’–‘%ymm31’ registers.
• the 8 mask registers ‘%k0’–‘%k7’.
Instruction mnemonic suffixes specify the operand’s data type. Constructors build these
data types into memory.
• Floating point constructors are ‘.float’ or ‘.single’, ‘.double’, and ‘.tfloat’ for
32-, 64-, and 80-bit formats. These correspond to instruction mnemonic suffixes ‘s’,
‘l’, and ‘t’. ‘t’ stands for 80-bit (ten byte) real. The 80387 only supports this format
via the ‘fldt’ (load 80-bit real to stack top) and ‘fstpt’ (store 80-bit real and pop
stack) instructions.
• Integer constructors are ‘.word’, ‘.long’ or ‘.int’, and ‘.quad’ for the 16-, 32-, and
64-bit integer formats. The corresponding instruction mnemonic suffixes are ‘s’ (short),
‘l’ (long), and ‘q’ (quad). As with the 80-bit real format, the 64-bit ‘q’ format is only
present in the ‘fildq’ (load quad integer to stack top) and ‘fistpq’ (store quad integer
and pop stack) instructions.
Register to register operations should not use instruction mnemonic suffixes. ‘fstl %st,
%st(1)’ will give a warning, and be assembled as if you wrote ‘fst %st, %st(1)’, since all
register to register operations use 80-bit floating point operands. (Contrast this with ‘fstl
%st, mem’, which converts ‘%st’ from 80-bit to 64-bit floating point format, then stores the
result in the 4 byte location ‘mem’)
the long variety, and file-local jumps will be promoted as necessary. (see Section 9.16.8
[i386-Jumps], page 189) ‘nojumps’ leaves external conditional jumps as byte offset jumps,
and warns about file-local conditional jumps that as promotes. Unconditional jumps are
treated as for ‘jumps’.
For example
.arch i8086,nojumps
9.16.18 Notes
There is some trickery concerning the ‘mul’ and ‘imul’ instructions that deserves mention.
The 16-, 32-, 64- and 128-bit expanding multiplies (base opcode ‘0xf6’; extension 4 for ‘mul’
and 5 for ‘imul’) can be output only in the one operand form. Thus, ‘imul %ebx, %eax’
does not select the expanding multiply; the expanding multiply would clobber the ‘%edx’
register, and this would confuse gcc output. Use ‘imul %ebx’ to get the 64-bit product in
‘%edx:%eax’.
We have added a two operand form of ‘imul’ when the first operand is an immediate
mode expression and the second operand is a register. This is just a shorthand, so that,
multiplying ‘%eax’ by 69, for example, can be done with ‘imul $69, %eax’ rather than ‘imul
$69, %eax, %eax’.
194 Using as
9.17.2 Syntax
The assembler syntax closely follows the IA-64 Assembly Language Reference Guide.
9.17.2.4 Relocations
In addition to the standard IA-64 relocations, the following relocations are implemented by
as:
196 Using as
@slotcount(V)
Convert the address offset V into a slot count. This pseudo function is available
only on VMS. The expression V must be known at assembly time: it can’t
reference undefined symbols or symbols in different sections.
9.17.3 Opcodes
For detailed information on the IA-64 machine instruction set, see the IA-64 Assembly
Language Reference Guide available at
http://developer.intel.com/design/itanium/arch_spec.htm
Chapter 9: Machine Dependent Features 197
9.19.2 Syntax
9.19.2.1 Register Names
LM32 has 32 x 32-bit general purpose registers ‘r0’, ‘r1’, ... ‘r31’.
The following aliases are defined: ‘gp’ - ‘r26’, ‘fp’ - ‘r27’, ‘sp’ - ‘r28’, ‘ra’ - ‘r29’, ‘ea’
- ‘r30’, ‘ba’ - ‘r31’.
LM32 has the following Control and Status Registers (CSRs).
IE Interrupt enable.
IM Interrupt mask.
IP Interrupt pending.
ICC Instruction cache control.
DCC Data cache control.
CC Cycle counter.
CFG Configuration.
EBA Exception base address.
DC Debug control.
Chapter 9: Machine Dependent Features 199
9.19.3 Opcodes
For detailed information on the LM32 machine instruction set, see http://www.
latticesemi.com/products/intellectualproperty/ipcores/mico32/.
as implements all the standard LM32 opcodes.
Chapter 9: Machine Dependent Features 201
%dsp8
%dsp16
These modifiers override the assembler’s assumptions about how big a sym-
bol’s address is. Normally, when it sees an operand like ‘sym[a0]’ it assumes
‘sym’ may require the widest displacement field (16 bits for ‘-m16c’, 24 bits for
‘-m32c’). These modifiers tell it to assume the address will fit in an 8 or 16 bit
(respectively) unsigned displacement. Note that, of course, if it doesn’t actually
fit you will get linker errors. Example:
mov.w %dsp8(sym)[a0],r1
mov.b #0,%dsp8(sym)[a0]
%hi8
This modifier allows you to load bits 16 through 23 of a 24 bit address into an
8 bit register. This is useful with, for example, the M16C ‘smovf’ instruction,
which expects a 20 bit address in ‘r1h’ and ‘a0’. Example:
mov.b #%hi8(sym),r1h
mov.w #%lo16(sym),a0
smovf.b
%lo16
Likewise, this modifier allows you to load bits 0 through 15 of a 24 bit address
into a 16 bit register.
%hi16
This modifier allows you to load bits 16 through 31 of a 32 bit address into
a 16 bit register. While the M32C family only has 24 bits of address space,
202 Using as
it does support addresses in pairs of 16 bit registers (like ‘a1a0’ for the ‘lde’
instruction). This modifier is for loading the upper half in such cases. Example:
mov.w #%hi16(sym),a1
mov.w #%lo16(sym),a0
...
lde.w [a1a0],r1
-no-warn-explicit-parallel-conflicts
Instructs as not to produce warning messages when questionable parallel in-
structions are encountered.
-Wnp This is a shorter synonym for the -no-warn-explicit-parallel-conflicts option.
-ignore-parallel-conflicts
This option tells the assembler’s to stop checking parallel instructions for con-
straint violations. This ability is provided for hardware vendors testing chip
designs and should not be used under normal circumstances.
-no-ignore-parallel-conflicts
This option restores the assembler’s default behaviour of checking parallel in-
structions to detect constraint violations.
-Ip This is a shorter synonym for the -ignore-parallel-conflicts option.
-nIp This is a shorter synonym for the -no-ignore-parallel-conflicts option.
-warn-unmatched-high
This option tells the assembler to produce a warning message if a .high pseudo
op is encountered without a matching .low pseudo op. The presence of such
an unmatched pseudo op usually indicates a programming error.
-no-warn-unmatched-high
Disables a previously enabled -warn-unmatched-high option.
-Wuh This is a shorter synonym for the -warn-unmatched-high option.
-Wnuh This is a shorter synonym for the -no-warn-unmatched-high option.
high expression
The high directive computes the value of its expression and places the upper
16-bits of the result into the immediate-field of the instruction. For example:
seth r0, #high(0x12345678) ; compute r0 = 0x12340000
seth, r0, #high(fred) ; compute r0 = upper 16-bits of address of fred
shigh expression
The shigh directive is very similar to the high directive. It also computes
the value of its expression and places the upper 16-bits of the result into the
immediate-field of the instruction. The difference is that shigh also checks to
see if the lower 16-bits could be interpreted as a signed number, and if so it
assumes that a borrow will occur from the upper-16 bits. To compensate for
this the shigh directive pre-biases the upper 16 bit value by adding one to it.
For example:
Chapter 9: Machine Dependent Features 205
For example:
seth r0, #shigh(0x12345678) ; compute r0 = 0x12340000
seth r0, #shigh(0x00008000) ; compute r0 = 0x00010000
In the second example the lower 16-bits are 0x8000. If these are treated as a
signed value and sign extended to 32-bits then the value becomes 0xffff8000. If
this value is then added to 0x00010000 then the result is 0x00008000.
This behaviour is to allow for the different semantics of the or3 and add3
instructions. The or3 instruction treats its 16-bit immediate argument as un-
signed whereas the add3 treats its 16-bit immediate as a signed value. So for
example:
seth r0, #shigh(0x00008000)
add3 r0, r0, #low(0x00008000)
Produces the correct result in r0, whereas:
seth r0, #shigh(0x00008000)
or3 r0, r0, #low(0x00008000)
Stores 0xffff8000 into r0.
Note - the shigh directive does not know where in the assembly source code
the lower 16-bits of the value are going set, so it cannot check to make sure
that an or3 instruction is being used rather than an add3 instruction. It is up
to the programmer to make sure that correct directives are used.
.m32r The directive performs a similar thing as the -m32r command line option. It
tells the assembler to only accept M32R instructions from now on. An instruc-
tions from later M32R architectures are refused.
.m32rx The directive performs a similar thing as the -m32rx command line option. It
tells the assembler to start accepting the extra instructions in the M32RX ISA
as well as the ordinary M32R ISA.
.m32r2 The directive performs a similar thing as the -m32r2 command line option. It
tells the assembler to start accepting the extra instructions in the M32R2 ISA
as well as the ordinary M32R ISA.
.little The directive performs a similar thing as the -little command line option. It
tells the assembler to start producing little-endian code and data. This option
should be used with care as producing mixed-endian binary files is fraught with
danger.
.big The directive performs a similar thing as the -big command line option. It
tells the assembler to start producing big-endian code and data. This option
should be used with care as producing mixed-endian binary files is fraught with
danger.
struction in which the destination register of the left hand instruction is used
as an input register in the right hand instruction. For example in this code
fragment ‘mv r1, r2 || neg r3, r1’ register r1 is the destination of the move
instruction and the input to the neg instruction.
output of 2nd instruction is the same as an input to 1st instruction - is this
intentional ?
This message is only produced if warnings for explicit parallel conflicts have
been enabled. It indicates that the assembler has encountered a parallel in-
struction in which the destination register of the right hand instruction is used
as an input register in the left hand instruction. For example in this code
fragment ‘mv r1, r2 || neg r2, r3’ register r2 is the destination of the neg
instruction and the input to the move instruction.
instruction ‘...’ is for the M32RX only
This message is produced when the assembler encounters an instruction which
is only supported by the M32Rx processor, and the ‘-m32rx’ command-line flag
has not been specified to allow assembly of such instructions.
unknown instruction ‘...’
This message is produced when the assembler encounters an instruction which
it does not recognize.
only the NOP instruction can be issued in parallel on the m32r
This message is produced when the assembler encounters a parallel instruc-
tion which does not involve a NOP instruction and the ‘-m32rx’ command-line
flag has not been specified. Only the M32Rx processor is able to execute two
instructions in parallel.
instruction ‘...’ cannot be executed in parallel.
This message is produced when the assembler encounters a parallel instruction
which is made up of one or two instructions which cannot be executed in parallel.
Instructions share the same execution pipeline
This message is produced when the assembler encounters a parallel instruction
whose components both use the same execution pipeline.
Instructions write to the same destination register.
This message is produced when the assembler encounters a parallel instruction
where both components attempt to modify the same register. For example these
code fragments will produce this message: ‘mv r1, r2 || neg r1, r3’ ‘jl r0 ||
mv r14, r1’ ‘st r2, @-r1 || mv r1, r3’ ‘mv r1, r2 || ld r0, @r1+’ ‘cmp r1,
r2 || addx r3, r4’ (Both write to the condition bit)
Chapter 9: Machine Dependent Features 207
normal character. In this mode, you must either use C style comments, or start
comments with a ‘#’ character at the beginning of a line.
‘--base-size-default-16 --base-size-default-32’
If you use an addressing mode with a base register without specifying
the size, as will normally use the full 32 bit value. For example, the
addressing mode ‘%a0@(%d0)’ is equivalent to ‘%a0@(%d0:l)’. You may use
the ‘--base-size-default-16’ option to tell as to default to using the 16 bit
value. In this case, ‘%a0@(%d0)’ is equivalent to ‘%a0@(%d0:w)’. You may use
the ‘--base-size-default-32’ option to restore the default behaviour.
‘--disp-size-default-16 --disp-size-default-32’
If you use an addressing mode with a displacement, and the value of the dis-
placement is not known, as will normally assume that the value is 32 bits. For
example, if the symbol ‘disp’ has not been defined, as will assemble the ad-
dressing mode ‘%a0@(disp,%d0)’ as though ‘disp’ is a 32 bit value. You may
use the ‘--disp-size-default-16’ option to tell as to instead assume that
the displacement is 16 bits. In this case, as will assemble ‘%a0@(disp,%d0)’ as
though ‘disp’ is a 16 bit value. You may use the ‘--disp-size-default-32’
option to restore the default behaviour.
‘--pcrel’ Always keep branches PC-relative. In the M680x0 architecture all branches are
defined as PC-relative. However, on some processors they are limited to word
displacements maximum. When as needs a long branch that is not available,
it normally emits an absolute jump instead. This option disables this substitu-
tion. When this option is given and no long branches are available, only word
branches will be emitted. An error message will be generated if a word branch
cannot reach its target. This option has no effect on 68020 and other processors
that have long branches. see Section 9.22.6.1 [Branch Improvement], page 213.
‘-m68000’ as can assemble code for several different members of the Motorola 680x0 family.
The default depends upon how as was configured when it was built; normally,
the default is to assemble code for the 68020 microprocessor. The following
options may be used to change the default. These options control which in-
structions and addressing modes are permitted. The members of the 680x0
family are very similar. For detailed information about the differences, see the
Motorola manuals.
‘-m68000’
‘-m68ec000’
‘-m68hc000’
‘-m68hc001’
‘-m68008’
‘-m68302’
‘-m68306’
‘-m68307’
‘-m68322’
‘-m68356’ Assemble for the 68000. ‘-m68008’, ‘-m68302’, and so on are syn-
onyms for ‘-m68000’, since the chips are the same from the point
of view of the assembler.
Chapter 9: Machine Dependent Features 209
‘-m68020’
‘-m68ec020’
Assemble for the 68020. This is normally the default.
‘-m68030’
‘-m68ec030’
Assemble for the 68030.
‘-m68040’
‘-m68ec040’
Assemble for the 68040.
‘-m68060’
‘-m68ec060’
Assemble for the 68060.
‘-mcpu32’
‘-m68330’
‘-m68331’
‘-m68332’
‘-m68333’
‘-m68334’
‘-m68336’
‘-m68340’
‘-m68341’
‘-m68349’
‘-m68360’ Assemble for the CPU32 family of chips.
‘-m5200’
‘-m5202’
‘-m5204’
‘-m5206’
‘-m5206e’
‘-m521x’
‘-m5249’
‘-m528x’
‘-m5307’
‘-m5407’
‘-m547x’
‘-m548x’
‘-mcfv4’
‘-mcfv4e’ Assemble for the ColdFire family of chips.
‘-m68881’
‘-m68882’ Assemble 68881 floating point instructions. This is the default for
the 68020, 68030, and the CPU32. The 68040 and 68060 always
support floating point instructions.
210 Using as
‘-mno-68881’
Do not assemble 68881 floating point instructions. This is the de-
fault for 68000 and the 68010. The 68040 and 68060 always support
floating point instructions, even if this option is used.
‘-m68851’ Assemble 68851 MMU instructions. This is the default for the
68020, 68030, and 68060. The 68040 accepts a somewhat different
set of MMU instructions; ‘-m68851’ and ‘-m68040’ should not be
used together.
‘-mno-68851’
Do not assemble 68851 MMU instructions. This is the default for
the 68000, 68010, and the CPU32. The 68040 accepts a somewhat
different set of MMU instructions.
9.22.2 Syntax
This syntax for the Motorola 680x0 was developed at mit.
The 680x0 version of as uses instructions names and syntax compatible with the Sun
assembler. Intervening periods are ignored; for example, ‘movl’ is equivalent to ‘mov.l’.
In the following table apc stands for any of the address registers (‘%a0’ through ‘%a7’),
the program counter (‘%pc’), the zero-address relative to the program counter (‘%zpc’), a
suppressed address register (‘%za0’ through ‘%za7’), or it may be omitted entirely. The use
of size means one of ‘w’ or ‘l’, and it may be omitted, along with the leading colon, unless
a scale is also specified. The use of scale means one of ‘1’, ‘2’, ‘4’, or ‘8’, and it may always
be omitted along with the leading colon.
The following addressing modes are understood:
Immediate
‘#number’
Data Register
‘%d0’ through ‘%d7’
Address Register
‘%a0’ through ‘%a7’
‘%a7’ is also known as ‘%sp’, i.e., the Stack Pointer. %a6 is also known as ‘%fp’,
the Frame Pointer.
Address Register Indirect
‘%a0@’ through ‘%a7@’
Address Register Postincrement
‘%a0@+’ through ‘%a7@+’
Address Register Predecrement
‘%a0@-’ through ‘%a7@-’
Indirect Plus Offset
‘apc@(number)’
Index ‘apc@(number,register:size:scale)’
The number may be omitted.
Chapter 9: Machine Dependent Features 211
Postindex ‘apc@(number)@(onumber,register:size:scale)’
The onumber or the register, but not both, may be omitted.
Preindex ‘apc@(number,register:size:scale)@(onumber)’
The number may be omitted. Omitting the register produces the Postindex
addressing mode.
Absolute ‘symbol’, or ‘digits’, optionally followed by ‘:b’, ‘:w’, or ‘:l’.
Preindex ‘([number,apc,register.size*scale],onumber)’
The number, or the apc, or the register, or any two of them, may be omitted.
The onumber may be omitted. The register and the apc may appear in either
order. If both apc and register are address registers, and the size and scale are
omitted, then the first register is taken as the base register, and the second as
the index register.
.extend
.ldouble Extended precision (long double) floating point constants.
.even This directive is a special case of the .align directive; it aligns the output to
an even byte boundary.
.arch name
Select the target architecture and extension features. Valid values for name
are the same as for the -march command-line option. This directive cannot
be specified after any instructions have been assembled. If it is given multiple
times, or in conjunction with the -march option, all uses must be for the same
architecture and extension set.
.cpu name Select the target cpu. Valid values for name are the same as for the -mcpu
command-line option. This directive cannot be specified after any instructions
have been assembled. If it is given multiple times, or in conjunction with the
-mopt option, all uses must be for the same cpu.
Chapter 9: Machine Dependent Features 213
9.22.6 Opcodes
9.22.6.1 Branch Improvement
Certain pseudo opcodes are permitted for branch instructions. They expand to the shortest
branch instruction that reach the target. Generally these mnemonics are made by substi-
tuting ‘j’ for ‘b’ at the start of a Motorola mnemonic.
The following table summarizes the pseudo-operations. A * flags cases that are more
fully described after the table:
Displacement
+------------------------------------------------------------
| 68020 68000/10, not PC-relative OK
Pseudo-Op |BYTE WORD LONG ABSOLUTE LONG JUMP **
+------------------------------------------------------------
jbsr |bsrs bsrw bsrl jsr
jra |bras braw bral jmp
* jXX |bXXs bXXw bXXl bNXs;jmp
* dbXX | N/A dbXXw dbXX;bras;bral dbXX;bras;jmp
fjXX | N/A fbXXw fbXXl N/A
XX: condition
NX: negative of condition XX
jmp foo
oof:
--short-branches
The ‘--short-branches’ option turns off the translation of relative branches
into absolute branches when the branch offset is out of range. By default
as transforms the relative branch (‘bsr’, ‘bgt’, ‘bge’, ‘beq’, ‘bne’, ‘ble’, ‘blt’,
‘bhi’, ‘bcc’, ‘bls’, ‘bcs’, ‘bmi’, ‘bvs’, ‘bvs’, ‘bra’) into an absolute branch when
the offset is out of the -128 .. 127 range. In that case, the ‘bsr’ instruction is
translated into a ‘jsr’, the ‘bra’ instruction is translated into a ‘jmp’ and the
conditional branches instructions are inverted and followed by a ‘jmp’. This
option disables these translations and as will generate an error if a relative
branch is out of range. This option does not affect the optimization associated
to the ‘jbra’, ‘jbsr’ and ‘jbXX’ pseudo opcodes.
--force-long-branches
The ‘--force-long-branches’ option forces the translation of relative branches
into absolute branches. This option does not affect the optimization associated
to the ‘jbra’, ‘jbsr’ and ‘jbXX’ pseudo opcodes.
--print-insn-syntax
You can use the ‘--print-insn-syntax’ option to obtain the syntax description
of the instruction when an error is detected.
--print-opcodes
The ‘--print-opcodes’ option prints the list of all the instructions with their
syntax. The first item of each line represents the instruction name and the
rest of the line indicates the possible operands for that instruction. The list is
printed in alphabetical order. Once the list is printed as exits.
--generate-example
The ‘--generate-example’ option is similar to ‘--print-opcodes’ but it gen-
erates an example for each instruction instead.
9.23.2 Syntax
In the M68HC11 syntax, the instruction name comes first and it may be followed by one
or several operands (up to three). Operands are separated by comma (‘,’). In the normal
mode, as will complain if too many operands are specified for a given instruction. In the
MRI mode (turned on with ‘-M’ option), it will treat them as comments. Example:
inx
lda #23
bset 2,x #4
brclr *bot #8 foo
The presence of a ‘;’ character or a ‘!’ character anywhere on a line indicates the start
of a comment that extends to the end of that line.
A ‘*’ or a ‘#’ character at the start of a line also introduces a line comment, but these
characters do not work elsewhere on the line. If the first character of the line is a ‘#’
then as well as starting a comment, the line could also be logical line number directive
(see Section 3.3 [Comments], page 31) or a preprocessor control command (see Section 3.1
[Preprocessing], page 31).
The M68HC11 assembler does not currently support a line separator character.
Chapter 9: Machine Dependent Features 217
The following addressing modes are understood for 68HC11 and 68HC12:
Immediate
‘#number’
Address Register
‘number,X’, ‘number,Y’
The number may be omitted in which case 0 is assumed.
Direct Addressing mode
‘*symbol’, or ‘*digits’
Absolute ‘symbol’, or ‘digits’
The M68HC12 has other more complex addressing modes. All of them are supported
and they are represented below:
Constant Offset Indexed Addressing Mode
‘number,reg’
The number may be omitted in which case 0 is assumed. The register can
be either ‘X’, ‘Y’, ‘SP’ or ‘PC’. The assembler will use the smaller post-byte
definition according to the constant value (5-bit constant offset, 9-bit constant
offset or 16-bit constant offset). If the constant is not known by the assembler
it will use the 16-bit constant offset post-byte and the value will be resolved at
link time.
Offset Indexed Indirect
‘[number,reg]’
The register can be either ‘X’, ‘Y’, ‘SP’ or ‘PC’.
Auto Pre-Increment/Pre-Decrement/Post-Increment/Post-Decrement
‘number,-reg’ ‘number,+reg’ ‘number,reg-’ ‘number,reg+’
The number must be in the range ‘-8’..‘+8’ and must not be 0. The register
can be either ‘X’, ‘Y’, ‘SP’ or ‘PC’.
Accumulator Offset
‘acc,reg’
The accumulator register can be either ‘A’, ‘B’ or ‘D’. The register can be either
‘X’, ‘Y’, ‘SP’ or ‘PC’.
Accumulator D offset indexed-indirect
‘[D,reg]’
The register can be either ‘X’, ‘Y’, ‘SP’ or ‘PC’.
For example:
ldab 1024,sp
ldd [10,x]
orab 3,+x
stab -2,y-
ldx a,pc
sty [d,sp]
218 Using as
.interrupt symbol
This directive marks the symbol as an interrupt entry point. This information
is then used by the debugger to correctly unwind the frame across interrupts.
.xrefb symbol
This directive is defined for compatibility with the ‘Specification for
Motorola 8 and 16-Bit Assembly Language Input Standard’ and is ignored.
9.23.6 Opcodes
9.23.6.1 Branch Improvement
Certain pseudo opcodes are permitted for branch instructions. They expand to the shortest
branch instruction that reach the target. Generally these mnemonics are made by prepend-
ing ‘j’ to the start of Motorola mnemonic. These pseudo opcodes are not affected by the
‘--short-branches’ or ‘--force-long-branches’ options.
The following table summarizes the pseudo-operations.
Displacement Width
+-------------------------------------------------------------+
| Options |
| --short-branches --force-long-branches |
+--------------------------+----------------------------------+
Op |BYTE WORD | BYTE WORD |
+--------------------------+----------------------------------+
bsr | bsr <pc-rel> <error> | jsr <abs> |
bra | bra <pc-rel> <error> | jmp <abs> |
jbsr | bsr <pc-rel> jsr <abs> | bsr <pc-rel> jsr <abs> |
jbra | bra <pc-rel> jmp <abs> | bra <pc-rel> jmp <abs> |
bXX | bXX <pc-rel> <error> | bNX +3; jmp <abs> |
jbXX | bXX <pc-rel> bNX +3; | bXX <pc-rel> bNX +3; jmp <abs> |
| jmp <abs> | |
+--------------------------+----------------------------------+
XX: condition
NX: negative of condition XX
jbsr
jbra These are the simplest jump pseudo-operations; they always map to one partic-
ular machine instruction, depending on the displacement to the branch target.
jbXX Here, ‘jbXX’ stands for an entire family of pseudo-operations, where XX is a
conditional branch or condition-code test. The full list of pseudo-ops in this
family is:
jbcc jbeq jbge jbgt jbhi jbvs jbpl jblo
220 Using as
9.24.2 Syntax
9.24.2.1 Overview
In the S12Z syntax, the instruction name comes first and it may be followed by one, or by
several operands. In most cases the maximum number of operands is three. Operands are
separated by a comma (‘,’). A comma however does not act as a separator if it appears
within parentheses (‘()’) or within square brackets (‘[]’). as will complain if too many,
too few or inappropriate operands are specified for a given instruction.
Some instructions accept and (in certain situations require) a suffix indicating the size
of the operand. The suffix is separated from the instruction name by a period (‘.’) and
may be one of ‘b’, ‘w’, ‘p’ or ‘l’ indicating ‘byte’ (a single byte), ‘word’ (2 bytes), ‘pointer’
(3 bytes) or ‘long’ (4 bytes) respectively.
Example:
bset.b 0xA98, #5
mov.b #6, 0x2409
ld d0, #4
mov.l (d0, x), 0x2409
inc d0
cmp d0, #12
blt *-4
lea x, 0x2409
st y, (1, x)
The presence of a ‘;’ character anywhere on a line indicates the start of a comment that
extends to the end of that line.
A ‘*’ or a ‘#’ character at the start of a line also introduces a line comment, but these
characters do not work elsewhere on the line. If the first character of the line is a ‘#’
then as well as starting a comment, the line could also be logical line number directive
222 Using as
(see Section 3.3 [Comments], page 31) or a preprocessor control command (see Section 3.1
[Preprocessing], page 31).
The S12Z assembler does not currently support a line separator character.
Auto Pre-Increment/Pre-Decrement/Post-Increment/Post-Decrement
‘-reg’, ‘+reg’, ‘reg-’ or ‘reg+’
This addressing mode is typically used to access a value at an address, and
simultaneously to increment/decrement the register pointing to that address.
Thus reg may be any of the 24 bit registers ‘X’, ‘Y’, or ‘S’. Pre-increment
and post-decrement are not available for register ‘S’ (only post-increment and
pre-decrement are available).
Register Offset Direct
‘(data-reg,reg)’
Reg can be either ‘X’, ‘Y’, or ‘S’. Data-reg must be one of the data registers
‘D0’, ‘D1’ . . . ‘D7’. If any of the registers ‘D2’ . . . ‘D5’ are specified, then the
register value is treated as a signed value. Otherwise it is treated as unsigned.
Register Offset Indirect
‘[data-reg,reg]’
Reg can be either ‘X’ or ‘Y’. Data-reg must be one of the data registers ‘D0’,
‘D1’ . . . ‘D7’. If any of the registers ‘D2’ . . . ‘D5’ are specified, then the register
value is treated as a signed value. Otherwise it is treated as unsigned.
For example:
trap #197 ;; Immediate mode
bra *+49 ;; Relative mode
bra .L0 ;; ditto
jmp 0xFE0034 ;; Absolute direct mode
jmp [0xFD0012] ;; Absolute indirect mode
inc.b (4,x) ;; Constant offset indexed mode
jsr (45, d0) ;; ditto
dec.w [4,y] ;; Constant offset indexed indirect mode
clr.p (-s) ;; Pre-decrement mode
neg.l (d0, s) ;; Register offset direct mode
com.b [d1, x] ;; Register offset indirect mode
psh cch ;; Register mode
The destination operand of this instruction could either refer to the register ‘D1’, or it could
refer to the symbol named “d1”. If the latter is intended then as must be invoked with
‘-mreg-prefix=pfx’ and the code written as
st pfxd0, d1
where pfx is the chosen register prefix. For this reason, compiler back-ends should choose
a register prefix which cannot be confused with a symbol name.
Chapter 9: Machine Dependent Features 225
9.25.2 Syntax
9.25.2.1 Special Characters
‘!’ is the line comment character.
You can use ‘;’ instead of a newline to separate statements.
Since ‘$’ has no special meaning, you may use it in symbol names.
9.26.1 Directives
A number of assembler directives are available for MicroBlaze.
.data8 expression,...
This directive is an alias for .byte. Each expression is assembled into an eight-
bit value.
.data16 expression,...
This directive is an alias for .hword. Each expression is assembled into an
16-bit value.
.data32 expression,...
This directive is an alias for .word. Each expression is assembled into an 32-bit
value.
.ent name[,label]
This directive is an alias for .func denoting the start of function name at
(optional) label.
.end name[,label]
This directive is an alias for .endfunc denoting the end of function name.
.gpword label,...
This directive is an alias for .rva. The resolved address of label is stored in
the data section.
.weakext label
Declare that label is a weak external symbol.
.rodata Switch to .rodata section. Equivalent to .section .rodata
.sdata2 Switch to .sdata2 section. Equivalent to .section .sdata2
.sdata Switch to .sdata section. Equivalent to .section .sdata
.bss Switch to .bss section. Equivalent to .section .bss
.sbss Switch to .sbss section. Equivalent to .section .sbss
-mgp32
-mfp32 Some macros have different expansions for 32-bit and 64-bit registers. 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 general-purpose registers and ‘-mfp32’ controls the size of
floating-point registers.
The .set gp=32 and .set fp=32 directives allow the size of registers to
be changed for parts of an object. The default value is restored by .set
gp=default and .set fp=default.
On some MIPS variants there is a 32-bit mode flag; when this flag is set, 64-
bit instructions generate a trap. Also, some 32-bit OSes only save the 32-bit
registers on a context switch, so it is essential never to use the 64-bit registers.
-mgp64
-mfp64 Assume that 64-bit registers are available. This is provided in the interests of
symmetry with ‘-mgp32’ and ‘-mfp32’.
The .set gp=64 and .set fp=64 directives allow the size of registers to
be changed for parts of an object. The default value is restored by .set
gp=default and .set fp=default.
-mfpxx Make no assumptions about whether 32-bit or 64-bit floating-point registers are
available. This is provided to support having modules compatible with either
‘-mfp32’ or ‘-mfp64’. This option can only be used with MIPS II and above.
The .set fp=xx directive allows a part of an object to be marked as not making
assumptions about 32-bit or 64-bit FP registers. The default value is restored
by .set fp=default.
-modd-spreg
-mno-odd-spreg
Enable use of floating-point operations on odd-numbered single-precision regis-
ters when supported by the ISA. ‘-mfpxx’ implies ‘-mno-odd-spreg’, otherwise
the default is ‘-modd-spreg’
-mips16
-no-mips16
Generate code for the MIPS 16 processor. This is equivalent to putting .module
mips16 at the start of the assembly file. ‘-no-mips16’ turns off this option.
-mmips16e2
-mno-mips16e2
Enable the use of MIPS16e2 instructions in MIPS16 mode. This is equivalent to
putting .module mips16e2 at the start of the assembly file. ‘-mno-mips16e2’
turns off this option.
Chapter 9: Machine Dependent Features 229
-mmicromips
-mno-micromips
Generate code for the microMIPS processor. This is equivalent to putting
.module micromips at the start of the assembly file. ‘-mno-micromips’ turns
off this option. This is equivalent to putting .module nomicromips at the start
of the assembly file.
-msmartmips
-mno-smartmips
Enables the SmartMIPS extensions to the MIPS32 instruction set, which pro-
vides a number of new instructions which target smartcard and cryptographic
applications. This is equivalent to putting .module smartmips at the start of
the assembly file. ‘-mno-smartmips’ 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.
-mdsp
-mno-dsp Generate code for the DSP Release 1 Application Specific Extension. This tells
the assembler to accept DSP Release 1 instructions. ‘-mno-dsp’ turns off this
option.
-mdspr2
-mno-dspr2
Generate code for the DSP Release 2 Application Specific Extension. This
option implies ‘-mdsp’. This tells the assembler to accept DSP Release 2 in-
structions. ‘-mno-dspr2’ turns off this option.
-mdspr3
-mno-dspr3
Generate code for the DSP Release 3 Application Specific Extension. This
option implies ‘-mdsp’ and ‘-mdspr2’. This tells the assembler to accept DSP
Release 3 instructions. ‘-mno-dspr3’ turns off this option.
-mmt
-mno-mt Generate code for the MT Application Specific Extension. This tells the as-
sembler to accept MT instructions. ‘-mno-mt’ turns off this option.
-mmcu
-mno-mcu Generate code for the MCU Application Specific Extension. This tells the
assembler to accept MCU instructions. ‘-mno-mcu’ turns off this option.
-mmsa
-mno-msa Generate code for the MIPS SIMD Architecture Extension. This tells the as-
sembler to accept MSA instructions. ‘-mno-msa’ turns off this option.
230 Using as
-mxpa
-mno-xpa Generate code for the MIPS eXtended Physical Address (XPA) Extension. This
tells the assembler to accept XPA instructions. ‘-mno-xpa’ turns off this option.
-mvirt
-mno-virt
Generate code for the Virtualization Application Specific Extension. This tells
the assembler to accept Virtualization instructions. ‘-mno-virt’ turns off this
option.
-mcrc
-mno-crc Generate code for the cyclic redundancy check (CRC) Application Specific Ex-
tension. This tells the assembler to accept CRC instructions. ‘-mno-crc’ turns
off this option.
-mginv
-mno-ginv
Generate code for the Global INValidate (GINV) Application Specific Exten-
sion. This tells the assembler to accept GINV instructions. ‘-mno-ginv’ turns
off this option.
-mloongson-mmi
-mno-loongson-mmi
Generate code for the Loongson MultiMedia extensions Instructions (MMI)
Application Specific Extension. This tells the assembler to accept MMI in-
structions. ‘-mno-loongson-mmi’ turns off this option.
-mloongson-cam
-mno-loongson-cam
Generate code for the Loongson Content Address Memory (CAM) Applica-
tion Specific Extension. This tells the assembler to accept CAM instructions.
‘-mno-loongson-cam’ turns off this option.
-mloongson-ext
-mno-loongson-ext
Generate code for the Loongson EXTensions (EXT) instructions Application
Specific Extension. This tells the assembler to accept EXT instructions.
‘-mno-loongson-ext’ turns off this option.
-mloongson-ext2
-mno-loongson-ext2
Generate code for the Loongson EXTensions R2 (EXT2) instructions Applica-
tion Specific Extension. This tells the assembler to accept EXT2 instructions.
‘-mno-loongson-ext2’ turns off this option.
-minsn32
-mno-insn32
Only use 32-bit instruction encodings when generating code for the microMIPS
processor. This option inhibits the use of any 16-bit instructions. This is equiv-
alent to putting .set insn32 at the start of the assembly file. ‘-mno-insn32’
turns off this option. This is equivalent to putting .set noinsn32 at the start of
Chapter 9: Machine Dependent Features 231
-mfix-r5900
-mno-fix-r5900
Do not attempt to schedule the preceding instruction into the delay slot of a
branch instruction placed at the end of a short loop of six instructions or fewer
and always schedule a nop instruction there instead. The short loop bug under
certain conditions causes loops to execute only once or twice, due to a hardware
bug in the R5900 chip.
-m4010
-no-m4010
Generate code for the LSI R4010 chip. This tells the assembler to accept the
R4010-specific instructions (‘addciu’, ‘ffc’, etc.), and to not schedule ‘nop’
instructions around accesses to the ‘HI’ and ‘LO’ registers. ‘-no-m4010’ turns
off this option.
-m4650
-no-m4650
Generate code for the MIPS R4650 chip. This tells the assembler to accept
the ‘mad’ and ‘madu’ instruction, and to not schedule ‘nop’ instructions around
accesses to the ‘HI’ and ‘LO’ registers. ‘-no-m4650’ turns off this option.
-m3900
-no-m3900
-m4100
-no-m4100
For each option ‘-mnnnn’, generate code for the MIPS Rnnnn chip. This tells
the assembler to accept instructions specific to that chip, and to schedule for
that chip’s hazards.
-march=cpu
Generate code for a particular MIPS CPU. It is exactly equivalent to ‘-mcpu’,
except that there are more value of cpu understood. Valid cpu value are:
2000, 3000, 3900, 4000, 4010, 4100, 4111, vr4120, vr4130, vr4181,
4300, 4400, 4600, 4650, 5000, rm5200, rm5230, rm5231, rm5261,
rm5721, vr5400, vr5500, 6000, rm7000, 8000, rm9000, 10000, 12000,
14000, 16000, 4kc, 4km, 4kp, 4ksc, 4kec, 4kem, 4kep, 4ksd, m4k,
m4kp, m14k, m14kc, m14ke, m14kec, 24kc, 24kf2 1, 24kf, 24kf1 1,
24kec, 24kef2 1, 24kef, 24kef1 1, 34kc, 34kf2 1, 34kf, 34kf1 1, 34kn,
74kc, 74kf2 1, 74kf, 74kf1 1, 74kf3 2, 1004kc, 1004kf2 1, 1004kf,
1004kf1 1, interaptiv, interaptiv-mr2, m5100, m5101, p5600, 5kc,
5kf, 20kc, 25kf, sb1, sb1a, i6400, i6500, p6600, loongson2e, loong-
son2f, gs464, gs464e, gs264e, octeon, octeon+, octeon2, octeon3,
xlr, xlp
For compatibility reasons, ‘nx’ and ‘bfx’ are accepted as synonyms for ‘nf1_1’.
These values are deprecated.
-mtune=cpu
Schedule and tune for a particular MIPS CPU. Valid cpu values are identical
to ‘-march=cpu’.
Chapter 9: Machine Dependent Features 233
-mabi=abi
Record which ABI the source code uses. The recognized arguments are: ‘32’,
‘n32’, ‘o64’, ‘64’ and ‘eabi’.
-msym32
-mno-sym32
Equivalent to adding .set sym32 or .set nosym32 to the beginning of the as-
sembler input. See Section 9.27.3 [MIPS Symbol Sizes], page 236.
-nocpp This option is ignored. It is accepted for command-line compatibility with
other assemblers, which use it to turn off C style preprocessing. With gnu as,
there is no need for ‘-nocpp’, because the gnu assembler itself never runs the
C preprocessor.
-msoft-float
-mhard-float
Disable or enable floating-point instructions. Note that by default floating-
point instructions are always allowed even with CPU targets that don’t have
support for these instructions.
-msingle-float
-mdouble-float
Disable or enable double-precision floating-point operations. Note that by de-
fault double-precision floating-point operations are always allowed even with
CPU targets that don’t have support for these operations.
--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.
This feature is useful if the processor support the FR bit in its status register,
and this bit is known (by the programmer) to be set. This bit prevents the
aliasing of the double width register by the single width registers.
By default --construct-floats is selected, allowing construction of these
floating point constants.
--relax-branch
--no-relax-branch
The ‘--relax-branch’ option enables the relaxation of out-of-range branches.
Any branches whose target cannot be reached directly are converted to a small
instruction sequence including an inverse-condition branch to the physically
next instruction, and a jump to the original target is inserted between the two
instructions. In PIC code the jump will involve further instructions for address
calculation.
The BC1ANY2F, BC1ANY2T, BC1ANY4F, BC1ANY4T, BPOSGE32 and BPOSGE64 in-
structions are excluded from relaxation, because they have no complementing
counterparts. They could be relaxed with the use of a longer sequence involv-
ing another branch, however this has not been implemented and if their target
turns out of reach, they produce an error even if branch relaxation is enabled.
234 Using as
-mpdr
-mno-pdr Control generation of .pdr sections. Off by default on IRIX, on elsewhere.
-mshared
-mno-shared
When generating code using the Unix calling conventions (selected by ‘-KPIC’ or
‘-mcall_shared’), gas will normally generate code which can go into a shared
library. The ‘-mno-shared’ option tells gas to generate code which uses the
calling convention, but can not go into a shared library. The resulting code is
slightly more efficient. This option only affects the handling of the ‘.cpload’
and ‘.cpsetup’ pseudo-ops.
When no -G option is given, the default limit is 8 bytes. The option -G 0 prevents any
data from being automatically classified as small.
It is also possible to mark specific objects as small by putting them in the special sections
.sdata and .sbss, which are “small” counterparts of .data and .bss respectively. The
toolchain will treat such data as small regardless of the -G setting.
On startup, systems that support a small data area are expected to initialize register
$28, also known as $gp, in such a way that small data can be accessed using a 16-bit offset
from that register. For example, when ‘addr’ is small data, the ‘dla $4,addr’ instruction
above is equivalent to:
daddiu $4,$28,%gp_rel(addr)
Small data is not supported for SVR4-style PIC.
16-bit instructions from that point on in the assembly. The .set noinsn32 directive allows
16-bit instructions to be accepted.
Traditional MIPS assemblers do not support this directive.
directive has been seen then a warning will be raised if it does not match an inferred
setting.
The floating-point ABI is inferred as follows. If ‘-msoft-float’ has been used the
module will be marked as soft-float. If ‘-msingle-float’ has been used then the module
will be marked as single-precision. The remaining ABIs are then selected based on the
FP register width. Double-precision is selected if the width of GP and FP registers match
and the special double-precision variants for 32-bit ABIs are then selected depending on
‘-mfpxx’, ‘-mfp64’ and ‘-mno-odd-spreg’.
The directive .set xpa makes the assembler accept instructions from the XPA Extension
from that point on in the assembly. The .set noxpa directive prevents XPA instructions
from being accepted.
The directive .set mips16e2 makes the assembler accept instructions from the
MIPS16e2 Application Specific Extension from that point on in the assembly, whenever
in MIPS16 mode. The .set nomips16e2 directive prevents MIPS16e2 instructions from
being accepted, in MIPS16 mode. Neither directive affects the state of MIPS16 mode
being active itself which has separate controls.
The directive .set crc makes the assembler accept instructions from the CRC Extension
from that point on in the assembly. The .set nocrc directive prevents CRC instructions
from being accepted.
The directive .set ginv makes the assembler accept instructions from the GINV Ex-
tension from that point on in the assembly. The .set noginv directive prevents GINV
instructions from being accepted.
The directive .set loongson-mmi makes the assembler accept instructions from the
MMI Extension from that point on in the assembly. The .set noloongson-mmi directive
prevents MMI instructions from being accepted.
The directive .set loongson-cam makes the assembler accept instructions from the
Loongson CAM from that point on in the assembly. The .set noloongson-cam directive
prevents Loongson CAM instructions from being accepted.
The directive .set loongson-ext makes the assembler accept instructions from the
Loongson EXT from that point on in the assembly. The .set noloongson-ext directive
prevents Loongson EXT instructions from being accepted.
The directive .set loongson-ext2 makes the assembler accept instructions from
the Loongson EXT2 from that point on in the assembly. This directive implies
.set loognson-ext. The .set noloongson-ext2 directive prevents Loongson EXT2
instructions from being accepted.
Traditional MIPS assemblers do not support these directives.
If a ‘#’ appears as the first character of a line, the whole line is treated as a comment, but
in this case the line can also be a logical line number directive (see Section 3.3 [Comments],
page 31) or a preprocessor control command (see Section 3.1 [Preprocessing], page 31).
The ‘;’ character can be used to separate statements on the same line.
244 Using as
is in effect, they are instead passed through to the linker, which will allocate as many global
registers as is needed.
9.28.3 Syntax
The assembly syntax is supposed to be upward compatible with that described in Sec-
tions 1.3 and 1.4 of ‘The Art of Computer Programming, Volume 1’. Draft versions of those
chapters as well as other MMIX information is located at http://www-cs-faculty.
stanford.edu/~knuth/mmix-news.html. Most code examples from the mmixal package
located there should work unmodified when assembled and linked as single files, with a few
noteworthy exceptions (see Section 9.28.4 [MMIX-mmixal], page 249).
Before an instruction is emitted, the current location is aligned to the next four-byte
boundary. If a label is defined at the beginning of the line, its value will be the aligned
value.
In addition to the traditional hex-prefix ‘0x’, a hexadecimal number can also be specified
by the prefix character ‘#’.
After all operands to an MMIX instruction or directive have been specified, the rest of
the line is ignored, treated as a comment.
Two other characters, ‘%’ and ‘!’, each start a comment anywhere on the line. Thus you
can’t use the ‘modulus’ and ‘not’ operators in expressions normally associated with these
two characters.
A ‘;’ is a line separator, treated as a new-line, so separate instructions can be specified
on a single line.
9.28.3.2 Symbols
The character ‘:’ is permitted in identifiers. There are two exceptions to it being treated as
any other symbol character: if a symbol begins with ‘:’, it means that the symbol is in the
global namespace and that the current prefix should not be prepended to that symbol (see
[MMIX-prefix], page 249). The ‘:’ is then not considered part of the symbol. For a symbol
in the label position (first on a line), a ‘:’ at the end of a symbol is silently stripped off. A
label is permitted, but not required, to be followed by a ‘:’, as with many other assembly
formats.
The character ‘@’ in an expression, is a synonym for ‘.’, the current location.
In addition to the common forward and backward local symbol formats (see Section 5.3
[Symbol Names], page 43), they can be specified with upper-case ‘B’ and ‘F’, as in ‘8B’ and
‘9F’. A local label defined for the current position is written with a ‘H’ appended to the
number:
3H LDB $0,$1,2
This and traditional local-label formats cannot be mixed: a label must be defined and
referred to using the same format.
There’s a minor caveat: just as for the ordinary local symbols, the local symbols are
translated into ordinary symbols using control characters are to hide the ordinal number
of the symbol. Unfortunately, these symbols are not translated back in error messages.
Thus you may see confusing error messages when local symbols are used. Control charac-
ters ‘\003’ (control-C) and ‘\004’ (control-D) are used for the MMIX-specific local-symbol
syntax.
The symbol ‘Main’ is handled specially; it is always global.
By defining the symbols ‘__.MMIX.start..text’ and ‘__.MMIX.start..data’, the ad-
dress of respectively the ‘.text’ and ‘.data’ segments of the final program can be defined,
though when linking more than one object file, the code or data in the object file containing
the symbol is not guaranteed to be start at that position; just the final executable. See
[MMIX-loc], page 247.
GREG
This directive reserves a global register, gives it an initial value and optionally
gives it a symbolic name. Some examples:
areg GREG
breg GREG data_value
248 Using as
GREG data_buffer
.greg creg, another_data_value
The symbolic register name can be used in place of a (non-special) register. If a
value isn’t provided, it defaults to zero. Unless the option ‘--no-merge-gregs’
is specified, non-zero registers allocated with this directive may be eliminated
by as; another register with the same value used in its place. Any of the in-
structions ‘CSWAP’, ‘GO’, ‘LDA’, ‘LDBU’, ‘LDB’, ‘LDHT’, ‘LDOU’, ‘LDO’, ‘LDSF’, ‘LDTU’,
‘LDT’, ‘LDUNC’, ‘LDVTS’, ‘LDWU’, ‘LDW’, ‘PREGO’, ‘PRELD’, ‘PREST’, ‘PUSHGO’, ‘STBU’,
‘STB’, ‘STCO’, ‘STHT’, ‘STOU’, ‘STSF’, ‘STTU’, ‘STT’, ‘STUNC’, ‘SYNCD’, ‘SYNCID’,
can have a value nearby an initial value in place of its second and third operands.
Here, “nearby” is defined as within the range 0. . . 255 from the initial value of
such an allocated register.
buffer1 BYTE 0,0,0,0,0
buffer2 BYTE 0,0,0,0,0
...
GREG buffer1
LDOU $42,buffer2
In the example above, the ‘Y’ field of the LDOUI instruction (LDOU with a
constant Z) will be replaced with the global register allocated for ‘buffer1’,
and the ‘Z’ field will have the value 5, the offset from ‘buffer1’ to ‘buffer2’.
The result is equivalent to this code:
buffer1 BYTE 0,0,0,0,0
buffer2 BYTE 0,0,0,0,0
...
tmpreg GREG buffer1
LDOU $42,tmpreg,(buffer2-buffer1)
Global registers allocated with this directive are allocated in order higher-to-
lower within a file. Other than that, the exact order of register allocation and
elimination is undefined. For example, the order is undefined when more than
one file with such directives are linked together. With the options ‘-x’ and
‘--linker-allocated-gregs’, ‘GREG’ directives for two-operand cases like the
one mentioned above can be omitted. Sufficient global registers will then be
allocated by the linker.
BYTE
The ‘BYTE’ directive takes a series of operands separated by a comma. If an
operand is a string (see Section 3.6.1.1 [Strings], page 33), each character of
that string is emitted as a byte. Other operands must be constant expressions
without forward references, in the range 0. . . 255. If you need operands hav-
ing expressions with forward references, use ‘.byte’ (see Section 7.11 [Byte],
page 54). An operand can be omitted, defaulting to a zero value.
WYDE
TETRA
OCTA
The directives ‘WYDE’, ‘TETRA’ and ‘OCTA’ emit constants of two, four and eight
bytes size respectively. Before anything else happens for the directive, the
current location is aligned to the respective constant-size boundary. If a label
is defined at the beginning of the line, its value will be that after the alignment.
Chapter 9: Machine Dependent Features 249
A single operand can be omitted, defaulting to a zero value emitted for the
directive. Operands can be expressed as strings (see Section 3.6.1.1 [Strings],
page 33), in which case each character in the string is emitted as a separate
constant of the size indicated by the directive.
PREFIX
The ‘PREFIX’ directive sets a symbol name prefix to be prepended to all sym-
bols (except local symbols, see Section 9.28.3.2 [MMIX-Symbols], page 246),
that are not prefixed with ‘:’, until the next ‘PREFIX’ directive. Such prefixes
accumulate. For example,
PREFIX a
PREFIX b
c IS 0
defines a symbol ‘abc’ with the value 0.
BSPEC
ESPEC
A pair of ‘BSPEC’ and ‘ESPEC’ directives delimit a section of special contents
(without specified semantics). Example:
BSPEC 42
TETRA 1,2,3
ESPEC
The single operand to ‘BSPEC’ must be number in the range 0. . . 255. The
‘BSPEC’ number 80 is used by the GNU binutils implementation.
Predefined symbols are visible as file-local symbols after use. (In the ELF file, that
is—the linked mmo file has no notion of a file-local symbol.)
Some mapping of constant expressions to sections in LOC expressions is attempted, but
that functionality is easily confused and should be avoided unless compatibility with mmixal
is required. A LOC expression to ‘0x2000000000000000’ or higher, maps to the ‘.data’
section and lower addresses map to the ‘.text’ section (see [MMIX-loc], page 247).
The code and data areas are each contiguous. Sparse programs with far-away LOC
directives will take up the same amount of space as a contiguous program with zeros filled
in the gaps between the LOC directives. If you need sparse programs, you might try and
get the wanted effect with a linker script and splitting up the code parts into sections (see
Section 7.85 [Section], page 77). Assembly code for this, to be compatible with mmixal,
would look something like:
.if 0
LOC away_expression
.else
.section away,"ax"
.fi
as will not execute the LOC directive and mmixal ignores the lines with .. This construct
can be used generally to help compatibility.
Symbols can’t be defined twice–not even to the same value.
Instruction mnemonics are recognized case-insensitive, though the ‘IS’ and ‘GREG’
pseudo-operations must be specified in upper-case characters.
There’s no unicode support.
The following is a list of programs in ‘mmix.tar.gz’, available at http://
www-cs-faculty.stanford.edu/~knuth/mmix-news.html, last checked with the version
dated 2001-08-25 (md5sum c393470cfc86fac040487d22d2bf0172) that assemble with mmixal
but do not assemble with as:
silly.mms
LOC to a previous address.
sim.mms Redefines symbol ‘Done’.
test.mms Uses the serial operator ‘&’.
Chapter 9: Machine Dependent Features 251
Note that this option can be stacked with the -mn option so that the assembler
will both warn about missing NOP instructions and then insert them automat-
ically.
-mY disables warnings about missing NOP instructions.
-md mark the object file as one that requires data to copied from ROM to RAM at
execution startup. Disabled by default.
-mdata-region=region
Select the region data will be placed in. Region placement is performed by the
compiler and linker. The only effect this option will have on the assembler is
that if upper or either is selected, then the symbols to initialise high data and
bss will be defined. Valid region values are:
none
lower
upper
either
9.29.2 Syntax
9.29.2.1 Macros
The macro syntax used on the MSP 430 is like that described in the MSP 430 Family
Assembler Specification. Normal as macros should still work.
Additional built-in macros are:
llo(exp) Extracts least significant word from 32-bit expression ’exp’.
lhi(exp) Extracts most significant word from 32-bit expression ’exp’.
hlo(exp) Extracts 3rd word from 64-bit expression ’exp’.
hhi(exp) Extracts 4rd word from 64-bit expression ’exp’.
They normally being used as an immediate source operand.
mov #llo(1), r10 ; == mov #1, r10
mov #lhi(1), r10 ; == mov #0, r10
bne label A polymorph instruction which is ‘jne label’ or ‘jeq +4; br label’
blt label A polymorph instruction which is ‘jl label’ or ‘jge +4; br label’
bltn label
A polymorph instruction which is ‘jn label’ or ‘jn +2; jmp +4; br label’
bltu label
A polymorph instruction which is ‘jlo label’ or ‘jhs +2; br label’
bge label A polymorph instruction which is ‘jge label’ or ‘jl +4; br label’
bgeu label
A polymorph instruction which is ‘jhs label’ or ‘jlo +4; br label’
bgt label A polymorph instruction which is ‘jeq +2; jge label’ or ‘jeq +6; jl +4; br
label’
bgtu label
A polymorph instruction which is ‘jeq +2; jhs label’ or ‘jeq +6; jlo +4; br
label’
bleu label
A polymorph instruction which is ‘jeq label; jlo label’ or ‘jeq +2; jhs +4;
br label’
ble label A polymorph instruction which is ‘jeq label; jl label’ or ‘jeq +2; jge +4;
br label’
jump label
A polymorph instruction which is ‘jmp label’ or ‘br label’
254 Using as
9.29.5 Opcodes
as implements all the standard MSP 430 opcodes. No additional pseudo-instructions are
needed on this family.
For information on the 430 machine instruction set, see MSP430 User’s Manual, docu-
ment slau049d, Texas Instrument, Inc.
-m[no-]perf-ext
Enable/Disable Performance extension
-m[no-]perf2-ext
Enable/Disable Performance extension 2
-m[no-]string-ext
Enable/Disable String extension
-m[no-]reduced-regs
Enable/Disable Reduced Register configuration (GPR16) option
-m[no-]audio-isa-ext
Enable/Disable AUDIO ISA extension
-m[no-]fpu-sp-ext
Enable/Disable FPU SP extension
-m[no-]fpu-dp-ext
Enable/Disable FPU DP extension
-m[no-]fpu-fma
Enable/Disable FPU fused-multiply-add instructions
-mall-ext
Turn on all extensions and instructions support
9.30.2 Syntax
9.30.2.1 Special Characters
Use ‘#’ at column 1 and ‘!’ anywhere in the line except inside quotes.
Multiple instructions in a line are allowed though not recommended and should be
separated by ‘;’.
Assembler is not case-sensitive in general except user defined label. For example, ‘jral
F1’ is different from ‘jral f1’ while it is the same as ‘JRAL F1’.
Global pointer
Register $r29 is regarded as the global pointer.
Link pointer
Register $r30 is regarded as the link pointer.
Stack pointer
Register $r31 is regarded as the stack pointer.
not rt5,ra5
Alias of ‘nor rt5,ra5,ra5’.
neg rt5,ra5
Alias of ‘subri rt5,ra5,0’.
br rb5 Depending on how it is assembled, it is translated into ‘r5 rb5’ or ‘jr rb5’.
b label Branch to label depending on how it is assembled, it is translated into ‘j8
label’, ‘j label’, or "‘la $ta,label’ ‘br $ta’".
bral rb5 Alias of jral br5 depending on how it is assembled, it is translated into ‘jral5
rb5’ or ‘jral rb5’.
bal fname Alias of jal fname depending on how it is assembled, it is translated into ‘jal
fname’ or "‘la $ta,fname’ ‘bral $ta’".
call fname
Call function fname same as ‘jal fname’.
move rt5,ra5
For 16-bit, this is ‘mov55 rt5,ra5’. For no 16-bit, this is ‘ori rt5,ra5,0’.
move rt5,var
This is the same as ‘l.w rt5,var’.
move rt5,imm32
This is the same as ‘li rt5,imm32’.
pushm ra5,rb5
Push contents of registers from ra5 to rb5 into stack.
push ra5 Push content of register ra5 into stack. (same ‘pushm ra5,ra5’).
push.d var
Push value of double-word variable var into stack.
push.w var
Push value of word variable var into stack.
push.h var
Push value of half-word variable var into stack.
push.b var
Push value of byte variable var into stack.
pusha var Push 32-bit address of variable var into stack.
pushi imm32
Push 32-bit immediate value into stack.
popm ra5,rb5
Pop top of stack values into registers ra5 to rb5.
pop rt5 Pop top of stack value into register. (same as ‘popm rt5,rt5’.)
pop.d var,ra5
Pop value of double-word variable var from stack using register ra5 as 2nd
scratch register. (1st is $ta)
Chapter 9: Machine Dependent Features 261
pop.w var,ra5
Pop value of word variable var from stack using register ra5.
pop.h var,ra5
Pop value of half-word variable var from stack using register ra5.
pop.b var,ra5
Pop value of byte variable var from stack using register ra5.
262 Using as
9.31.2 Syntax
9.31.2.1 Special Characters
‘#’ is the line comment character. ‘;’ is the line separator character.
%hi(expression)
Extract the upper 16 bits of expression.
%lo(expression)
Extract the lower 16 bits of expression.
Chapter 9: Machine Dependent Features 263
%gprel(expression)
Subtract the value of the symbol _gp from expression.
The intention of the %gprel relocation is to have a fast small area of memory
which only takes a 16-bit immediate to access.
.section .sdata
fastint:
.int 123
.section .text
ldw r4, %gprel(fastint)(gp)
%call(expression)
%call_lo(expression)
%call_hiadj(expression)
%got(expression)
%got_lo(expression)
%got_hiadj(expression)
%gotoff(expression)
%gotoff_lo(expression)
%gotoff_hiadj(expression)
%tls_gd(expression)
%tls_ie(expression)
%tls_le(expression)
%tls_ldm(expression)
%tls_ldo(expression)
These relocations support the ABI for Linux Systems documented in the Nios
II Processor Reference Handbook.
.set noat Allows assembly code to use at register without warning. Macro or relaxation
expansions generate warnings.
.set at Assembly code using at register generates warnings, and macro expansion and
relaxation are enabled.
.set nobreak
Allows assembly code to use ba and bt registers without warning.
.set break
Turns warnings back on for using ba and bt registers.
.set norelax
Do not replace any branches or calls.
.set relaxsection
Replace identified out-of-range branches with jmp sequences (default).
.set relaxsection
Replace all branch and call instructions with jmp and callr sequences.
.set ... All other .set are the normal use.
9.31.5 Opcodes
as implements all the standard Nios II opcodes documented in the Nios II Processor Ref-
erence Handbook, including the assembler pseudo-instructions.
Chapter 9: Machine Dependent Features 265
9.33.1.3 Relocations
ELF relocations are available as defined in the OpenRISC architecture specification.
R_OR1K_HI_16_IN_INSN is obtained using ‘hi’ and R_OR1K_LO_16_IN_INSN and R_OR1K_
SLO16 are obtained using ‘lo’. For signed offsets R_OR1K_AHI16 is obtained from ‘ha’. For
example:
l.movhi r5, hi(symbol)
l.ori r5, r5, lo(symbol)
9.33.4 Opcodes
For detailed information on the OpenRISC machine instruction set, see http://www.
openrisc.io/architecture/.
as implements all the standard OpenRISC opcodes.
270 Using as
-mlimited-eis | -mno-limited-eis
Enable (or disable) the use of the limited extended instruction set: MARK, RTT,
SOB, SXT, and XOR.
The -mno-limited-eis options also implies -mno-eis.
-mmfpt | -mno-mfpt
Enable (or disable) the use of the MFPT instruction.
-mmultiproc | -mno-multiproc
Enable (or disable) the use of multiprocessor instructions: TSTSET and WRTLCK.
-mmxps | -mno-mxps
Enable (or disable) the use of the MFPS and MTPS instructions.
-mspl | -mno-spl
Enable (or disable) the use of the SPL instruction.
Enable (or disable) the use of the microcode instructions: LDUB, MED, and XFC.
L2DR L2D
L3DR L3D
SYS TRAP
9.35.2 PJ Syntax
9.35.2.1 Special Characters
The presence of a ‘!’ or ‘/’ on a line indicates the start of a comment that extends to the
end of the current line.
If a ‘#’ appears as the first character of a line then the whole line is treated as a comment,
but in this case the line could also be a logical line number directive (see Section 3.3
[Comments], page 31) or a preprocessor control command (see Section 3.1 [Preprocessing],
page 31).
The ‘;’ character can be used to separate statements on the same line.
Chapter 9: Machine Dependent Features 275
-mrelocatable
Support for GCC’s -mrelocatable option.
-mrelocatable-lib
Support for GCC’s -mrelocatable-lib option.
-memb Set PPC EMB bit in ELF flags.
-mlittle, -mlittle-endian, -le
Generate code for a little endian machine.
-mbig, -mbig-endian, -be
Generate code for a big endian machine.
-msolaris
Generate code for Solaris.
-mno-solaris
Do not generate code for Solaris.
-nops=count
If an alignment directive inserts more than count nops, put a branch at the
beginning to skip execution of the nops.
9.37.2 Syntax
9.37.2.1 Special Characters
‘#’ and ‘;’ are the line comment characters.
.8byte expression
Create an unaligned constant 8 bytes in size.
.16byte expression
Create an unaligned constant 16 bytes in size.
.set no_warn_regname_label
Do not output warnings when a label name matches a register name. Equivalent
to passing the -mno-warn-regname-label command-line option.
9.37.5 Opcodes
as implements all the standard PRU core V3 opcodes in the original pasm assembler. Older
cores are not supported by as.
GAS also implements the LDI32 pseudo instruction for loading a 32-bit immediate value
into a register.
ldi32 sp, __stack_top
ldi32 r14, 0x12345678
280 Using as
-fpic
-fPIC Generate position-independent code
-fno-pic Don’t generate position-independent code (default)
-march=ISA
Select the base isa, as specified by ISA. For example -march=rv32ima. If this
option and the architecture attributes aren’t set, then assembler will check the
default configure setting –with-arch=ISA.
-misa-spec=ISAspec
Select the default isa spec version. If the version of ISA isn’t set by -march,
then assembler helps to set the version according to the default chosen spec.
If this option isn’t set, then assembler will check the default configure setting
–with-isa-spec=ISAspec.
-mpriv-spec=PRIVspec
Select the privileged spec version. We can decide whether the CSR is valid or
not according to the chosen spec. If this option and the privilege attributes
aren’t set, then assembler will check the default configure setting –with-priv-
spec=PRIVspec.
-mabi=ABI
Selects the ABI, which is either "ilp32" or "lp64", optionally followed by "f",
"d", or "q" to indicate single-precision, double-precision, or quad-precision
floating-point calling convention, or none to indicate the soft-float calling con-
vention. Also, "ilp32" can optionally be followed by "e" to indicate the RVE
ABI, which is always soft-float.
-mrelax Take advantage of linker relaxations to reduce the number of instructions re-
quired to materialize symbol addresses. (default)
-mno-relax
Don’t do linker relaxations.
-march-attr
Generate the default contents for the riscv elf attribute section if the .attribute
directives are not set. This section is used to record the information that a
linker or runtime loader needs to check compatibility. This information includes
ISA string, stack alignment requirement, unaligned memory accesses, and the
major, minor and revision version of privileged specification.
-mno-arch-attr
Don’t generate the default riscv elf attribute section if the .attribute directives
are not set.
Chapter 9: Machine Dependent Features 281
-mcsr-check
Enable the CSR checking for the ISA-dependent CRS and the read-only CSR.
The ISA-dependent CSR are only valid when the specific ISA is set. The read-
only CSR can not be written by the CSR instructions.
-mno-csr-check
Don’t do CSR checking.
-mlittle-endian
Generate code for a little endian machine.
-mbig-endian
Generate code for a big endian machine.
%lo(symbol)
The low 12 bits of absolute address for symbol.
%hi(symbol)
The high 20 bits of absolute address for symbol. This is usually used with the
%lo modifier to represent a 32-bit absolute address.
lui a0, %hi(symbol) // R_RISCV_HI20
addi a0, a0, %lo(symbol) // R_RISCV_LO12_I
%pcrel_lo(label)
The low 12 bits of relative address between pc and symbol. The symbol is
related to the high part instruction which is marked by label.
%pcrel_hi(symbol)
The high 20 bits of relative address between pc and symbol. This is usually
used with the %pcrel lo modifier to represent a +/-2GB pc-relative range.
label:
auipc a0, %pcrel_hi(symbol) // R_RISCV_PCREL_HI20
addi a0, a0, %pcrel_lo(label) // R_RISCV_PCREL_LO12_I
label:
auipc a0, %pcrel_hi(symbol) // R_RISCV_PCREL_HI20
load/store a0, %pcrel_lo(label)(a0) // R_RISCV_PCREL_LO12_I/S
Or you can use the pseudo lla/lw/sw/... instruction to do this.
lla a0, symbol
%got_pcrel_hi(symbol)
The high 20 bits of relative address between pc and the GOT entry of symbol.
This is usually used with the %pcrel lo modifier to access the GOT entry.
label:
auipc a0, %got_pcrel_hi(symbol) // R_RISCV_GOT_HI20
addi a0, a0, %pcrel_lo(label) // R_RISCV_PCREL_LO12_I
label:
auipc a0, %got_pcrel_hi(symbol) // R_RISCV_GOT_HI20
load/store a0, %pcrel_lo(label)(a0) // R_RISCV_PCREL_LO12_I/S
Also, the pseudo la instruction with PIC has similar behavior.
%tprel_add(symbol)
This is used purely to associate the R RISCV TPREL ADD relocation for
TLS relaxation. This one is only valid as the fourth operand to the normally 3
operand add instruction.
%tprel_lo(symbol)
The low 12 bits of relative address between tp and symbol.
%tprel_hi(symbol)
The high 20 bits of relative address between tp and symbol. This is usually
used with the %tprel lo and %tprel add modifiers to access the thread local
variable symbol in TLS Local Exec.
lui a5, %tprel_hi(symbol) // R_RISCV_TPREL_HI20
284 Using as
%tls_ie_pcrel_hi(symbol)
The high 20 bits of relative address between pc and GOT entry. It is usually
used with the %pcrel lo modifier to access the thread local variable symbol in
TLS Initial Exec.
la.tls.ie a5, symbol
add a5, a5, tp
load/store t0, 0(a5)
The pseudo la.tls.ie instruction can be expended to
label:
auipc a5, %tls_ie_pcrel_hi(symbol) // R_RISCV_TLS_GOT_HI20
load a5, %pcrel_lo(label)(a5) // R_RISCV_PCREL_LO12_I
%tls_gd_pcrel_hi(symbol)
The high 20 bits of relative address between pc and GOT entry. It is usually
used with the %pcrel lo modifier to access the thread local variable symbol in
TLS Global Dynamic.
la.tls.gd a0, symbol
call __tls_get_addr@plt
mv a5, a0
load/store t0, 0(a5)
The pseudo la.tls.gd instruction can be expended to
label:
auipc a0, %tls_gd_pcrel_hi(symbol) // R_RISCV_TLS_GD_HI20
addi a0, a0, %pcrel_lo(label) // R_RISCV_PCREL_LO12_I
rs1 First source register number for operand x, can be GPR or FPR.
C0
C1
286 Using as
R type with 4 register operands: .insn r opcode6, func3, func2, rd, rs1, rs2,
rs3
R4 type: .insn r4 opcode6, func3, func2, rd, rs1, rs2, rs3
+-----+-------+-----+-----+-------+----+---------+
| rs3 | func2 | rs2 | rs1 | func3 | rd | opcode6 |
+-----+-------+-----+-----+-------+----+---------+
31 27 25 20 15 12 7 0
I type: .insn i opcode6, func3, rd, rs1, simm12
I type: .insn i opcode6, func3, rd, simm12(rs1)
+--------------+-----+-------+----+---------+
| simm12[11:0] | rs1 | func3 | rd | opcode6 |
+--------------+-----+-------+----+---------+
31 20 15 12 7 0
S type: .insn s opcode6, func3, rs2, simm12(rs1)
+--------------+-----+-----+-------+-------------+---------+
| simm12[11:5] | rs2 | rs1 | func3 | simm12[4:0] | opcode6 |
+--------------+-----+-----+-------+-------------+---------+
31 25 20 15 12 7 0
B type: .insn s opcode6, func3, rs1, rs2, symbol
SB type: .insn sb opcode6, func3, rs1, rs2, symbol
+-----------------+-----+-----+-------+----------------+---------+
| simm12[12|10:5] | rs2 | rs1 | func3 | simm12[4:1|11] | opcode6 |
+-----------------+-----+-----+-------+----------------+---------+
31 25 20 15 12 7 0
U type: .insn u opcode6, rd, simm20
+--------------------------+----+---------+
| simm20[20|10:1|11|19:12] | rd | opcode6 |
+--------------------------+----+---------+
31 12 7 0
J type: .insn j opcode6, rd, symbol
UJ type: .insn uj opcode6, rd, symbol
+------------+--------------+------------+---------------+----+---------+
| simm20[20] | simm20[10:1] | simm20[11] | simm20[19:12] | rd | opcode6 |
+------------+--------------+------------+---------------+----+---------+
31 30 21 20 12 7 0
CR type: .insn cr opcode2, func4, rd, rs2
+-------+--------+-----+---------+
| func4 | rd/rs1 | rs2 | opcode2 |
+-------+--------+-----+---------+
15 12 7 2 0
CI type: .insn ci opcode2, func3, rd, simm6
+-------+----------+--------+------------+---------+
| func3 | simm6[5] | rd/rs1 | simm6[4:0] | opcode2 |
+-------+----------+--------+------------+---------+
288 Using as
15 13 12 7 2 0
CIW type: .insn ciw opcode2, func3, rd’, uimm8
+-------+------------+-----+---------+
| func3 | uimm8[7:0] | rd’ | opcode2 |
+-------+-------- ---+-----+---------+
15 13 5 2 0
CSS type: .insn css opcode2, func3, rd, uimm6
+-------+------------+----+---------+
| func3 | uimm6[5:0] | rd | opcode2 |
+-------+------------+----+---------+
15 13 7 2 0
CL type: .insn cl opcode2, func3, rd’, uimm5(rs1’)
+-------+------------+------+------------+------+---------+
| func3 | uimm5[4:2] | rs1’ | uimm5[1:0] | rd’ | opcode2 |
+-------+------------+------+------------+------+---------+
15 13 10 7 5 2 0
CS type: .insn cs opcode2, func3, rs2’, uimm5(rs1’)
+-------+------------+------+------------+------+---------+
| func3 | uimm5[4:2] | rs1’ | uimm5[1:0] | rs2’ | opcode2 |
+-------+------------+------+------------+------+---------+
15 13 10 7 5 2 0
CA type: .insn ca opcode2, func6, func2, rd’, rs2’
+-- ----+----------+-------+------+---------+
| func6 | rd’/rs1’ | func2 | rs2’ | opcode2 |
+-------+----------+-------+------+---------+
15 10 7 5 2 0
CB type: .insn cb opcode2, func3, rs1’, symbol
+-------+--------------+------+------------------+---------+
| func3 | simm8[8|4:3] | rs1’ | simm8[7:6|2:1|5] | opcode2 |
+-------+--------------+------+------------------+---------+
15 13 10 7 2 0
CJ type: .insn cj opcode2, symbol
+-------+-------------------------------+---------+
| func3 | simm11[11|4|9:8|10|6|7|3:1|5] | opcode2 |
+-------+-------------------------------+---------+
15 13 2 0
For the complete list of all instruction format variants see The RISC-V Instruction Set
Manual Volume I: User-Level ISA.
%hi16()
When loading a 20-bit (or wider) address into registers, this modifier selects
the 16 most significant bits.
movw ax,#%hi16(_sym)
%hi8()
When loading a 20-bit (or wider) address into registers, this modifier selects
the 8 bits that would go into CS or ES (i.e. bits 23..16).
mov es, #%hi8(_sym)
-mgcc-abi
This option tells the assembler that the old GCC ABI is being used by the
assembled code. With this version of the ABI function arguments that are
passed on the stack are aligned to a 32-bit boundary.
-mrx-abi This option tells the assembler that the official RX ABI is being used by the
assembled code. With this version of the ABI function arguments that are
passed on the stack are aligned to their natural alignments. This option is the
default.
-mcpu=name
This option tells the assembler the target CPU type. Currently the rx100,
rx200, rx600, rx610, rxv2, rxv3 and rxv3-dfpu are recognised as valid cpu
names. Attempting to assemble an instructionnot supported by the indicated
cpu type will result in an error message being generated.
-mno-allow-string-insns
This option tells the assembler to mark the object file that it is building as one
that does not use the string instructions SMOVF, SCMPU, SMOVB, SMOVU, SUNTIL
SWHILE or the RMPA instruction. In addition the mark tells the linker to complain
if an attempt is made to link the binary with another one that does use any of
these instructions.
Note - the inverse of this option, -mallow-string-insns, is not needed. The
assembler automatically detects the use of the the instructions in the source
code and labels the resulting object file appropriately. If no string instructions
are detected then the object file is labelled as being one that can be linked with
either string-using or string-banned object files.
The modifier returns the offset from the gp symbol to the specified symbol as a 16-bit
value. The intent is that this offset should be used in a register+offset move instruction
when generating references to small data. Ie, like this:
mov.W %gp(_foo)[%gpreg], r1
The assembler also supports two meta register names which can be used to refer to
registers whose values may not be known to the programmer. These meta register names
are:
Both registers normally have the value r13, but this can change if some registers have
been reserved for use by interrupt handlers or if both the small data limit and position
independent data features are being used at the same time.
294 Using as
9.41.1 Options
The following table lists all available s390 specific options:
-m31 | -m64
Select 31- or 64-bit ABI implying a word size of 32- or 64-bit.
These options are only available with the ELF object file format, and require
that the necessary BFD support has been included (on a 31-bit platform you
must add –enable-64-bit-bfd on the call to the configure script to enable 64-bit
usage and use s390x as target platform).
-mesa | -mzarch
Select the architecture mode, either the Enterprise System Architecture (esa)
mode or the z/Architecture mode (zarch).
The 64-bit instructions are only available with the z/Architecture mode. The
combination of ‘-m64’ and ‘-mesa’ results in a warning message.
-march=CPU
This option specifies the target processor. The following processor names are
recognized: g5 (or arch3), g6, z900 (or arch5), z990 (or arch6), z9-109,
z9-ec (or arch7), z10 (or arch8), z196 (or arch9), zEC12 (or arch10), z13 (or
arch11), z14 (or arch12), z15 (or arch13), and arch14.
Assembling an instruction that is not supported on the target processor results
in an error message.
The processor names starting with arch refer to the edition number in the
Principle of Operations manual. They can be used as alternate processor names
and have been added for compatibility with the IBM XL compiler.
arch3, g5 and g6 cannot be used with the ‘-mzarch’ option since the
z/Architecture mode is not supported on these processor levels.
There is no arch4 option supported. arch4 matches -march=arch5 -mesa.
-mregnames
Allow symbolic names for registers.
-mno-regnames
Do not allow symbolic names for registers.
-mwarn-areg-zero
Warn whenever the operand for a base or index register has been specified but
evaluates to zero. This can indicate the misuse of general purpose register 0 as
an address register.
296 Using as
Certain characters at the end of the mnemonic may describe a property of the instruction:
c the instruction uses a 8-bit character operand
There are many exceptions to the scheme outlined in the above lists, in particular for
the privileged instructions. For non-privileged instruction it works quite well, for example
the instruction ‘clgfr’ c: compare instruction, l: unsigned operands, g: 64-bit operands, f:
32- to 64-bit extension, r: register operands. The instruction compares an 64-bit value in a
register with the zero extended 32-bit value from a second register. For a complete list of
all mnemonics see appendix B in the Principles of Operation.
Dn(Ln,Bn)
the address for operand number n is formed from the content of general register
Bn called the base register and the displacement field Dn. The length of the
operand n is specified by the field Ln.
The base registers Bn and the index registers Xn of a storage operand can be skipped.
If Bn and Xn are skipped, a zero will be stored to the operand field. The notation changes
as follows:
Dn(0,Bn) Dn(Bn)
Dn(0,0) Dn
Dn(0) Dn
Dn(Ln,0) Dn(Ln)
An instruction is two, four, or six bytes in length and must be aligned on a 2 byte
boundary. The first two bits of the instruction specify the length of the instruction, 00
300 Using as
indicates a two byte instruction, 01 and 10 indicates a four byte instruction, and 11 indicates
a six byte instruction.
The following table lists the s390 instruction formats that are available with the ‘.insn’
pseudo directive:
E format
+-------------+
| OpCode |
+-------------+
0 15
RI format: <insn> R1,I2
+--------+----+----+------------------+
| OpCode | R1 |OpCd| I2 |
+--------+----+----+------------------+
0 8 12 16 31
RIE format: <insn> R1,R3,I2
+--------+----+----+------------------+--------+--------+
| OpCode | R1 | R3 | I2 |////////| OpCode |
+--------+----+----+------------------+--------+--------+
0 8 12 16 32 40 47
RIL format: <insn> R1,I2
+--------+----+----+------------------------------------+
| OpCode | R1 |OpCd| I2 |
+--------+----+----+------------------------------------+
0 8 12 16 47
RILU format: <insn> R1,U2
+--------+----+----+------------------------------------+
| OpCode | R1 |OpCd| U2 |
+--------+----+----+------------------------------------+
0 8 12 16 47
RIS format: <insn> R1,I2,M3,D4(B4)
+--------+----+----+----+-------------+--------+--------+
| OpCode | R1 | M3 | B4 | D4 | I2 | Opcode |
+--------+----+----+----+-------------+--------+--------+
0 8 12 16 20 32 36 47
RR format: <insn> R1,R2
+--------+----+----+
| OpCode | R1 | R2 |
+--------+----+----+
0 8 12 15
RRE format: <insn> R1,R2
+------------------+--------+----+----+
| OpCode |////////| R1 | R2 |
+------------------+--------+----+----+
Chapter 9: Machine Dependent Features 301
0 16 24 28 31
RRF format: <insn> R1,R2,R3,M4
+------------------+----+----+----+----+
| OpCode | R3 | M4 | R1 | R2 |
+------------------+----+----+----+----+
0 16 20 24 28 31
RRS format: <insn> R1,R2,M3,D4(B4)
+--------+----+----+----+-------------+----+----+--------+
| OpCode | R1 | R3 | B4 | D4 | M3 |////| OpCode |
+--------+----+----+----+-------------+----+----+--------+
0 8 12 16 20 32 36 40 47
RS format: <insn> R1,R3,D2(B2)
+--------+----+----+----+-------------+
| OpCode | R1 | R3 | B2 | D2 |
+--------+----+----+----+-------------+
0 8 12 16 20 31
RSE format: <insn> R1,R3,D2(B2)
+--------+----+----+----+-------------+--------+--------+
| OpCode | R1 | R3 | B2 | D2 |////////| OpCode |
+--------+----+----+----+-------------+--------+--------+
0 8 12 16 20 32 40 47
RSI format: <insn> R1,R3,I2
+--------+----+----+------------------------------------+
| OpCode | R1 | R3 | I2 |
+--------+----+----+------------------------------------+
0 8 12 16 47
RSY format: <insn> R1,R3,D2(B2)
+--------+----+----+----+-------------+--------+--------+
| OpCode | R1 | R3 | B2 | DL2 | DH2 | OpCode |
+--------+----+----+----+-------------+--------+--------+
0 8 12 16 20 32 40 47
RX format: <insn> R1,D2(X2,B2)
+--------+----+----+----+-------------+
| OpCode | R1 | X2 | B2 | D2 |
+--------+----+----+----+-------------+
0 8 12 16 20 31
RXE format: <insn> R1,D2(X2,B2)
+--------+----+----+----+-------------+--------+--------+
| OpCode | R1 | X2 | B2 | D2 |////////| OpCode |
+--------+----+----+----+-------------+--------+--------+
0 8 12 16 20 32 40 47
RXF format: <insn> R1,R3,D2(X2,B2)
+--------+----+----+----+-------------+----+---+--------+
302 Using as
In the mnemonic for a branch instruction the condition code string <m> can be any of
the following:
h jump on A high
p jump on plus
l jump on A low
m jump on minus
e jump on A equal B
For the compare and branch, and compare and trap instructions there are 12 condition
code strings that can be used as part of the mnemonic in place of a mask operand in the
instruction format:
In the mnemonic for a compare and branch and compare and trap instruction the con-
dition code string <m> can be any of the following:
h jump on A high
l jump on A low
e jump on A equal B
entered into the GOT or PLT, ‘label’ is a local label, and ‘constant’ is an arbitrary
expression that the assembler can evaluate to a constant value.
The term ‘(symbol + constant1)@modifier +/- label + constant2’ is also accepted
but a warning message is printed and the term is converted to ‘symbol@modifier +/-
label + constant1 + constant2’.
@got
@got12 The @got modifier can be used for displacement fields, 16-bit immediate fields
and 32-bit pc-relative immediate fields. The @got12 modifier is synonym to
@got. The symbol is added to the GOT. For displacement fields and 16-bit
immediate fields the symbol term is replaced with the offset from the start of
the GOT to the GOT slot for the symbol. For a 32-bit pc-relative field the
pc-relative offset to the GOT slot from the current instruction address is used.
@gotent The @gotent modifier can be used for 32-bit pc-relative immediate fields. The
symbol is added to the GOT and the symbol term is replaced with the pc-
relative offset from the current instruction to the GOT slot for the symbol.
@gotoff The @gotoff modifier can be used for 16-bit immediate fields. The symbol term
is replaced with the offset from the start of the GOT to the address of the
symbol.
@gotplt The @gotplt modifier can be used for displacement fields, 16-bit immediate
fields, and 32-bit pc-relative immediate fields. A procedure linkage table entry
is generated for the symbol and a jump slot for the symbol is added to the GOT.
For displacement fields and 16-bit immediate fields the symbol term is replaced
with the offset from the start of the GOT to the jump slot for the symbol. For
a 32-bit pc-relative field the pc-relative offset to the jump slot from the current
instruction address is used.
@plt The @plt modifier can be used for 16-bit and 32-bit pc-relative immediate fields.
A procedure linkage table entry is generated for the symbol. The symbol term
is replaced with the relative offset from the current instruction to the PLT entry
for the symbol.
@pltoff The @pltoff modifier can be used for 16-bit immediate fields. The symbol term
is replaced with the offset from the start of the PLT to the address of the
symbol.
@gotntpoff
The @gotntpoff modifier can be used for displacement fields. The symbol is
added to the static TLS block and the negated offset to the symbol in the
static TLS block is added to the GOT. The symbol term is replaced with the
offset to the GOT slot from the start of the GOT.
@indntpoff
The @indntpoff modifier can be used for 32-bit pc-relative immediate fields. The
symbol is added to the static TLS block and the negated offset to the symbol
in the static TLS block is added to the GOT. The symbol term is replaced with
the pc-relative offset to the GOT slot from the current instruction address.
308 Using as
For more information about the thread local storage modifiers ‘gotntpoff’ and
‘indntpoff’ see the ELF extension documentation ‘ELF Handling For Thread-Local
Storage’.
The assembler directive ‘.ltorg’ is used to emit all literal pool entries to the current
position.
@gotntpoff
@indntpoff
The @gotntpoff and @indntpoff modifier can be used for .long and
.quad. The symbol is added to the static TLS block and the negated
offset to the symbol in the static TLS block is added to the GOT.
For @gotntpoff the symbol term is replaced with the offset from
the start of the GOT to the GOT slot, for @indntpoff the symbol
term is replaced with the address of the GOT slot.
@dtpoff The @dtpoff modifier can be used for .long and .quad. The symbol
term is replaced with the offset of the symbol relative to the start
of the TLS block it is contained in.
@ntpoff The @ntpoff modifier can be used for .long and .quad. The symbol
term is replaced with the offset of the symbol relative to the TCB
pointer.
For more information about the thread local storage modifiers see the ELF
extension documentation ‘ELF Handling For Thread-Local Storage’.
.ltorg This directive causes the current contents of the literal pool to be dumped to
the current location (Section 9.41.3.8 [s390 Literal Pool Entries], page 308).
.machine STRING[+EXTENSION]...
This directive allows changing the machine for which code is generated. string
may be any of the -march= selection options, or push, or pop. .machine push
saves the currently selected cpu, which may be restored with .machine pop. Be
aware that the cpu string has to be put into double quotes in case it contains
characters not appropriate for identifiers. So you have to write "z9-109" instead
of just z9-109. Extensions can be specified after the cpu name, separated by
plus characters. Valid extensions are: htm, nohtm, vx, novx. They extend the
basic instruction set with features from a higher cpu level, or remove support
for a feature from the given cpu level.
Example: z13+nohtm allows all instructions of the z13 cpu except instructions
from the HTM facility.
.machinemode string
This directive allows one to change the architecture mode for which code is
being generated. string may be esa, zarch, zarch_nohighgprs, push, or pop.
.machinemode zarch_nohighgprs can be used to prevent the highgprs flag
from being set in the ELF header of the output file. This is useful in situations
where the code is gated with a runtime check which makes sure that the code is
only executed on kernels providing the highgprs feature. .machinemode push
saves the currently selected mode, which may be restored with .machinemode
pop.
‘.double’ always emit the ieee format. To assemble hexadecimal floating-point constants
the ‘.long’ and ‘.quad’ directives must be used.
312 Using as
set nor1 Let the assembler to generate warnings if the source program uses r1. (Default)
.sdata Tell the assembler to add subsequent data into the sdata section
.rdata Tell the assembler to add subsequent data into the rdata section
.frame "frame-register", "offset", "return-pc-register"
Describe a stack frame. "frame-register" is the frame register, "offset" is the dis-
tance from the frame register to the virtual frame pointer, "return-pc-register"
is the return program register. You must use ".ent" before ".frame" and only
one ".frame" can be used per ".ent".
.mask "bitmask", "frameoffset"
Indicate which of the integer registers are saved in the current function’s stack
frame, this is for the debugger to explain the frame chain.
.ent "proc-name"
Set the beginning of the procedure "proc name". Use this directive when you
want to generate information for the debugger.
.end proc-name
Set the end of a procedure. Use this directive to generate information for the
debugger.
.bss Switch the destination of following statements into the bss section, which is
used for data that is uninitialized anywhere.
--renesas
Disable optimization with section symbol for compatibility with Renesas as-
sembler.
--allow-reg-prefix
Allow ’$’ as a register name prefix.
--isa=sh4 | sh4a
Specify the sh4 or sh4a instruction set.
--isa=dsp
Enable sh-dsp insns, and disable sh3e / sh4 insns.
--isa=all
Enable sh1, sh2, sh2e, sh3, sh3e, sh4, sh4a, and sh-dsp insn sets.
-h-tick-hex
Support H’00 style hex constants in addition to 0x00 style.
9.43.2 Syntax
9.43.2.1 Special Characters
‘!’ is the line comment character.
You can use ‘;’ instead of a newline to separate statements.
If a ‘#’ appears as the first character of a line then the whole line is treated as a comment,
but in this case the line could also be a logical line number directive (see Section 3.3
[Comments], page 31) or a preprocessor control command (see Section 3.1 [Preprocessing],
page 31).
Since ‘$’ has no special meaning, you may use it in symbol names.
Chapter 9: Machine Dependent Features 315
SH3E instructions are a subset of the floating point calculations conforming to the IEEE754
standard.
In addition to single-precision and double-precision floating-point operation capability,
the on-chip FPU of SH4 has a 128-bit graphic engine that enables 32-bit floating-point
data to be processed 128 bits at a time. It also supports 4 * 4 array operations and inner
product operations. Also, a superscalar architecture is employed that enables simultaneous
execution of two instructions (including FPU instructions), providing performance of up to
twice that of conventional architectures at the same frequency.
9.43.5 Opcodes
For detailed information on the SH machine instruction set, see SH-Microcomputer User’s
Manual (Renesas) or SH-4 32-bit CPU Core Architecture (SuperH) and SuperH (SH) 64-Bit
RISC Series (SuperH).
as implements all the standard SH opcodes. No additional pseudo-instructions are
needed on this family. Note, however, that because as supports a simpler form of PC-
relative addressing, you may simply write (for example)
mov.l bar,r0
where other assemblers might require an explicit displacement to bar from the program
counter:
mov.l @(disp, PC)
Chapter 9: Machine Dependent Features 317
9.44.3.3 Constants
Several Sparc instructions take an immediate operand field for which mnemonic names
exist. Two such examples are ‘membar’ and ‘prefetch’. Another example are the set of V9
memory access instruction that allow specification of an address space identifier.
The ‘membar’ instruction specifies a memory barrier that is the defined by the operand
which is a bitmask. The supported mask mnemonics are:
• ‘#Sync’ requests that all operations (including nonmemory reference operations) ap-
pearing prior to the membar must have been performed and the effects of any excep-
tions become visible before any instructions after the membar may be initiated. This
corresponds to membar cmask field bit 2.
• ‘#MemIssue’ requests that all memory reference operations appearing prior to the
membar must have been performed before any memory operation after the membar
may be initiated. This corresponds to membar cmask field bit 1.
• ‘#Lookaside’ requests that a store appearing prior to the membar must complete before
any load following the membar referencing the same address can be initiated. This
corresponds to membar cmask field bit 0.
• ‘#StoreStore’ defines that the effects of all stores appearing prior to the membar in-
struction must be visible to all processors before the effect of any stores following the
membar. Equivalent to the deprecated stbar instruction. This corresponds to membar
mmask field bit 3.
322 Using as
• ‘#LoadStore’ defines all loads appearing prior to the membar instruction must have
been performed before the effect of any stores following the membar is visible to any
other processor. This corresponds to membar mmask field bit 2.
• ‘#StoreLoad’ defines that the effects of all stores appearing prior to the membar in-
struction must be visible to all processors before loads following the membar may be
performed. This corresponds to membar mmask field bit 1.
• ‘#LoadLoad’ defines that all loads appearing prior to the membar instruction must have
been performed before any loads following the membar may be performed. This corre-
sponds to membar mmask field bit 0.
The actual behavior of a given prefetch function code is processor specific. If a processor
does not implement a given prefetch function code, it will treat the prefetch instruction
as a nop.
For instructions that accept an immediate address space identifier, as provides many
mnemonics corresponding to V9 defined as well as UltraSPARC and Niagara extended
values. For example, ‘#ASI_P’ and ‘#ASI_BLK_INIT_QUAD_LDD_AIUS’. See the V9 and
processor specific manuals for details.
9.44.3.4 Relocations
ELF relocations are available as defined in the 32-bit and 64-bit Sparc ELF specifications.
R_SPARC_HI22 is obtained using ‘%hi’ and R_SPARC_LO10 is obtained using ‘%lo’. Like-
wise R_SPARC_HIX22 is obtained from ‘%hix’ and R_SPARC_LOX10 is obtained using ‘%lox’.
For example:
sethi %hi(symbol), %g1
or %g1, %lo(symbol), %g1
Several relocations exist to allow the link editor to potentially optimize GOT data refer-
ences. The R_SPARC_GOTDATA_OP_HIX22 relocation can obtained by enclosing an operand
inside of ‘%gdop_hix22’. The R_SPARC_GOTDATA_OP_LOX10 relocation can obtained by en-
closing an operand inside of ‘%gdop_lox10’. Likewise, R_SPARC_GOTDATA_OP can be ob-
tained by enclosing an operand inside of ‘%gdop’. For example, assuming the GOT base is
in register %l7:
sethi %gdop_hix22(symbol), %l1
xor %l1, %gdop_lox10(symbol), %l1
ld [%l7 + %l1], %l2, %gdop(symbol)
There are many relocations that can be requested for access to thread local storage
variables. All of the Sparc TLS mnemonics are supported:
• R_SPARC_TLS_GD_HI22 is requested using ‘%tgd_hi22’.
• R_SPARC_TLS_GD_LO10 is requested using ‘%tgd_lo10’.
• R_SPARC_TLS_GD_ADD is requested using ‘%tgd_add’.
• R_SPARC_TLS_GD_CALL is requested using ‘%tgd_call’.
• R_SPARC_TLS_LDM_HI22 is requested using ‘%tldm_hi22’.
• R_SPARC_TLS_LDM_LO10 is requested using ‘%tldm_lo10’.
• R_SPARC_TLS_LDM_ADD is requested using ‘%tldm_add’.
• R_SPARC_TLS_LDM_CALL is requested using ‘%tldm_call’.
• R_SPARC_TLS_LDO_HIX22 is requested using ‘%tldo_hix22’.
• R_SPARC_TLS_LDO_LOX10 is requested using ‘%tldo_lox10’.
• R_SPARC_TLS_LDO_ADD is requested using ‘%tldo_add’.
• R_SPARC_TLS_IE_HI22 is requested using ‘%tie_hi22’.
• R_SPARC_TLS_IE_LO10 is requested using ‘%tie_lo10’.
• R_SPARC_TLS_IE_LD is requested using ‘%tie_ld’.
• R_SPARC_TLS_IE_LDX is requested using ‘%tie_ldx’.
• R_SPARC_TLS_IE_ADD is requested using ‘%tie_add’.
• R_SPARC_TLS_LE_HIX22 is requested using ‘%tle_hix22’.
• R_SPARC_TLS_LE_LOX10 is requested using ‘%tle_lox10’.
Here are some example TLS model sequences.
First, General Dynamic:
sethi %tgd_hi22(symbol), %l1
add %l1, %tgd_lo10(symbol), %l1
add %l7, %l1, %o0, %tgd_add(symbol)
call __tls_get_addr, %tgd_call(symbol)
nop
Local Dynamic:
sethi %tldm_hi22(symbol), %l1
add %l1, %tldm_lo10(symbol), %l1
add %l7, %l1, %o0, %tldm_add(symbol)
call __tls_get_addr, %tldm_call(symbol)
Chapter 9: Machine Dependent Features 325
nop
st %o1, [%o0]
sta %o2, [%o0] %asi
sll %o3, 3, %o3
srl %o4, 8, %o4
sra %o5, 12, %o5
cas [%o0], %o1, %o2
casa [%o0] %asi, %o1, %o2
clr %g1
And in 64-bit mode as will emit:
ldx [%o0], %o1
ldxa [%o0] %asi, %o2
stx %o1, [%o0]
stxa %o2, [%o0] %asi
sllx %o3, 3, %o3
srlx %o4, 8, %o4
srax %o5, 12, %o5
casx [%o0], %o1, %o2
casxa [%o0] %asi, %o1, %o2
clrx %g1
Finally, the ‘.nword’ translating directive is supported as well. It is documented in the
section on Sparc machine directives.
.reserve This must be followed by a symbol name, a positive number, and "bss". This
behaves somewhat like .lcomm, but the syntax is different.
.seg This must be followed by "text", "data", or "data1". It behaves like .text,
.data, or .data 1.
.skip This is functionally identical to the .space directive.
.word On the Sparc, the .word directive produces 32 bit values, instead of the 16 bit
values it produces on many other machines.
.xword On the Sparc V9 processor, the .xword directive produces 64 bit values.
328 Using as
9.45.2 Blocking
A blocked section or memory block is guaranteed not to cross the blocking boundary (usually
a page, or 128 words) if it is smaller than the blocking size, or to start on a page boundary
if it is larger than the blocking size.
.asg "SYM1",SYM2
.asg "SYM2",x
add x,a ; final code assembled is "add x, a"
Macro parameters are converted to subsyms; a side effect of this is the normal as ’\ARG’
dereferencing syntax is unnecessary. Subsyms defined within a macro will have global
scope, unless the .var directive is used to identify the subsym as a local macro variable see
Section 9.45.9 [.var], page 331.
Substitution may be forced in situations where replacement might be ambiguous by
placing colons on either side of the subsym. The following code:
.eval "10",x
LAB:X: add #x, a
When assembled becomes:
LAB10 add #10, a
Smaller parts of the string assigned to a subsym may be accessed with the following
syntax:
:symbol(char_index):
Evaluates to a single-character string, the character at char index.
:symbol(start,length):
Evaluates to a substring of symbol beginning at start with length length.
$atan2(expr1,expr2)
Returns the floating point arctangent of expr1 / expr2.
$ceil(expr)
Returns the smallest integer not less than expr as floating point.
$cosh(expr)
Returns the floating point hyperbolic cosine of expr.
$cos(expr)
Returns the floating point cosine of expr.
$cvf(expr)
Returns the integer value expr converted to floating-point.
$cvi(expr)
Returns the floating point value expr converted to integer.
$exp(expr)
Returns the floating point value e ^ expr.
$fabs(expr)
Returns the floating point absolute value of expr.
$floor(expr)
Returns the largest integer that is not greater than expr as floating point.
$fmod(expr1,expr2)
Returns the floating point remainder of expr1 / expr2.
$int(expr)
Returns 1 if expr evaluates to an integer, zero otherwise.
$ldexp(expr1,expr2)
Returns the floating point value expr1 * 2 ^ expr2.
$log10(expr)
Returns the base 10 logarithm of expr.
$log(expr)
Returns the natural logarithm of expr.
$max(expr1,expr2)
Returns the floating point maximum of expr1 and expr2.
$min(expr1,expr2)
Returns the floating point minimum of expr1 and expr2.
$pow(expr1,expr2)
Returns the floating point value expr1 ^ expr2.
$round(expr)
Returns the nearest integer to expr as a floating point number.
$sgn(expr)
Returns -1, 0, or 1 based on the sign of expr.
Chapter 9: Machine Dependent Features 331
$sin(expr)
Returns the floating point sine of expr.
$sinh(expr)
Returns the floating point hyperbolic sine of expr.
$sqrt(expr)
Returns the floating point square root of expr.
$tan(expr)
Returns the floating point tangent of expr.
$tanh(expr)
Returns the floating point hyperbolic tangent of expr.
$trunc(expr)
Returns the integer value of expr truncated towards zero as floating point.
9.45.9 Directives
.align [size]
.even Align the section program counter on the next boundary, based on size. size
may be any power of 2. .even is equivalent to .align with a size of 2.
1 Align SPC to word boundary
2 Align SPC to longword boundary (same as .even)
128 Align SPC to page boundary
.asg string, name
Assign name the string string. String replacement is performed on string before
assignment.
.eval string, name
Evaluate the contents of string string and assign the result as a string to the
subsym name. String replacement is performed on string before assignment.
.bss symbol, size [, [blocking_flag] [,alignment_flag]]
Reserve space for symbol in the .bss section. size is in words. If present, block-
ing flag indicates the allocated space should be aligned on a page boundary if
it would otherwise cross a page boundary. If present, alignment flag causes the
assembler to allocate size on a long word boundary.
332 Using as
bits, the value will be truncated. Successive .field directives will pack starting
at the current word, filling the most significant bits first, and aligning to the
start of the next word if the field size does not fit into the space remaining in
the current word. A .align directive with an operand of 1 will force the next
.field directive to begin packing into a new word. If a label is used, it points
to the word that contains the specified field.
.label symbol
Define a special symbol to refer to the load time address of the current section
program counter.
.length
.width Set the page length and width of the output listing file. Ignored.
.list
.nolist Control whether the source listing is printed. Ignored.
.loop [count]
.break [condition]
.endloop Repeatedly assemble a block of code. .loop begins the block, and .endloop
marks its termination. count defaults to 1024, and indicates the number of times
the block should be repeated. .break terminates the loop so that assembly
begins after the .endloop directive. The optional condition will cause the loop
to terminate only if it evaluates to zero.
334 Using as
word, filling the most-significant bits first. Unused space is zero-filled. If a label
is used, it points to the first word initialized.
[stag] .struct [offset]
[name_1] element [count_1]
[name_2] element [count_2]
[tname] .tag stagx [tcount]
...
[name_n] element [count_n]
[ssize] .endstruct
label .tag [stag]
Assign symbolic offsets to the elements of a structure. stag defines a symbol
to use to reference the structure. offset indicates a starting value to use for the
first element encountered; otherwise it defaults to zero. Each element can have
a named offset, name, which is a symbol assigned the value of the element’s
offset into the structure. If stag is missing, these become global symbols. count
adjusts the offset that many times, as if element were an array. element may
be one of .byte, .word, .long, .float, or any equivalent of those, and the
structure offset is adjusted accordingly. .field and .string are also allowed;
the size of .field is one bit, and .string is considered to be one word in
size. Only element descriptors, structure/union tags, .align and conditional
assembly directives are allowed within .struct/.endstruct. .align aligns
member offsets to word boundaries only. ssize, if provided, will always be
assigned the size of the structure.
The .tag directive, in addition to being used to define a structure/union ele-
ment within a structure, may be used to apply a structure to a symbol. Once
applied to label, the individual structure elements may be applied to label to
produce the desired offsets using label as the structure base.
.tab Set the tab size in the output listing. Ignored.
[utag] .union
[name_1] element [count_1]
[name_2] element [count_2]
[tname] .tag utagx[,tcount]
...
[name_n] element [count_n]
[usize] .endstruct
label .tag [utag]
Similar to .struct, but the offset after each element is reset to zero, and the
usize is set to the maximum of all defined elements. Starting offset for the
union is always zero.
[symbol] .usect "section_name", size, [,[blocking_flag] [,alignment_flag]]
Reserve space for variables in a named, uninitialized section (similar to .bss).
.usect allows definitions sections independent of .bss. symbol points to the
first location reserved by this allocation. The symbol may be used as a variable
name. size is the allocated size in words. blocking flag indicates whether to
block this section on a page boundary (128 words) (see Section 9.45.2 [TIC54X-
336 Using as
Block], page 328). alignment flag indicates whether the section should be
longword-aligned.
.var sym[,..., sym_n]
Define a subsym to be a local variable within a macro. See See Section 9.45.10
[TIC54X-Macros], page 336.
.version version
Set which processor to build instructions for. Though the following values are
accepted, the op is ignored.
541
542
543
545
545LP
546LP
548
549
9.45.10 Macros
Macros do not require explicit dereferencing of arguments (i.e., \ARG).
During macro expansion, the macro parameters are converted to subsyms. If the number
of arguments passed the macro invocation exceeds the number of parameters defined, the last
parameter is assigned the string equivalent of all remaining arguments. If fewer arguments
are given than parameters, the missing parameters are assigned empty strings. To include
a comma in an argument, you must enclose the argument in quotes.
The following built-in subsym functions allow examination of the string value of subsyms
(or ordinary strings). The arguments are strings unless otherwise indicated (subsyms passed
as args will be replaced by the strings they represent).
$symlen(str)
Returns the length of str.
$symcmp(str1,str2)
Returns 0 if str1 == str2, non-zero otherwise.
$firstch(str,ch)
Returns index of the first occurrence of character constant ch in str.
$lastch(str,ch)
Returns index of the last occurrence of character constant ch in str.
$isdefed(symbol)
Returns zero if the symbol symbol is not in the symbol table, non-zero other-
wise.
$ismember(symbol,list)
Assign the first member of comma-separated string list to symbol; list is re-
assigned the remainder of the list. Returns zero if list is a null string. Both
arguments must be subsyms.
Chapter 9: Machine Dependent Features 337
$iscons(expr)
Returns 1 if string expr is binary, 2 if octal, 3 if hexadecimal, 4 if a character,
5 if decimal, and zero if not an integer.
$isname(name)
Returns 1 if name is a valid symbol name, zero otherwise.
$isreg(reg)
Returns 1 if reg is a valid predefined register name (AR0-AR7 only).
$structsz(stag)
Returns the size of the structure or union represented by stag.
$structacc(stag)
Returns the reference point of the structure or union represented by stag. Al-
ways returns zero.
Instruction, register and functional unit names are case-insensitive. as requires fully-
specified functional unit names, such as ‘.S1’, ‘.L1X’ or ‘.D1T2’, on all instructions using a
functional unit.
For some instructions, there may be syntactic ambiguity between register or functional
unit names and the names of labels or other symbols. To avoid this, enclose the ambiguous
symbol name in parentheses; register and functional unit names may not be enclosed in
parentheses.
-m32 | -m64
Select the word size, either 32 bits or 64 bits.
-EB | -EL Select the endianness, either big-endian (-EB) or little-endian (-EL).
9.47.2 Syntax
Block comments are delimited by ‘/*’ and ‘*/’. End of line comments may be introduced
by ‘#’.
Instructions consist of a leading opcode or macro name followed by whitespace and an
optional comma-separated list of operands:
opcode [operand, ...]
A bundle can span multiple lines. If you want to put multiple instructions on a line,
whether in a bundle or not, you need to separate them with semicolons as in this example.
A bundle may contain one or more instructions, up to the limit specified by the ISA
(currently three). If fewer instructions are specified than the hardware supports in a bundle,
the assembler inserts fnop instructions automatically.
The assembler will prefer to preserve the ordering of instructions within the bundle,
putting the first instruction in a lower-numbered pipeline than the next one, etc. This fact,
combined with the optional use of explicit fnop or nop instructions, allows precise control
over which pipeline executes each instruction.
If the instructions cannot be bundled in the listed order, the assembler will automatically
try to find a valid pipeline assignment. If there is no way to bundle the instructions together,
the assembler reports an error.
The assembler does not yet auto-bundle (automatically combine multiple instructions
into one bundle), but it reserves the right to do so in the future. If you want to force an
instruction to run by itself, put it in a bundle explicitly with curly braces and use nop
instructions (not fnop) to fill the remaining pipeline slots in that bundle.
hw2_last
This modifier yields the same value as hw2, but it also checks that the value
does not overflow.
A 48-bit symbolic value is constructed by using the following idiom:
moveli r0, hw2_last(sym)
shl16insli r0, r0, hw1(sym)
shl16insli r0, r0, hw0(sym)
hw0_got
This modifier is used to load bits 0-15 of the symbol’s offset in the GOT entry
corresponding to the symbol.
hw0_last_got
This modifier yields the same value as hw0_got, but it also checks that the
value does not overflow.
hw1_last_got
This modifier is used to load bits 16-31 of the symbol’s offset in the GOT entry
corresponding to the symbol, and it also checks that the value does not overflow.
plt
This modifier is used for function symbols. It causes a procedure linkage table,
an array of code stubs, to be created at the time the shared object is created
or linked against, together with a global offset table entry. The value is a pc-
relative offset to the corresponding stub code in the procedure linkage table.
This arrangement causes the run-time symbol resolver to be called to look up
and set the value of the symbol the first time the function is called (at latest;
depending environment variables). It is only safe to leave the symbol unresolved
this way if all references are function calls.
hw0_plt
This modifier is used to load bits 0-15 of the pc-relative address of a plt entry.
hw1_plt
This modifier is used to load bits 16-31 of the pc-relative address of a plt entry.
hw1_last_plt
This modifier yields the same value as hw1_plt, but it also checks that the
value does not overflow.
hw2_last_plt
This modifier is used to load bits 32-47 of the pc-relative address of a plt entry,
and it also checks that the value does not overflow.
hw0_tls_gd
This modifier is used to load bits 0-15 of the offset of the GOT entry of the
symbol’s TLS descriptor, to be used for general-dynamic TLS accesses.
hw0_last_tls_gd
This modifier yields the same value as hw0_tls_gd, but it also checks that the
value does not overflow.
344 Using as
hw1_last_tls_gd
This modifier is used to load bits 16-31 of the offset of the GOT entry of the
symbol’s TLS descriptor, to be used for general-dynamic TLS accesses. It also
checks that the value does not overflow.
hw0_tls_ie
This modifier is used to load bits 0-15 of the offset of the GOT entry containing
the offset of the symbol’s address from the TCB, to be used for initial-exec TLS
accesses.
hw0_last_tls_ie
This modifier yields the same value as hw0_tls_ie, but it also checks that the
value does not overflow.
hw1_last_tls_ie
This modifier is used to load bits 16-31 of the offset of the GOT entry containing
the offset of the symbol’s address from the TCB, to be used for initial-exec TLS
accesses. It also checks that the value does not overflow.
hw0_tls_le
This modifier is used to load bits 0-15 of the offset of the symbol’s address from
the TCB, to be used for local-exec TLS accesses.
hw0_last_tls_le
This modifier yields the same value as hw0_tls_le, but it also checks that the
value does not overflow.
hw1_last_tls_le
This modifier is used to load bits 16-31 of the offset of the symbol’s address
from the TCB, to be used for local-exec TLS accesses. It also checks that the
value does not overflow.
tls_gd_call
This modifier is used to tag an instruction as the “call” part of a calling sequence
for a TLS GD reference of its operand.
tls_gd_add
This modifier is used to tag an instruction as the “add” part of a calling sequence
for a TLS GD reference of its operand.
tls_ie_load
This modifier is used to tag an instruction as the “load” part of a calling
sequence for a TLS IE reference of its operand.
.no_allow_suspicious_bundles
Turns off error checking for combinations of instructions in a bundle that prob-
ably indicate a programming error.
.require_canonical_reg_names
Require that canonical register names be used, and emit a warning if the nu-
meric names are used. This is on by default.
.no_require_canonical_reg_names
Permit the use of numeric names for registers that have canonical names.
346 Using as
9.48.2 Syntax
Block comments are delimited by ‘/*’ and ‘*/’. End of line comments may be introduced
by ‘#’.
Instructions consist of a leading opcode or macro name followed by whitespace and an
optional comma-separated list of operands:
opcode [operand, ...]
Instructions must be separated by a newline or semicolon.
There are two ways to write code: either write naked instructions, which the assembler
is free to combine into VLIW bundles, or specify the VLIW bundles explicitly.
Bundles are specified using curly braces:
{ add r3,r4,r5 ; add r7,r8,r9 ; lw r10,r11 }
A bundle can span multiple lines. If you want to put multiple instructions on a line,
whether in a bundle or not, you need to separate them with semicolons as in this example.
A bundle may contain one or more instructions, up to the limit specified by the ISA
(currently three). If fewer instructions are specified than the hardware supports in a bundle,
the assembler inserts fnop instructions automatically.
The assembler will prefer to preserve the ordering of instructions within the bundle,
putting the first instruction in a lower-numbered pipeline than the next one, etc. This fact,
combined with the optional use of explicit fnop or nop instructions, allows precise control
over which pipeline executes each instruction.
If the instructions cannot be bundled in the listed order, the assembler will automatically
try to find a valid pipeline assignment. If there is no way to bundle the instructions together,
the assembler reports an error.
The assembler does not yet auto-bundle (automatically combine multiple instructions
into one bundle), but it reserves the right to do so in the future. If you want to force an
instruction to run by itself, put it in a bundle explicitly with curly braces and use nop
instructions (not fnop) to fill the remaining pipeline slots in that bundle.
r56 sn
r57 idn0
r58 idn1
r59 udn0
r60 udn1
r61 udn2
r62 udn3
r63 zero
The assembler will emit a warning if a numeric name is used instead of the canonical
name. The .no_require_canonical_reg_names assembler pseudo-op turns off this warn-
ing. .require_canonical_reg_names turns it back on.
got
This modifier is used to load the offset of the GOT entry corresponding to the
symbol.
got_lo16
This modifier is used to load the sign-extended low 16 bits of the offset of the
GOT entry corresponding to the symbol.
got_hi16
This modifier is used to load the sign-extended high 16 bits of the offset of the
GOT entry corresponding to the symbol.
348 Using as
got_ha16
This modifier is like got_hi16, but it adds one if got_lo16 of the input value
is negative.
plt
This modifier is used for function symbols. It causes a procedure linkage table,
an array of code stubs, to be created at the time the shared object is created
or linked against, together with a global offset table entry. The value is a pc-
relative offset to the corresponding stub code in the procedure linkage table.
This arrangement causes the run-time symbol resolver to be called to look up
and set the value of the symbol the first time the function is called (at latest;
depending environment variables). It is only safe to leave the symbol unresolved
this way if all references are function calls.
tls_gd
This modifier is used to load the offset of the GOT entry of the symbol’s TLS
descriptor, to be used for general-dynamic TLS accesses.
tls_gd_lo16
This modifier is used to load the sign-extended low 16 bits of the offset of the
GOT entry of the symbol’s TLS descriptor, to be used for general dynamic TLS
accesses.
tls_gd_hi16
This modifier is used to load the sign-extended high 16 bits of the offset of the
GOT entry of the symbol’s TLS descriptor, to be used for general dynamic TLS
accesses.
tls_gd_ha16
This modifier is like tls_gd_hi16, but it adds one to the value if tls_gd_lo16
of the input value is negative.
tls_ie
This modifier is used to load the offset of the GOT entry containing the offset
of the symbol’s address from the TCB, to be used for initial-exec TLS accesses.
tls_ie_lo16
This modifier is used to load the low 16 bits of the offset of the GOT entry
containing the offset of the symbol’s address from the TCB, to be used for
initial-exec TLS accesses.
tls_ie_hi16
This modifier is used to load the high 16 bits of the offset of the GOT entry
containing the offset of the symbol’s address from the TCB, to be used for
initial-exec TLS accesses.
tls_ie_ha16
This modifier is like tls_ie_hi16, but it adds one to the value if tls_ie_lo16
of the input value is negative.
tls_le
Chapter 9: Machine Dependent Features 349
This modifier is used to load the offset of the symbol’s address from the TCB,
to be used for local-exec TLS accesses.
tls_le_lo16
This modifier is used to load the low 16 bits of the offset of the symbol’s address
from the TCB, to be used for local-exec TLS accesses.
tls_le_hi16
This modifier is used to load the high 16 bits of the offset of the symbol’s
address from the TCB, to be used for local-exec TLS accesses.
tls_le_ha16
This modifier is like tls_le_hi16, but it adds one to the value if tls_le_lo16
of the input value is negative.
tls_gd_call
This modifier is used to tag an instruction as the “call” part of a calling sequence
for a TLS GD reference of its operand.
tls_gd_add
This modifier is used to tag an instruction as the “add” part of a calling sequence
for a TLS GD reference of its operand.
tls_ie_load
This modifier is used to tag an instruction as the “load” part of a calling
sequence for a TLS IE reference of its operand.
-wsigned_overflow
Causes warnings to be produced when signed immediate values overflow the
space available for then within their opcodes. By default this option is disabled
as it is possible to receive spurious warnings due to using exact bit patterns as
immediate constants.
-wunsigned_overflow
Causes warnings to be produced when unsigned immediate values overflow the
space available for then within their opcodes. By default this option is disabled
as it is possible to receive spurious warnings due to using exact bit patterns as
immediate constants.
-mv850 Specifies that the assembled code should be marked as being targeted at the
V850 processor. This allows the linker to detect attempts to link such code
with code assembled for other processors.
-mv850e Specifies that the assembled code should be marked as being targeted at the
V850E processor. This allows the linker to detect attempts to link such code
with code assembled for other processors.
-mv850e1 Specifies that the assembled code should be marked as being targeted at the
V850E1 processor. This allows the linker to detect attempts to link such code
with code assembled for other processors.
-mv850any
Specifies that the assembled code should be marked as being targeted at the
V850 processor but support instructions that are specific to the extended vari-
ants of the process. This allows the production of binaries that contain target
specific code, but which are also intended to be used in a generic fashion. For
example libgcc.a contains generic routines used by the code produced by GCC
for all versions of the v850 architecture, together with support routines only
used by the V850E architecture.
-mv850e2 Specifies that the assembled code should be marked as being targeted at the
V850E2 processor. This allows the linker to detect attempts to link such code
with code assembled for other processors.
-mv850e2v3
Specifies that the assembled code should be marked as being targeted at the
V850E2V3 processor. This allows the linker to detect attempts to link such
code with code assembled for other processors.
-mv850e2v4
This is an alias for -mv850e3v5.
-mv850e3v5
Specifies that the assembled code should be marked as being targeted at the
V850E3V5 processor. This allows the linker to detect attempts to link such
code with code assembled for other processors.
-mrelax Enables relaxation. This allows the .longcall and .longjump pseudo ops to be
used in the assembler source code. These ops label sections of code which are
Chapter 9: Machine Dependent Features 351
either a long function call or a long branch. The assembler will then flag these
sections of code and the linker will attempt to relax them.
-mgcc-abi
Marks the generated object file as supporting the old GCC ABI.
-mrh850-abi
Marks the generated object file as supporting the RH850 ABI. This is the
default.
-m8byte-align
Marks the generated object file as supporting a maximum 64-bits of alignment
for variables defined in the source code.
-m4byte-align
Marks the generated object file as supporting a maximum 32-bits of alignment
for variables defined in the source code. This is the default.
-msoft-float
Marks the generated object file as not using any floating point instructions -
and hence can be linked with other V850 binaries that do or do not use floating
point. This is the default for binaries for architectures earlier than the e2v3.
-mhard-float
Marks the generated object file as one that uses floating point instructions -
and hence can only be linked with other V850 binaries that use the same kind
of floating point instructions, or with binaries that do not use floating point at
all. This is the default for binaries the e2v3 and later architectures.
9.49.2 Syntax
9.49.2.1 Special Characters
‘#’ is the line comment character. If a ‘#’ appears as the first character of a line, the whole
line is treated as a comment, but in this case the line can also be a logical line number
directive (see Section 3.3 [Comments], page 31) or a preprocessor control command (see
Section 3.1 [Preprocessing], page 31).
Two dashes (‘--’) can also be used to start a line comment.
The ‘;’ character can be used to separate statements on the same line.
general register 3
r3, sp
general register 4
r4, gp
general register 5
r5, tp
general register 6
r6
general register 7
r7
general register 8
r8
general register 9
r9
general register 10
r10
general register 11
r11
general register 12
r12
general register 13
r13
general register 14
r14
general register 15
r15
general register 16
r16
general register 17
r17
general register 18
r18
general register 19
r19
general register 20
r20
general register 21
r21
Chapter 9: Machine Dependent Features 353
general register 22
r22
general register 23
r23
general register 24
r24
general register 25
r25
general register 26
r26
general register 27
r27
general register 28
r28
general register 29
r29
general register 30
r30, ep
general register 31
r31, lp
system register 0
eipc
system register 1
eipsw
system register 2
fepc
system register 3
fepsw
system register 4
ecr
system register 5
psw
system register 16
ctpc
system register 17
ctpsw
system register 18
dbpc
354 Using as
system register 19
dbpsw
system register 20
ctbp
9.49.5 Opcodes
as implements all the standard V850 opcodes.
Chapter 9: Machine Dependent Features 355
address held in the GP register. [Note the linker assumes that the GP register
contains a fixed address set to the address of the label called ’ gp’. This can
either be set up automatically by the linker, or specifically set by using the
‘--defsym __gp=<value>’ command-line option].
tdaoff() Computes the offset of the named variable from the start of the Tiny Data Area
(whose address is held in register 30, the EP register) and stores the result as
a 4,5, 7 or 8 bit unsigned value in the immediate operand field of the given
instruction. For example:
‘sld.w tdaoff(_a_variable)[ep],r6’
loads the contents of the location pointed to by the label ’ a variable’ into
register 6, provided that the label is located somewhere within +256 bytes of
the address held in the EP register. [Note the linker assumes that the EP
register contains a fixed address set to the address of the label called ’ ep’.
This can either be set up automatically by the linker, or specifically set by
using the ‘--defsym __ep=<value>’ command-line option].
zdaoff() Computes the offset of the named variable from address 0 and stores the result
as a 16 bit signed value in the immediate operand field of the given instruction.
For example:
‘movea zdaoff(_a_variable),zero,r6’
puts the address of the label ’ a variable’ into register 6, assuming that the
label is somewhere within the first 32K of memory. (Strictly speaking it also
possible to access the last 32K of memory as well, as the offsets are signed).
ctoff() Computes the offset of the named variable from the start of the Call Table
Area (whose address is held in system register 20, the CTBP register) and
stores the result a 6 or 16 bit unsigned value in the immediate field of then
given instruction or piece of data. For example:
‘callt ctoff(table_func1)’
will put the call the function whose address is held in the call table at the
location labeled ’table func1’.
.longcall name
Indicates that the following sequence of instructions is a long call to function
name. The linker will attempt to shorten this call sequence if name is within
a 22bit offset of the call. Only valid if the -mrelax command-line switch has
been enabled.
.longjump name
Indicates that the following sequence of instructions is a long jump to label
name. The linker will attempt to shorten this code sequence if name is within
a 22bit offset of the jump. Only valid if the -mrelax command-line switch has
been enabled.
For information on the V850 instruction set, see V850 Family 32-/16-Bit single-Chip
Microcontroller Architecture Manual from NEC. Ltd.
Chapter 9: Machine Dependent Features 357
Symbols whose names include a dollar sign ‘$’ are exceptions to the general
name mapping. These symbols are normally only used to reference VMS library
names. Such symbols are always mapped to upper case.
‘-+’ The ‘-+’ option causes as to truncate any symbol name larger than 31 char-
acters. The ‘-+’ option also prevents some code following the ‘_main’ symbol
normally added to make the object file compatible with Vax-11 "C".
‘-1’ This option is ignored for backward compatibility with as version 1.x.
‘-H’ The ‘-H’ option causes as to print every symbol which was changed by case
mapping.
brb bar ;
foo: brw destination ;
bar:
(long displacement)
OPCODE ..., foo ;
brb bar ;
foo: jmp destination ;
bar:
aobleq
aoblss
sobgeq
sobgtr
(byte displacement)
OPCODE ...
(word displacement)
OPCODE ..., foo ;
brb bar ;
foo: brw destination ;
bar:
(long displacement)
OPCODE ..., foo ;
brb bar ;
foo: jmp destination ;
bar:
9.51.2 Syntax
9.51.2.1 Special Characters
Line comments are introduced either by the ‘!’ character or by the ‘;’ character appearing
anywhere on a line.
A hash character (‘#’) as the first character on a line also marks the start of a line
comment, but in this case it could also be a logical line number directive (see Section 3.3
[Comments], page 31) or a preprocessor control command (see Section 3.1 [Preprocessing],
page 31).
The Visium assembler does not currently support a line separator character.
9.51.3 Opcodes
All the standard opcodes of the architecture are implemented, along with the following
three pseudo-instructions: cmp, cmpc, move.
In addition, the following two illegal opcodes are implemented and used by the simula-
tion:
stop 5-bit immediate, SourceA
trace 5-bit immediate, SourceA
Chapter 9: Machine Dependent Features 363
9.52.2 Syntax
The assembler syntax directly encodes sequences of opcodes as defined in the WebAssembly
binary encoding specification at https://github.com/webassembly/spec/BinaryEncoding.md.
Structured sexp-style expressions are not supported as input.
9.52.2.2 Relocations
Special relocations are available by using the ‘@plt’, ‘@got’, or ‘@got’ suffixes after a constant
expression, which correspond to the R ASMJS LEB128 PLT, R ASMJS LEB128 GOT,
and R ASMJS LEB128 GOT CODE relocations, respectively.
The ‘@plt’ suffix is followed by a symbol name in braces; the symbol value is used to
determine the function signature for which a PLT stub is generated. Currently, the symbol
name is parsed from its last ‘F’ character to determine the argument count of the function,
which is also necessary for generating a PLT stub.
9.52.2.3 Signatures
Function signatures are specified with the signature pseudo-opcode, followed by a simple
function signature imitating a C++-mangled function type: F followed by an optional v,
then a sequence of i, l, f, and d characters to mark i32, i64, f32, and f64 parameters,
respectively; followed by a final E to mark the end of the function signature.
a linker script to do so may be preferable, as it doesn’t require running the entire module
through the assembler at once.
Chapter 9: Machine Dependent Features 365
9.53.2 Syntax
In XGATE RISC syntax, the instruction name comes first and it may be followed by up
to three operands. Operands are separated by commas (‘,’). as will complain if too many
operands are specified for a given instruction. The same will happen if you specified too
few operands.
nop
ldl #23
CMP R1, R2
The presence of a ‘;’ character or a ‘!’ character anywhere on a line indicates the start
of a comment that extends to the end of that line.
A ‘*’ or a ‘#’ character at the start of a line also introduces a line comment, but these
characters do not work elsewhere on the line. If the first character of the line is a ‘#’
then as well as starting a comment, the line could also be logical line number directive
(see Section 3.3 [Comments], page 31) or a preprocessor control command (see Section 3.1
[Preprocessing], page 31).
The XGATE assembler does not currently support a line separator character.
The following addressing modes are understood for XGATE:
Inherent ‘’
Immediate 3 Bit Wide
‘#number’
Immediate 4 Bit Wide
‘#number’
366 Using as
9.53.5 Opcodes
page 372. This option should be used when call targets can potentially be out
of range. It may degrade both code size and performance, but the linker can
generally optimize away the unnecessary overhead when a call ends up within
range. The default is ‘--no-longcalls’.
--transform | --no-transform
Enable or disable all assembler transformations of Xtensa instructions,
including both relaxation and optimization. The default is ‘--transform’;
‘--no-transform’ should only be used in the rare cases when the instructions
must be exactly as specified in the assembly source. Using ‘--no-transform’
causes out of range instruction operands to be errors.
--rename-section oldname=newname
Rename the oldname section to newname. This option can be used multiple
times to rename multiple sections.
--trampolines | --no-trampolines
Enable or disable transformation of jump instructions to allow jumps across a
greater range of addresses. See Section 9.55.4.3 [Jump Trampolines], page 373.
This option should be used when jump targets can potentially be out of range.
In the absence of such jumps this option does not affect code size or perfor-
mance. The default is ‘--trampolines’.
--abi-windowed | --abi-call0
Choose ABI tag written to the .xtensa.info section. ABI tag indicates ABI
of the assembly code. A warning is issued by the linker on an attempt to link
object files with inconsistent ABI tags. Default ABI is chosen by the Xtensa
core configuration.
The opcodes in a FLIX instruction are listed in the same order as the corresponding
instruction slots in the TIE format declaration. Directives and labels are not allowed inside
the braces of a FLIX instruction. A particular TIE format name can optionally be specified
immediately after the opening brace, but this is usually unnecessary. The assembler will
automatically search for a format that can encode the specified opcodes, so the format name
need only be specified in rare cases where there is more than one applicable format and
where it matters which of those formats is used. A FLIX instruction can also be specified
on a single line by separating the opcodes with semicolons:
{ [format;] opcode0 [operands]; opcode1 [operands]; opcode2 [operands]; ... }
If an opcode can only be encoded in a FLIX instruction but is not specified as part of
a FLIX bundle, the assembler will choose the smallest format where the opcode can be
encoded and will fill unused instruction slots with no-ops.
Because the addresses of targets of function calls are not generally known until link-time,
the assembler must assume the worst and relax all the calls to functions in other source
files, not just those that really will be out of range. The linker can recognize calls that
were unnecessarily relaxed, and it will remove the overhead introduced by the assembler for
those cases where direct calls are sufficient.
Call relaxation is disabled by default because it can have a negative effect on both code
size and performance, although the linker can usually eliminate the unnecessary overhead.
If a program is too large and some of the calls are out of range, function call relaxation can
be enabled using the ‘--longcalls’ command-line option or the longcalls directive (see
Section 9.55.5.2 [longcalls], page 376).
j 1f
...
retw
...
mov a10, a2
call8 func
...
1:
...
j .L0_TR_1
...
retw
.L0_TR_1:
j 1f
...
mov a10, a2
call8 func
...
1:
...
or to:
374 Using as
j .L0_TR_1
...
retw
...
mov a10, a2
j .L0_TR_0
.L0_TR_1:
j 1f
.L0_TR_0:
call8 func
...
1:
...
The Xtensa assembler uses trampolines with jump around only when it cannot find
suitable unreachable trampoline. There may be multiple trampolines between the jump
instruction and its target.
This relaxation does not apply to jumps to undefined symbols, assuming they will reach
their targets once resolved.
Jump relaxation is enabled by default because it does not affect code size or
performance while the code itself is small. This relaxation may be disabled completely
with ‘--no-trampolines’ or ‘--no-transform’ command-line options (see Section 9.55.1
[Command-line Options], page 368).
The Xtensa ADDI instruction only allows immediate operands in the range from -128 to
127. There are a number of alternate instruction sequences for the ADDI operation. First,
if the immediate is 0, the ADDI will be turned into a MOV.N instruction (or the equivalent
OR instruction if the code density option is not available). If the ADDI immediate is outside
of the range -128 to 127, but inside the range -32896 to 32639, an ADDMI instruction or
ADDMI/ADDI sequence will be used. Finally, if the immediate is outside of this range and a
free register is available, an L32R/ADD sequence will be used with a literal allocated from
the literal pool.
For example:
addi a5, a6, 0
addi a5, a6, 512
addi a5, a6, 513
addi a5, a6, 50000
is assembled into the following:
.literal .L1, 50000
mov.n a5, a6
addmi a5, a6, 0x200
addmi a5, a6, 0x200
addi a5, a5, 1
l32r a5, .L1
add a5, a6, a5
9.55.5 Directives
The Xtensa assembler supports a region-based directive syntax:
.begin directive [options]
...
.end directive
All the Xtensa-specific directives that apply to a region of code use this syntax.
The directive applies to code between the .begin and the .end. The state of the option
after the .end reverts to what it was before the .begin. A nested .begin/.end region can
further change the state of the directive without having to be aware of its outer state. For
example, consider:
.begin no-transform
L: add a0, a1, a2
.begin transform
M: add a0, a1, a2
.end transform
N: add a0, a1, a2
.end no-transform
The ADD opcodes at L and N in the outer no-transform region both result in ADD machine
instructions, but the assembler selects an ADD.N instruction for the ADD at M in the inner
transform region.
The advantage of this style is that it works well inside macros which can preserve the
context of their callers.
The following directives are available:
9.55.5.1 schedule
The schedule directive is recognized only for compatibility with Tensilica’s assembler.
.begin [no-]schedule
.end [no-]schedule
376 Using as
9.55.5.2 longcalls
The longcalls directive enables or disables function call relaxation. See Section 9.55.4.2
[Function Call Relaxation], page 372.
.begin [no-]longcalls
.end [no-]longcalls
Call relaxation is disabled by default unless the ‘--longcalls’ command-line option is
specified. The longcalls directive overrides the default determined by the command-line
options.
9.55.5.3 transform
This directive enables or disables all assembler transformation, including relaxation (see
Section 9.55.4 [Xtensa Relaxation], page 372) and optimization (see Section 9.55.3 [Xtensa
Optimizations], page 371).
.begin [no-]transform
.end [no-]transform
Transformations are enabled by default unless the ‘--no-transform’ option is used. The
transform directive overrides the default determined by the command-line options. An
underscore opcode prefix, disabling transformation of that opcode, always takes precedence
over both directives and command-line flags.
9.55.5.4 literal
The .literal directive is used to define literal pool data, i.e., read-only 32-bit data accessed
via L32R instructions.
.literal label, value[, value...]
This directive is similar to the standard .word directive, except that the actual location
of the literal data is determined by the assembler and linker, not by the position of the
.literal directive. Using this directive gives the assembler freedom to locate the literal
data in the most appropriate place and possibly to combine identical literals. For example,
the code:
entry sp, 40
.literal .L1, sym
l32r a4, .L1
can be used to load a pointer to the symbol sym into register a4. The value of sym will
not be placed between the ENTRY and L32R instructions; instead, the assembler puts the
data in a literal pool.
Literal pools are placed by default in separate literal sections; however, when using the
‘--text-section-literals’ option (see Section 9.55.1 [Command-line Options], page 368),
the literal pools for PC-relative mode L32R instructions are placed in the current section.1
These text section literal pools are created automatically before ENTRY instructions and man-
ually after ‘.literal_position’ directives (see Section 9.55.5.5 [literal position], page 377).
If there are no preceding ENTRY instructions, explicit .literal_position directives must
be used to place the text section literal pools; otherwise, as will report an error.
1
Literals for the .init and .fini sections are always placed in separate sections, even when ‘--text-
section-literals’ is enabled.
Chapter 9: Machine Dependent Features 377
When literals are placed in separate sections, the literal section names are derived from
the names of the sections where the literals are defined. The base literal section names are
.literal for PC-relative mode L32R instructions and .lit4 for absolute mode L32R in-
structions (see Section 9.55.5.7 [absolute-literals], page 378). These base names are used for
literals defined in the default .text section. For literals defined in other sections or within
the scope of a literal_prefix directive (see Section 9.55.5.6 [literal prefix], page 378), the
following rules determine the literal section name:
1. If the current section is a member of a section group, the literal section name includes
the group name as a suffix to the base .literal or .lit4 name, with a period to
separate the base name and group name. The literal section is also made a member of
the group.
2. If the current section name (or literal_prefix value) begins with
“.gnu.linkonce.kind.”, the literal section name is formed by replacing
“.kind” with the base .literal or .lit4 name. For example, for literals
defined in a section named .gnu.linkonce.t.func, the literal section will be
.gnu.linkonce.literal.func or .gnu.linkonce.lit4.func.
3. If the current section name (or literal_prefix value) ends with .text, the literal
section name is formed by replacing that suffix with the base .literal or .lit4 name.
For example, for literals defined in a section named .iram0.text, the literal section
will be .iram0.literal or .iram0.lit4.
4. If none of the preceding conditions apply, the literal section name is formed by adding
the base .literal or .lit4 name as a suffix to the current section name (or literal_
prefix value).
.literal_position
.align 4
continue:
movi a4, M
9.55.5.7 absolute-literals
The absolute-literals and no-absolute-literals directives control the absolute vs.
PC-relative mode for L32R instructions. These are relevant only for Xtensa configurations
that include the absolute addressing option for L32R instructions.
.begin [no-]absolute-literals
.end [no-]absolute-literals
These directives do not change the L32R mode—they only cause the assembler to emit
the appropriate kind of relocation for L32R instructions and to place the literal values in
the appropriate section. To change the L32R mode, the program must write the LITBASE
special register. It is the programmer’s responsibility to keep track of the mode and indicate
to the assembler which mode is used in each region of code.
If the Xtensa configuration includes the absolute L32R addressing option, the default is
to assume absolute L32R addressing unless the ‘--no-absolute-literals’ command-line
option is specified. Otherwise, the default is to assume PC-relative L32R addressing. The
absolute-literals directive can then be used to override the default determined by the
command-line options.
Chapter 9: Machine Dependent Features 379
-local-prefix=prefix
Mark all labels with specified prefix as local. But such label can be marked
global explicitly in the code. This option do not change default local label
prefix .L, it is just adds new one.
-colonless
Accept colonless labels. All symbols at line begin are treated as labels.
-fp-s=FORMAT
Single precision floating point numbers format. Default: ieee754 (32 bit).
-fp-d=FORMAT
Double precision floating point numbers format. Default: ieee754 (64 bit).
math48 48 bit floating point format from Math48 package by Anders Hejlsberg.
380 Using as
9.56.2 Syntax
The assembler syntax closely follows the ’Z80 family CPU User Manual’ by Zilog. In
expressions a single ‘=’ may be used as “is equal to” comparison operator.
Suffices can be used to indicate the radix of integer constants; ‘H’ or ‘h’ for hexadecimal,
‘D’ or ‘d’ for decimal, ‘Q’, ‘O’, ‘q’ or ‘o’ for octal, and ‘B’ for binary.
The suffix ‘b’ denotes a backreference to local label.
9.56.2.4 Labels
Labels started by .L acts as local labels. You may specify custom local label prefix by
-local-prefix command-line option. Dollar, forward and backward local labels are sup-
ported. By default, all labels are followed by colon. Legacy code with colonless labels can
be built with -colonless command-line option specified. In this case all tokens at line
begin are treated as labels.
xref name
A synonym for .extern (Section 7.35 [.extern], page 62).
9.56.5 Opcodes
In line with common practice, Z80 mnemonics are used for the Z80, Z80N, Z180, eZ80, Ascii
R800 and the GameBoy Z80.
In many instructions it is possible to use one of the half index registers
(‘ixl’,‘ixh’,‘iyl’,‘iyh’) in stead of an 8-bit general purpose register. This yields
instructions that are documented on the eZ80 and the R800, undocumented on the
Z80 and unsupported on the Z180. Similarly in f,(c) is documented on the R800,
undocumented on the Z80 and unsupported on the Z180 and the eZ80.
The assembler also supports the following undocumented Z80-instructions, that have not
been adopted in any other instruction set:
out (c),0 Sends zero to the port pointed to by register C.
sli m Equivalent to m = (m<<1)+1, the operand m can be any operand that is valid
for ‘sla’. One can use ‘sll’ as a synonym for ‘sli’.
op (ix+d), r
This is equivalent to
ld r, (ix+d)
op r
ld (ix+d), r
The operation ‘op’ may be any of ‘res b,’, ‘set b,’, ‘rl’, ‘rlc’, ‘rr’, ‘rrc’,
‘sla’, ‘sli’, ‘sra’ and ‘srl’, and the register ‘r’ may be any of ‘a’, ‘b’, ‘c’, ‘d’,
‘e’, ‘h’ and ‘l’.
op (iy+d), r
As above, but with ‘iy’ instead of ‘ix’.
The web site at http://www.z80.info is a good starting place to find more information
on programming the Z80.
You may enable or disable any of these instructions for any target CPU even this in-
struction is not supported by any real CPU of this type. Useful for custom CPU cores.
Chapter 9: Machine Dependent Features 383
9.57.1 Options
-z8001 Generate segmented code by default.
9.57.2 Syntax
9.57.2.1 Special Characters
‘!’ is the line comment character.
If a ‘#’ appears as the first character of a line then the whole line is treated as a comment,
but in this case the line could also be a logical line number directive (see Section 3.3
[Comments], page 31) or a preprocessor control command (see Section 3.1 [Preprocessing],
page 31).
You can use ‘;’ instead of a newline to separate statements.
word registers
r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15
rln
rhn
rn
rrn
rqn Register direct: 8bit, 16bit, 32bit, and 64bit registers.
@rn
@rrn Indirect register: @rrn in segmented mode, @rn in unsegmented mode.
addr Direct: the 16 bit or 24 bit address (depending on whether the assembler is in
segmented or unsegmented mode) of the operand is in the instruction.
address(rn)
Indexed: the 16 or 24 bit address is added to the 16 bit register to produce the
final address in memory of the operand.
rn(#imm)
rrn(#imm)
Base Address: the 16 or 24 bit register is added to the 16 bit sign extended
immediate displacement to produce the final address in memory of the operand.
rn(rm)
rrn(rm) Base Index: the 16 or 24 bit register rn or rrn is added to the sign extended 16
bit index register rm to produce the final address in memory of the operand.
#xx Immediate data xx.
9.57.4 Opcodes
For detailed information on the Z8000 machine instruction set, see Z8000 Technical Manual.
387
10 Reporting Bugs
Your bug reports play an essential role in making as reliable.
Reporting a bug may help you by bringing a solution to your problem, or it may not.
But in any case the principal function of a bug report is to help the entire community
by making the next version of as work better. Bug reports are your contribution to the
maintenance of as.
In order for a bug report to serve its purpose, you must include the information that
enables us to fix the bug.
enable us to investigate. You might as well expedite matters by sending them to begin
with.
To enable us to fix the bug, you should include all these things:
• The version of as. as announces it if you start it with the ‘--version’ argument.
Without this, we will not know whether there is any point in looking for the bug in the
current version of as.
• Any patches you may have applied to the as source.
• The type of machine you are using, and the operating system name and version number.
• What compiler (and its version) was used to compile as—e.g. “gcc-2.7”.
• The command arguments you gave the assembler to assemble your example and observe
the bug. To guarantee you will not omit something important, list them all. A copy
of the Makefile (or the output from make) is sufficient.
If we were to try to guess the arguments, we would probably guess wrong and then we
might not encounter the bug.
• A complete input file that will reproduce the bug. If the bug is observed when the
assembler is invoked via a compiler, send the assembler source, not the high level
language source. Most compilers will produce the assembler source when run with the
‘-S’ option. If you are using gcc, use the options ‘-v --save-temps’; this will save the
assembler source in a file with an extension of .s, and also show you exactly how as is
being run.
• A description of what behavior you observe that you believe is incorrect. For example,
“It gets a fatal signal.”
Of course, if the bug is that as gets a fatal signal, then we will certainly notice it. But
if the bug is incorrect output, we might not notice unless it is glaringly wrong. You
might as well not give us a chance to make a mistake.
Even if the problem you experience is a fatal signal, you should still say so explicitly.
Suppose something strange is going on, such as, your copy of as is out of sync, or you
have encountered a bug in the C library on your system. (This has happened!) Your
copy might crash and ours would not. If you told us to expect a crash, then when ours
fails to crash, we would know that the bug was not happening for us. If you had not
told us to expect a crash, then we would not be able to draw any conclusion from our
observations.
• If you wish to suggest changes to the as source, send us context diffs, as generated by
diff with the ‘-u’, ‘-c’, or ‘-p’ option. Always send diffs from the old file to the new
file. If you even discuss something in the as source, refer to it by context, not by line
number.
The line numbers in our development sources will not match those in your sources.
Your line numbers would convey no useful information to us.
Here are some things that are not necessary:
• A description of the envelope of the bug.
Often people who encounter a bug spend a lot of time investigating which changes to
the input file will make the bug go away and which changes will not affect it.
389
This is often time consuming and not very useful, because the way we will find the
bug is by running a single example under the debugger with breakpoints, not by pure
deduction from a series of examples. We recommend that you save your time for
something else.
Of course, if you can find a simpler example to report instead of the original one, that
is a convenience for us. Errors in the output will be easier to spot, running under the
debugger will take less time, and so on.
However, simplification is not vital; if you do not want to do this, report the bug
anyway and send us the entire test case you used.
• A patch for the bug.
A patch for the bug does help us if it is a good one. But do not omit the necessary
information, such as the test case, on the assumption that a patch is all we need. We
might see problems with your patch and decide to fix the problem another way, or we
might not understand it at all.
Sometimes with a program as complicated as as it is very hard to construct an example
that will make the program follow a certain path through the code. If you do not send
us the example, we will not be able to construct one, so we will not be able to verify
that the bug is fixed.
And if we cannot understand what bug you are trying to fix, or why your patch should
be an improvement, we will not install it. A test case will help us to understand.
• A guess about what the bug is or what it depends on.
Such guesses are usually wrong. Even we cannot guess right about such things without
first using the debugger to find the facts.
391
11 Acknowledgements
If you have contributed to GAS and your name isn’t listed here, it is not meant as a slight.
We just don’t know about it. Send mail to the maintainer, and we’ll correct the situation.
Currently the maintainer is Nick Clifton (email address [email protected]).
Dean Elsner wrote the original gnu assembler for the VAX.1
Jay Fenlason maintained GAS for a while, adding support for GDB-specific debug infor-
mation and the 68k series machines, most of the preprocessing pass, and extensive changes
in messages.c, input-file.c, write.c.
K. Richard Pixley maintained GAS for a while, adding various enhancements and many
bug fixes, including merging support for several processors, breaking GAS up to handle
multiple object file format back ends (including heavy rewrite, testing, an integration of
the coff and b.out back ends), adding configuration including heavy testing and verifica-
tion of cross assemblers and file splits and renaming, converted GAS to strictly ANSI C
including full prototypes, added support for m680[34]0 and cpu32, did considerable work
on i960 including a COFF port (including considerable amounts of reverse engineering),
a SPARC opcode file rewrite, DECstation, rs6000, and hp300hpux host ports, updated
“know” assertions and made them work, much other reorganization, cleanup, and lint.
Ken Raeburn wrote the high-level BFD interface code to replace most of the code in
format-specific I/O modules.
The original VMS support was contributed by David L. Kashtan. Eric Youngdale has
done much work with it since.
The Intel 80386 machine description was written by Eliot Dresselhaus.
Minh Tran-Le at IntelliCorp contributed some AIX 386 support.
The Motorola 88k machine description was contributed by Devon Bowen of Buffalo
University and Torbjorn Granlund of the Swedish Institute of Computer Science.
Keith Knowles at the Open Software Foundation wrote the original MIPS back end
(tc-mips.c, tc-mips.h), and contributed Rose format support (which hasn’t been merged
in yet). Ralph Campbell worked with the MIPS code to support a.out format.
Support for the Zilog Z8k and Renesas H8/300 processors (tc-z8k, tc-h8300), and IEEE
695 object file format (obj-ieee), was written by Steve Chamberlain of Cygnus Support.
Steve also modified the COFF back end to use BFD for some low-level operations, for use
with the H8/300 and AMD 29k targets.
John Gilmore built the AMD 29000 support, added .include support, and simplified
the configuration of which versions accept which directives. He updated the 68k machine
description so that Motorola’s opcodes always produced fixed-size instructions (e.g., jsr),
while synthetic instructions remained shrinkable (jbsr). John fixed many bugs, including
true tested cross-compilation support, and one bug in relaxation that took a week and
required the proverbial one-bit fix.
Ian Lance Taylor of Cygnus Support merged the Motorola and MIT syntax for the 68k,
completed support for some COFF targets (68k, i386 SVR3, and SCO Unix), added support
for MIPS ECOFF and ELF targets, wrote the initial RS/6000 and PowerPC assembler, and
made a few other minor patches.
1
Any more details?
392 Using as
under this License. If a section does not fit the above definition of Secondary then it is
not allowed to be designated as Invariant. The Document may contain zero Invariant
Sections. If the Document does not identify any Invariant Sections then there are none.
The “Cover Texts” are certain short passages of text that are listed, as Front-Cover
Texts or Back-Cover Texts, in the notice that says that the Document is released under
this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may
be at most 25 words.
A “Transparent” copy of the Document means a machine-readable copy, represented
in a format whose specification is available to the general public, that is suitable for
revising the document straightforwardly with generic text editors or (for images com-
posed of pixels) generic paint programs or (for drawings) some widely available drawing
editor, and that is suitable for input to text formatters or for automatic translation to
a variety of formats suitable for input to text formatters. A copy made in an otherwise
Transparent file format whose markup, or absence of markup, has been arranged to
thwart or discourage subsequent modification by readers is not Transparent. An image
format is not Transparent if used for any substantial amount of text. A copy that is
not “Transparent” is called “Opaque”.
Examples of suitable formats for Transparent copies include plain ascii without
markup, Texinfo input format, LaTEX input format, SGML or XML using a publicly
available DTD, and standard-conforming simple HTML, PostScript or PDF designed
for human modification. Examples of transparent image formats include PNG, XCF
and JPG. Opaque formats include proprietary formats that can be read and edited
only by proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for output purposes only.
The “Title Page” means, for a printed book, the title page itself, plus such following
pages as are needed to hold, legibly, the material this License requires to appear in the
title page. For works in formats which do not have any title page as such, “Title Page”
means the text near the most prominent appearance of the work’s title, preceding the
beginning of the body of the text.
The “publisher” means any person or entity that distributes copies of the Document
to the public.
A section “Entitled XYZ” means a named subunit of the Document whose title either
is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in
another language. (Here XYZ stands for a specific section name mentioned below, such
as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve
the Title” of such a section when you modify the Document means that it remains a
section “Entitled XYZ” according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that
this License applies to the Document. These Warranty Disclaimers are considered to
be included by reference in this License, but only as regards disclaiming warranties:
any other implication that these Warranty Disclaimers may have is void and has no
effect on the meaning of this License.
2. VERBATIM COPYING
Appendix A: GNU Free Documentation License 395
You may copy and distribute the Document in any medium, either commercially or
noncommercially, provided that this License, the copyright notices, and the license
notice saying this License applies to the Document are reproduced in all copies, and
that you add no other conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further copying of the copies
you make or distribute. However, you may accept compensation in exchange for copies.
If you distribute a large enough number of copies you must also follow the conditions
in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly
display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of
the Document, numbering more than 100, and the Document’s license notice requires
Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all
these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify you as the publisher
of these copies. The front cover must present the full title with all words of the title
equally prominent and visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve the title of the
Document and satisfy these conditions, can be treated as verbatim copying in other
respects.
If the required texts for either cover are too voluminous to fit legibly, you should put
the first ones listed (as many as fit reasonably) on the actual cover, and continue the
rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100,
you must either include a machine-readable Transparent copy along with each Opaque
copy, or state in or with each Opaque copy a computer-network location from which
the general network-using public has access to download using public-standard network
protocols a complete Transparent copy of the Document, free of added material. If
you use the latter option, you must take reasonably prudent steps, when you begin
distribution of Opaque copies in quantity, to ensure that this Transparent copy will
remain thus accessible at the stated location until at least one year after the last time
you distribute an Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the Document well
before redistributing any large number of copies, to give them a chance to provide you
with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the conditions
of sections 2 and 3 above, provided that you release the Modified Version under precisely
this License, with the Modified Version filling the role of the Document, thus licensing
distribution and modification of the Modified Version to whoever possesses a copy of
it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the
Document, and from those of previous versions (which should, if there were any,
396 Using as
be listed in the History section of the Document). You may use the same title as
a previous version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for
authorship of the modifications in the Modified Version, together with at least five
of the principal authors of the Document (all of its principal authors, if it has fewer
than five), unless they release you from this requirement.
C. State on the Title page the name of the publisher of the Modified Version, as the
publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications adjacent to the other
copyright notices.
F. Include, immediately after the copyright notices, a license notice giving the public
permission to use the Modified Version under the terms of this License, in the form
shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover
Texts given in the Document’s license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled “History”, Preserve its Title, and add to it an item
stating at least the title, year, new authors, and publisher of the Modified Version
as given on the Title Page. If there is no section Entitled “History” in the Docu-
ment, create one stating the title, year, authors, and publisher of the Document
as given on its Title Page, then add an item describing the Modified Version as
stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to
a Transparent copy of the Document, and likewise the network locations given in
the Document for previous versions it was based on. These may be placed in the
“History” section. You may omit a network location for a work that was published
at least four years before the Document itself, or if the original publisher of the
version it refers to gives permission.
K. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title
of the section, and preserve in the section all the substance and tone of each of the
contributor acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and
in their titles. Section numbers or the equivalent are not considered part of the
section titles.
M. Delete any section Entitled “Endorsements”. Such a section may not be included
in the Modified Version.
N. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in
title with any Invariant Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or appendices that qualify
as Secondary Sections and contain no material copied from the Document, you may at
your option designate some or all of these sections as invariant. To do this, add their
Appendix A: GNU Free Documentation License 397
titles to the list of Invariant Sections in the Modified Version’s license notice. These
titles must be distinct from any other section titles.
You may add a section Entitled “Endorsements”, provided it contains nothing but
endorsements of your Modified Version by various parties—for example, statements of
peer review or that the text has been approved by an organization as the authoritative
definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up
to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified
Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be
added by (or through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or by arrangement
made by the same entity you are acting on behalf of, you may not add another; but
you may replace the old one, on explicit permission from the previous publisher that
added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission
to use their names for publicity for or to assert or imply endorsement of any Modified
Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this License,
under the terms defined in section 4 above for modified versions, provided that you
include in the combination all of the Invariant Sections of all of the original documents,
unmodified, and list them all as Invariant Sections of your combined work in its license
notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical
Invariant Sections may be replaced with a single copy. If there are multiple Invariant
Sections with the same name but different contents, make the title of each such section
unique by adding at the end of it, in parentheses, the name of the original author or
publisher of that section if known, or else a unique number. Make the same adjustment
to the section titles in the list of Invariant Sections in the license notice of the combined
work.
In the combination, you must combine any sections Entitled “History” in the vari-
ous original documents, forming one section Entitled “History”; likewise combine any
sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You
must delete all sections Entitled “Endorsements.”
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released
under this License, and replace the individual copies of this License in the various
documents with a single copy that is included in the collection, provided that you
follow the rules of this License for verbatim copying of each of the documents in all
other respects.
You may extract a single document from such a collection, and distribute it individu-
ally under this License, provided you insert a copy of this License into the extracted
document, and follow this License in all other respects regarding verbatim copying of
that document.
398 Using as
AS Index
# %
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 %gp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
#APP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 ‘%gpreg’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
#NO_APP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 ‘%pidreg’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
$ –
‘-+’ option, VAX/VMS . . . . . . . . . . . . . . . . . . . . . . . 358
$ in symbol names . . . . . . . . . . . . . . 162, 166, 225, 314
-- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
$a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
‘--32’ option, i386 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
$acos math builtin, TIC54X . . . . . . . . . . . . . . . . . . 329
‘--32’ option, x86-64 . . . . . . . . . . . . . . . . . . . . . . . . . . 178
$asin math builtin, TIC54X . . . . . . . . . . . . . . . . . . 329
‘--64’ option, i386 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
$atan math builtin, TIC54X . . . . . . . . . . . . . . . . . . 329
‘--64’ option, x86-64 . . . . . . . . . . . . . . . . . . . . . . . . . . 178
$atan2 math builtin, TIC54X . . . . . . . . . . . . . . . . . 329
--abi-call0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
$ceil math builtin, TIC54X . . . . . . . . . . . . . . . . . . 330
--abi-windowed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
$cos math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330
--absolute-literals . . . . . . . . . . . . . . . . . . . . . . . . 368
$cosh math builtin, TIC54X . . . . . . . . . . . . . . . . . . 330
--allow-reg-prefix . . . . . . . . . . . . . . . . . . . . . . . . . . 314
$cvf math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330
--alternate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
$cvi math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330
--auto-litpools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
$d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101, 131
‘--base-size-default-16’ . . . . . . . . . . . . . . . . . . . . 208
$exp math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330
‘--base-size-default-32’ . . . . . . . . . . . . . . . . . . . . 208
$fabs math builtin, TIC54X . . . . . . . . . . . . . . . . . . 330
--big. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
$firstch subsym builtin, TIC54X . . . . . . . . . . . . 336
‘--bitwise-or’ option, M680x0 . . . . . . . . . . . . . . . 207
$floor math builtin, TIC54X . . . . . . . . . . . . . . . . . 330
‘--compress-debug-sections=’ option . . . . . . . . . . 7
$fmod math builtin, TIC54X . . . . . . . . . . . . . . . . . . 330
‘--disp-size-default-16’ . . . . . . . . . . . . . . . . . . . . 208
$int math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330
‘--disp-size-default-32’ . . . . . . . . . . . . . . . . . . . . 208
$iscons subsym builtin, TIC54X. . . . . . . . . . . . . . 336 ‘--divide’ option, i386 . . . . . . . . . . . . . . . . . . . . . . . 178
$isdefed subsym builtin, TIC54X . . . . . . . . . . . . 336 --dsp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
$ismember subsym builtin, TIC54X . . . . . . . . . . . 336 --emulation=crisaout
$isname subsym builtin, TIC54X. . . . . . . . . . . . . . 337 command-line option, CRIS. . . . . . . . . . . . . . . . . 154
$isreg subsym builtin, TIC54X . . . . . . . . . . . . . . . 337 --emulation=criself
$lastch subsym builtin, TIC54X. . . . . . . . . . . . . . 336 command-line option, CRIS. . . . . . . . . . . . . . . . . 154
$ldexp math builtin, TIC54X . . . . . . . . . . . . . . . . . 330 --enforce-aligned-data . . . . . . . . . . . . . . . . . . . . . 319
$log math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330 --fatal-warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
$log10 math builtin, TIC54X . . . . . . . . . . . . . . . . . 330 --fdpic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
$max math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330 --fix-v4bx command-line option, ARM . . . . . . 123
$min math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330 ‘--fixed-special-register-names’
$pow math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330 command-line option, MMIX . . . . . . . . . . . . . . . 244
$round math builtin, TIC54X . . . . . . . . . . . . . . . . . 330 ‘--force-long-branches’ . . . . . . . . . . . . . . . . . . . . . 216
$sgn math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330 ‘--generate-example’ . . . . . . . . . . . . . . . . . . . . . . . . 216
$sin math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 330 ‘--globalize-symbols’
$sinh math builtin, TIC54X . . . . . . . . . . . . . . . . . . 331 command-line option, MMIX . . . . . . . . . . . . . . . 244
$sqrt math builtin, TIC54X . . . . . . . . . . . . . . . . . . 331 ‘--gnu-syntax’ command-line
$structacc subsym builtin, TIC54X . . . . . . . . . . 337 option, MMIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
$structsz subsym builtin, TIC54X . . . . . . . . . . . 337 ‘--linker-allocated-gregs’
$symcmp subsym builtin, TIC54X. . . . . . . . . . . . . . 336 command-line option, MMIX . . . . . . . . . . . . . . . 244
$symlen subsym builtin, TIC54X. . . . . . . . . . . . . . 336 --listing-cont-lines . . . . . . . . . . . . . . . . . . . . . . . . 27
$t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 --listing-lhs-width. . . . . . . . . . . . . . . . . . . . . . . . . . 27
$tan math builtin, TIC54X . . . . . . . . . . . . . . . . . . . 331 --listing-lhs-width2 . . . . . . . . . . . . . . . . . . . . . . . . 27
$tanh math builtin, TIC54X . . . . . . . . . . . . . . . . . . 331 --listing-rhs-width. . . . . . . . . . . . . . . . . . . . . . . . . . 27
$trunc math builtin, TIC54X . . . . . . . . . . . . . . . . . 331 --little . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
$x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 --longcalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
--march=architecture
command-line option, CRIS. . . . . . . . . . . . . . . . . 154
402 Using as
--MD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 -an . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
--mul-bug-abort command-line -as . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
option, CRIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 -Asparc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-absolute-literals . . . . . . . . . . . . . . . . . . . . . 368 -Asparcfmaf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-auto-litpools . . . . . . . . . . . . . . . . . . . . . . . . . . 368 -Asparcima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
‘--no-expand’ command-line option, MMIX . . . 244 -Asparclet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-longcalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 -Asparclite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
‘--no-merge-gregs’ command-line -Asparcvis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
option, MMIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 -Asparcvis2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-mul-bug-abort -Asparcvis3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
command-line option, CRIS. . . . . . . . . . . . . . . . . 154 -Asparcvis3r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-pad-sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 -Av6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
‘--no-predefined-syms’ -Av7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
command-line option, MMIX . . . . . . . . . . . . . . . 244 -Av8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
‘--no-pushj-stubs’ command-line -Av9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
option, MMIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 -Av9a. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
‘--no-stubs’ command-line option, MMIX . . . . 244 -Av9b. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-target-align . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 -Av9c. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-text-section-literals . . . . . . . . . . . . . . . . 368 -Av9d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-trampolines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 -Av9e. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 -Av9m. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
--no-underscore command-line -Av9v. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
option, CRIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 -big option, M32R . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
--no-warn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 -colonless command-line option, Z80 . . . . . . . . 379
‘--pcrel’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 -d, VAX option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
--pic command-line option, CRIS . . . . . . . . . . . . 154 -D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
‘--print-insn-syntax’ . . . . . . . . . . . . . . . . . . 216, 365 -D, ignored on VAX . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
‘--print-opcodes’ . . . . . . . . . . . . . . . . . . . . . . . 216, 365 -eabi= command-line option, ARM . . . . . . . . . . . 122
‘--register-prefix-optional’ -EB command-line option, AArch64 . . . . . . . . . . . . 96
option, M680x0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 -EB command-line option, ARC . . . . . . . . . . . . . . . 110
--relax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 -EB command-line option, ARM. . . . . . . . . . . . . . . 122
‘--relax’ command-line option, MMIX . . . . . . . 244 -EB command-line option, BPF . . . . . . . . . . . . . . . 146
--rename-section . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 -EB option (MIPS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
--renesas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 -EB option, M32R . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
--sectname-subst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 ‘-EB’ option, TILE-Gx . . . . . . . . . . . . . . . . . . . . . . . . 341
‘--short-branches’ . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 -EL command-line option, AArch64 . . . . . . . . . . . . 96
--small . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 -EL command-line option, ARC . . . . . . . . . . . . . . . 110
--statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 -EL command-line option, ARM. . . . . . . . . . . . . . . 123
‘--strict-direct-mode’ . . . . . . . . . . . . . . . . . . . . . . 215 -EL command-line option, BPF . . . . . . . . . . . . . . . 146
--target-align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 -EL option (MIPS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
--text-section-literals . . . . . . . . . . . . . . . . . . . . 368 -EL option, M32R . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
--traditional-format . . . . . . . . . . . . . . . . . . . . . . . . 29 ‘-EL’ option, TILE-Gx . . . . . . . . . . . . . . . . . . . . . . . . 341
--trampolines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 -f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
--transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 -F command-line option, Alpha . . . . . . . . . . . . . . . 102
--underscore command-line option, CRIS . . . . 154 ‘-fno-pic’ option, RISC-V . . . . . . . . . . . . . . . . . . . . 280
--warn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 -fp-d command-line option, Z80 . . . . . . . . . . . . . . 379
‘--x32’ option, i386 . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 -fp-s command-line option, Z80 . . . . . . . . . . . . . . 379
‘--x32’ option, x86-64 . . . . . . . . . . . . . . . . . . . . . . . . 178 ‘-fpic’ option, RISC-V . . . . . . . . . . . . . . . . . . . . . . . 280
‘--xgate-ramoffset’ . . . . . . . . . . . . . . . . . . . . . . . . . 215 -g command-line option, Alpha . . . . . . . . . . . . . . . 102
‘-1’ option, VAX/VMS . . . . . . . . . . . . . . . . . . . . . . . 358 -G command-line option, Alpha . . . . . . . . . . . . . . . 102
-32addr command-line option, Alpha . . . . . . . . . 102 -G option (MIPS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
-a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ‘-h’ option, VAX/VMS . . . . . . . . . . . . . . . . . . . . . . . 357
-ac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ‘-H’ option, VAX/VMS . . . . . . . . . . . . . . . . . . . . . . . 358
-ad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 -I path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
-ag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ‘-ignore-parallel-conflicts’
-ah . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 option, M32RX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
-al . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ‘-Ip’ option, M32RX. . . . . . . . . . . . . . . . . . . . . . . . . . 204
-Aleon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 -J, ignored on VAX . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
AS Index 403
ARC word aligned program counter . . . . . . . . . . . 111 assembler directive TETRA, MMIX . . . . . . . . . . . 248
arch directive, i386 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 assembler directive WYDE, MMIX . . . . . . . . . . . . 248
arch directive, M680x0 . . . . . . . . . . . . . . . . . . . . . . . 212 assembler directives, CRIS . . . . . . . . . . . . . . . . . . . . 157
arch directive, MSP 430 . . . . . . . . . . . . . . . . . . . . . . 254 assembler directives, M68HC11. . . . . . . . . . . . . . . . 218
arch directive, x86-64 . . . . . . . . . . . . . . . . . . . . . . . . . 191 assembler directives, M68HC12. . . . . . . . . . . . . . . . 218
architecture options, IP2022 . . . . . . . . . . . . . . . . . . 197 assembler directives, MMIX . . . . . . . . . . . . . . . . . . . 247
architecture options, IP2K . . . . . . . . . . . . . . . . . . . . 197 assembler directives, RL78 . . . . . . . . . . . . . . . . . . . . 290
architecture options, M16C . . . . . . . . . . . . . . . . . . . 201 assembler directives, RX . . . . . . . . . . . . . . . . . . . . . . 294
architecture options, M32C . . . . . . . . . . . . . . . . . . . 201 assembler directives, XGATE . . . . . . . . . . . . . . . . . 366
architecture options, M32R . . . . . . . . . . . . . . . . . . . 203 assembler internal logic error . . . . . . . . . . . . . . . . . . . 39
architecture options, M32R2 . . . . . . . . . . . . . . . . . . 203 assembler version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
architecture options, M32RX . . . . . . . . . . . . . . . . . . 203 assembler, and linker . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
architecture options, M680x0. . . . . . . . . . . . . . . . . . 208 assembly listings, enabling . . . . . . . . . . . . . . . . . . . . . 25
Architecture variant option, CRIS . . . . . . . . . . . . . 154 assigning values to symbols . . . . . . . . . . . . . . . . . 43, 61
architectures, Meta . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 at register, MIPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
architectures, PowerPC . . . . . . . . . . . . . . . . . . . . . . . 275 att syntax pseudo op, i386 . . . . . . . . . . . . . . . . . . . . 184
architectures, SCORE . . . . . . . . . . . . . . . . . . . . . . . . 312 att syntax pseudo op, x86-64. . . . . . . . . . . . . . . . . . 184
architectures, SPARC . . . . . . . . . . . . . . . . . . . . . . . . . 317 attributes, symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
arguments for addition . . . . . . . . . . . . . . . . . . . . . . . . . 48 auxiliary attributes, COFF symbols . . . . . . . . . . . . 46
arguments for subtraction . . . . . . . . . . . . . . . . . . . . . . 48 auxiliary symbol information, COFF . . . . . . . . . . . 60
arguments in expressions . . . . . . . . . . . . . . . . . . . . . . . 47 AVR line comment character . . . . . . . . . . . . . . . . . . 136
arithmetic functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 AVR line separator . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
arithmetic operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 AVR modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
ARM data relocations . . . . . . . . . . . . . . . . . . . . . . . . 124 AVR opcode summary . . . . . . . . . . . . . . . . . . . . . . . . 137
ARM floating point (ieee) . . . . . . . . . . . . . . . . . . . . 125 AVR options (none) . . . . . . . . . . . . . . . . . . . . . . . . . . 134
ARM identifiers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 AVR register names . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
ARM immediate character . . . . . . . . . . . . . . . . . . . . 124 AVR support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
ARM line comment character . . . . . . . . . . . . . . . . . 124
ARM line separator . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
ARM machine directives . . . . . . . . . . . . . . . . . . . . . . 125 B
ARM opcodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 backslash (\\) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
ARM options (none) . . . . . . . . . . . . . . . . . . . . . . . . . . 117 backspace (\b) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ARM register names . . . . . . . . . . . . . . . . . . . . . . . . . . 124 balign directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
ARM support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 balignl directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
ascii directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 balignw directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
asciz directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 bes directive, TIC54X . . . . . . . . . . . . . . . . . . . . . . . . 334
asg directive, TIC54X . . . . . . . . . . . . . . . . . . . . . . . . 331 big endian output, MIPS . . . . . . . . . . . . . . . . . . . . . . . 14
assembler bugs, reporting . . . . . . . . . . . . . . . . . . . . . 387 big endian output, PJ . . . . . . . . . . . . . . . . . . . . . . . . . . 13
assembler crash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 big-endian output, MIPS . . . . . . . . . . . . . . . . . . . . . . 227
assembler directive .3byte, RX . . . . . . . . . . . . . . . . 294 big-endian output, TIC6X . . . . . . . . . . . . . . . . . . . . 338
assembler directive .arch, CRIS . . . . . . . . . . . . . . . 158 bignums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
assembler directive .dword, CRIS. . . . . . . . . . . . . . 157 binary constants, TIC54X . . . . . . . . . . . . . . . . . . . . . 328
assembler directive .far, M68HC11 . . . . . . . . . . . . 218 binary files, including . . . . . . . . . . . . . . . . . . . . . . . . . . 65
assembler directive .fetchalign, RX . . . . . . . . . . . . 294 binary integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
assembler directive .interrupt, M68HC11 . . . . . . 219 bit names, IA-64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
assembler directive .mode, M68HC11 . . . . . . . . . . 218 bitfields, not supported on VAX . . . . . . . . . . . . . . . 360
assembler directive .relax, M68HC11 . . . . . . . . . . 218 Blackfin directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
assembler directive .syntax, CRIS . . . . . . . . . . . . . 157 Blackfin options (none) . . . . . . . . . . . . . . . . . . . . . . . 142
assembler directive .xrefb, M68HC11 . . . . . . . . . . 219 Blackfin support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
assembler directive BSPEC, MMIX . . . . . . . . . . . 249 Blackfin syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
assembler directive BYTE, MMIX . . . . . . . . . . . . 248 block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
assembler directive ESPEC, MMIX . . . . . . . . . . . 249 BMI, i386 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
assembler directive GREG, MMIX . . . . . . . . . . . . 247 BMI, x86-64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
assembler directive IS, MMIX . . . . . . . . . . . . . . . . . 247 BPF line comment character . . . . . . . . . . . . . . . . . . 146
assembler directive LOC, MMIX . . . . . . . . . . . . . . 247 BPF opcodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
assembler directive LOCAL, MMIX . . . . . . . . . . . 247 BPF options (none) . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
assembler directive OCTA, MMIX . . . . . . . . . . . . 248 BPF register names . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
assembler directive PREFIX, MMIX . . . . . . . . . . 249 BPF support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
410 Using as
intel syntax pseudo op, i386. . . . . . . . . . . . . . . . . . . 184 line comment character, Alpha . . . . . . . . . . . . . . . . 103
intel syntax pseudo op, x86-64 . . . . . . . . . . . . . . . . 184 line comment character, ARC . . . . . . . . . . . . . . . . . 110
internal assembler sections . . . . . . . . . . . . . . . . . . . . . 39 line comment character, ARM . . . . . . . . . . . . . . . . 124
internal directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 line comment character, AVR . . . . . . . . . . . . . . . . . 136
interrupt link register, ARC . . . . . . . . . . . . . . . . . . . 111 line comment character, BPF . . . . . . . . . . . . . . . . . 146
Interrupt Vector Base address, ARC . . . . . . . . . . 111 line comment character, CR16 . . . . . . . . . . . . . . . . 153
invalid input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 line comment character, D10V . . . . . . . . . . . . . . . . 162
invocation summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 line comment character, D30V . . . . . . . . . . . . . . . . 165
IP2K architecture options . . . . . . . . . . . . . . . . . . . . . 197 line comment character, Epiphany . . . . . . . . . . . . 169
IP2K line comment character . . . . . . . . . . . . . . . . . 197 line comment character, H8/300 . . . . . . . . . . . . . . . 170
IP2K line separator . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 line comment character, i386 . . . . . . . . . . . . . . . . . . 184
IP2K options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 line comment character, IA-64 . . . . . . . . . . . . . . . . 195
IP2K support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 line comment character, IP2K . . . . . . . . . . . . . . . . . 197
irp directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 line comment character, LM32 . . . . . . . . . . . . . . . . 200
irpc directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 line comment character, M32C . . . . . . . . . . . . . . . . 202
line comment character, M680x0 . . . . . . . . . . . . . . 214
line comment character, M68HC11 . . . . . . . . . . . . 216
J line comment character, Meta . . . . . . . . . . . . . . . . . 225
joining text and data sections . . . . . . . . . . . . . . . . . . 29 line comment character, MicroBlaze . . . . . . . . . . . 226
jsri2bsr command-line option, C-SKY . . . . . . . 159 line comment character, MIPS . . . . . . . . . . . . . . . . 242
jump instructions, i386. . . . . . . . . . . . . . . . . . . . . . . . 186 line comment character, MSP 430 . . . . . . . . . . . . . 252
jump instructions, relaxation . . . . . . . . . . . . . . . . . . 373 line comment character, Nios II . . . . . . . . . . . . . . . 262
jump instructions, x86-64 . . . . . . . . . . . . . . . . . . . . . 186 line comment character, NS32K . . . . . . . . . . . . . . . 265
jump optimization, i386 . . . . . . . . . . . . . . . . . . . . . . . 189 line comment character, OpenRISC . . . . . . . . . . . 266
jump optimization, x86-64 . . . . . . . . . . . . . . . . . . . . 189 line comment character, PJ . . . . . . . . . . . . . . . . . . . 274
jump/call operands, i386 . . . . . . . . . . . . . . . . . . . . . . 184 line comment character, PowerPC . . . . . . . . . . . . . 277
jump/call operands, x86-64 . . . . . . . . . . . . . . . . . . . 184 line comment character, PRU . . . . . . . . . . . . . . . . . 278
line comment character, RL78 . . . . . . . . . . . . . . . . . 291
line comment character, RX. . . . . . . . . . . . . . . . . . . 294
L line comment character, s390 . . . . . . . . . . . . . . . . . . 296
L16SI instructions, relaxation . . . . . . . . . . . . . . . . . 374 line comment character, S12Z . . . . . . . . . . . . . . . . . 221
L16UI instructions, relaxation . . . . . . . . . . . . . . . . . 374 line comment character, SCORE . . . . . . . . . . . . . . 313
L32I instructions, relaxation . . . . . . . . . . . . . . . . . . 374 line comment character, SH . . . . . . . . . . . . . . . . . . . 314
L8UI instructions, relaxation . . . . . . . . . . . . . . . . . . 374 line comment character, Sparc . . . . . . . . . . . . . . . . 319
label (:) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 line comment character, TIC54X . . . . . . . . . . . . . . 337
label directive, TIC54X . . . . . . . . . . . . . . . . . . . . . . 333 line comment character, TIC6X . . . . . . . . . . . . . . . 338
labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 line comment character, V850 . . . . . . . . . . . . . . . . . 351
labels, Z80 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 line comment character, VAX . . . . . . . . . . . . . . . . . 361
largecomm directive, ELF . . . . . . . . . . . . . . . . . . . . . 183 line comment character, Visium . . . . . . . . . . . . . . . 362
lcomm directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67, 112 line comment character, WebAssembly . . . . . . . . 363
lcomm directive, COFF . . . . . . . . . . . . . . . . . . . . . . . . 183 line comment character, XGATE . . . . . . . . . . . . . . 365
lcommon directive, ARC . . . . . . . . . . . . . . . . . . . . . . . 112 line comment character, XStormy16 . . . . . . . . . . . 367
ld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 line comment character, Z80 . . . . . . . . . . . . . . . . . . 380
ldouble directive M680x0 . . . . . . . . . . . . . . . . . . . . . 212 line comment character, Z8000 . . . . . . . . . . . . . . . . 383
ldouble directive M68HC11 . . . . . . . . . . . . . . . . . . 219 line comment characters, CRIS . . . . . . . . . . . . . . . . 156
ldouble directive XGATE . . . . . . . . . . . . . . . . . . . . 366 line comment characters, MMIX . . . . . . . . . . . . . . 245
ldouble directive, TIC54X . . . . . . . . . . . . . . . . . . . . 332 line directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
LDR reg,=<expr> pseudo op, AArch64 . . . . . . . . . 101 line directive, MSP 430 . . . . . . . . . . . . . . . . . . . . . . 254
LDR reg,=<label> pseudo op, ARM . . . . . . . . . . . 130 line numbers, in input files . . . . . . . . . . . . . . . . . . . . . 22
LEB128 directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 line separator character . . . . . . . . . . . . . . . . . . . . . . . . 32
length directive, TIC54X . . . . . . . . . . . . . . . . . . . . . 333 line separator character, Nios II . . . . . . . . . . . . . . . 262
length of symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 line separator, AArch64 . . . . . . . . . . . . . . . . . . . . . . . . 99
level 1 interrupt link register, ARC . . . . . . . . . . . . 111 line separator, Alpha. . . . . . . . . . . . . . . . . . . . . . . . . . 103
level 2 interrupt link register, ARC . . . . . . . . . . . . 111 line separator, ARC . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
lflags directive (ignored) . . . . . . . . . . . . . . . . . . . . . . 67 line separator, ARM . . . . . . . . . . . . . . . . . . . . . . . . . . 124
line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 line separator, AVR . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
line comment character . . . . . . . . . . . . . . . . . . . . . . . . 32 line separator, CR16 . . . . . . . . . . . . . . . . . . . . . . . . . . 153
line comment character, AArch64 . . . . . . . . . . . . . . 99 line separator, Epiphany . . . . . . . . . . . . . . . . . . . . . . 169
416 Using as