AT&T彙編僞指令

 

最近一直在看OS方面的東西,其中要用到許多AT&T彙編,下面是在網上打到的關於它的僞指令方面的中英文對照版本。英文版本也可以輸入如下命令來查看:
    info as   
    read the "Pseudo Ops" node

7 Assembler Directives
All assembler directives have names that begin with a period (‘.’). The rest
of the name is letters, usually in lower case.
This chapter discusses directives that are available regardless of the target
machine configuration for the gnu assembler. Some machine configurations provi
de additional directives. See Chapter 8 [Machine Dependencies], page 61.

7 彙編器命令
所有的彙編器命令名都由句號('.')開頭。命令名的其餘是字母,通常使用小寫。
本章討論可用命令,不理會gun彙編器針對目標機器配置。某些機器的配置提供附加的命令
。見第8章[機器相關性],第61頁。

7.1 .abort
This directive stops the assembly immediately. It is for compatibility with ot
her 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 th
is directive tells as to quit also. One day .abort will not be supported.

7.1 .abort
本命令立即終止彙編過程。這是爲了兼容其它的彙編器。早期的想法是彙編語言的源碼會
被輸送進彙編器。如果發送源碼的程序要退出,它可以使用本命令通知as退出。將來可能
不再支持使用.abort


7.2 .ABORT
When producing COFF output, as accepts this directive as a synonym for ‘.abor
t’.
When producing b.out output, as accepts this directive, but ignores it.

7.2 .ABORT
當生成COFF輸出時,彙編器把這條命令作爲.abort接受。
當產成b.out輸出時,彙編器允許使用這條命令,但忽略它。


7.3 .align abs-expr, abs-expr, abs-expr
Pad the location counter (in the current subsection) to a particular storage b
oundary. The first expression (which must be absolute) is the alignment requir
ed, as described below.
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 paddi
ng bytes are normally zero. However, on some 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 di
rective. If doing the alignment would require skipping more bytes than the spe
cified maximum, then the alignment is not done at all. You can omit the fill v
alue (the second argument) entirely by simply using two commas after the requi
red alignment; this can be useful if you want the alignment to be filled with
no-op instructions when appropriate.
The way the required alignment is specified varies from system to system. For
the a29k, hppa, m68k, m88k, w65, sparc, and Hitachi SH, and i386 using ELF for
mat, the first expression is the alignment request in bytes. For example ‘.al
ign 8’ advances the location counter until it is a multiple of 8. If the loca
tion counter is already a multiple of 8, no change is needed.
For other systems, including the i386 using a.out format, and the arm and stro
ngarm, it is the number of low-order zero bits the location counter must have
after advancement. For example ‘.align 3’ advances the location counter unti
l it a multiple of 8. If the location counter is already a multiple of 8, no c
hange is needed.
This inconsistency is due to the different behaviors of the various native ass
emblers for these systems which GAS must emulate. GAS also provides .balign an
d .p2align directives, described later, which have a consistent behavior acros
s all architectures (but are specific to GAS).


7.3 .align abs-expr, abs-expr, abs-expr
增加位置計數器(在當前的子段)使它指向規定的存儲邊界。第一個表達式參數(結果必須是
純粹的數字)是必需參數:邊界基準,見後面的描述。
第二個表達式參數(結果必須是純粹的數字)給出填充字節的值,用這個值填充位置計數器
越過的地方。這個參數(和逗點)可以省略,如果省略它,填充字節的值通常是0。但在某些
系統上,如果本段標識爲包含代碼,而填充值被省略,則使用no-op指令填充這個空間。

第3個參數表達式的結果也必須是純粹的數字,這個參數是可選的。如果存在第3個參數,
它代表本對齊命令允許越過字節數的最大值。如果完成這個對齊需要跳過的字節比指定的
最大值還多,則根本無法完成對齊。您可以在邊界基準後簡單地使用兩個逗號,以省略填充
值參數(第二參數);如果您想在適當的時候,對齊操作自動使用no-op指令填充,這個方法
將非常奏效。
邊界基準的定義因系統而有差異。a29k,hppa,m68k,m88k,w65,sparc,Hitachi SH,
和使用ELF格式的i386,第一個表達式是邊界基準,單位是字節。例如‘.align 8’向後移
動位置計數器至8的倍數。如果地址已經是8的倍數,則無需移動。
有些其它系統,包括使用a.out格式的i386,ARM和strongarm,這代表位置計數器移動後,
計數器中連續爲0的低序位數量。例如‘.align 3’向後移動位置計數器直至8的倍數(計
數器的最低的3位爲0)。如果地址已經是8倍數,則無需移動。
之所以存在這樣的區別,是因爲GAS需要模仿各種彙編器的不同動作。GAS還提供.balign和
.p2align命令,在以後詳細講述,這兩條命令在所有的機型上使用相同的動作 (但需要向
GAS明確說明機型)。


7.4 .ascii "string". . .
.ascii expects zero or more string literals (see Section 3.6.1.1 [Strings], pa
ge 19) separated by commas. It assembles each string (with no automatic traili
ng zero byte) into consecutive addresses.

7.4 .ascii "string"...
.ascii可不帶參數或者帶多個由逗點分開的字符串(見3.6.1.1節[Strings],第19頁)。它把
彙編好的每個字符串(在字符串末不自動追加零字節)存入連續的地址。


7.5 .asciz "string". . .
.asciz is just like .ascii, but each string is followed by a zero byte. The “
z” in ‘.asciz’ stands for “zero”.

7.5 .asciz "string"...
.asciz類似與.ascii,但在每個字符串末自動追加一個零字節。‘.asciz’中的‘z’代表
“zero”。


7.6 .balign[wl] abs-expr, abs-expr, abs-expr
Pad the location counter (in the current subsection) to a particular storage b
oundary. The first expression (which must be absolute) is the alignment reques
t in bytes. For example ‘.balign 8’ advances the location counter until it i
s a multiple of 8. If the location counter is already a multiple of 8, no chan
ge is needed.
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 paddi
ng bytes are normally zero. However, on some 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 di
rective. If doing the alignment would require skipping more bytes than the spe
cified maximum, then the alignment is not done at all. You can omit the fill v
alue (the second argument) entirely by simply using two commas after the requi
red alignment; this can be useful if you want the alignment to be filled with
no-op instructions when appropriate.
The .balignw and .balignl directives are variants of the .balign directive. Th
e .balignw directive treats the fill pattern as a two byte word value. The .ba
lignl directives treats the fill pattern as a four byte longword value. For ex
ample, .balignw 4,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 byte
s depends upon the endianness of the processor). If it skips 1 or 3 bytes, the
fill value is undefined.

7.6
.balign[wl] abs-expr, abs-expr, abs-expr
增加位置計數器(在當前子段)使它指向規定的存儲邊界。第一個表達式參數(結果必須是純
粹的數字)是必需參數:邊界基準,單位爲字節。例如,‘.balign 8’向後移動位置計數器
直至計數器的值等於8的倍數。如果位置計數器已經是8的倍數,則無需移動。
第2個表達式參數(結果必須是純粹的數字)給出填充字節的值,用這個值填充位置計數器越
過的地方。第2個參數(和逗點)可以省略。如果省略它,填充字節的值通常是0。但在某些
系統上,如果本段標識爲包含代碼,而填充值被省略,則使用no-op指令填充空白區。
第3個參數的結果也必須是純粹的數字,這個參數是可選的。如果存在第3個參數,它代表
本對齊命令允許跳過字節數的最大值。如果完成這個對齊需要跳過的字節數比規定的最大
值還多,則根本無法完成對齊。您可以在邊界基準參數後簡單地使用兩個逗號,以省略填充
值參數(第二參數);如果您在想在適當的時候,對齊操作自動使用no-op指令填充,本方法
將非常奏效。

.balignw和.balignl是.balign命令的變化形式。.balignw使用2個字節來填充空白區。.b
alignl使用4字節來填充。例如,.balignw 4,0x368d將地址對齊到4的倍數,如果它跳過2個
字節,GAS將使用0x368d填充這2個字節(字節的確切存放位置視處理器的存儲方式而定)。
如果它跳過1或3個字節,則填充值不明確。


7.7 .byte expressions
.byte expects zero or more expressions, separated by commas. Each expression i
s assembled into the next byte.

7.7.byte expressions
.byte可不帶參數或者帶多個表達式參數,表達式之間由逗點分隔。每個表達式參數都被匯
編成下一個字節。


7.8 .comm symbol , length
.comm declares a common symbol named symbol. When linking, a common symbol in
one object file may be merged with a defined or common symbol of the same name
in another object file. If ld does not see a definition for the symbol–just
one or more common symbols–then it will allocate length bytes of uninitialize
d memory. length must be an absolute expression. If ld sees multiple common sy
mbols with the same name, and they do not all have the same size, it will allo
cate space using the largest size.
When using ELF, the .comm directive takes an optional third argument. This is
the desired alignment of the symbol, specified as a byte boundary (for example
, an alignment of 16 means that the least significant 4 bits of the address sh
ould be zero). 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 w
ill use the alignment when placing the symbol. If no alignment is specified, a
s 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.
The syntax for .comm differs slightly on the HPPA. The syntax is ‘symbol .com
m, length’;symbol is optional.

7.8 .comm symbol , length
.comm聲明一個符號名爲symbol的通用符號(common symbol)。當連接時,目標文件中的通
用符號可能被併入其它目標文件中已定義的符號,或者被併入其他目標文件中同名通用符
號。如果ld無法找到該符號的定義——只有一個或多個通用符號——則分配length個字節
的未初始化內存。Length必須是一個純粹的表達式。如果ld發現多個同名的通用符號,並
且它們的長度不同,ld將按照它們之中最大的length值爲符號分配內存。
當使用ELF格式時,.comm可以使用第3個參數。它代表符號需要對齊的邊界基準(例如,邊界
基準爲16時意味着符號存放地址的最低4位應該是零)。第3個參數表達式結果必須是純粹的
數字,而且一定是2的冪。當ld爲通用符號分配未初始化內存時,在存放符號時要使用到這
個參數。如果沒有規定邊界基準,as將把邊界基準設置成以2爲底的該符號長度的對數,並
向下取整。最大值爲16。
.comm的語法在HPPA上稍微有些不同。語法是‘symbol .comm, length’;其中參數symbol
是可選的。


7.9 .data subsection
.data tells as to assemble the following statements onto the end of the data s
ubsection numbered subsection (which is an absolute expression). If subsection
is omitted, it defaults to zero.

7.9 .data subsection
.data通知as彙編後續語句,將它們追加在編號爲subsection(subsection必須是純粹的表
達式)數據段末。如果參數subsection省略,則默認是0。


7.10 .def name
Begin defining debugging information for a symbol name; the definition extends
until the .endef directive is encountered. This directive is only observed wh
en as is configured for COFF format output; when producing b.out, ‘.def’ is
recognized, but ignored.

7.10 .def name
開始定義符號'name'的調試信息;定義區延伸至遇到.endef命令。本命令只在as被配置成C
OFF格式輸出時才使用;當輸出爲b.out格式時,可以使用‘.def’命令,但被忽略。

7.11 .desc symbol, abs-expression
This directive sets the descriptor of the symbol (see Section 5.5 [Symbol Attr
ibutes],page 30) to the low 16 bits of an absolute expression.
The ‘.desc’ directive is not available when as is configured for COFF output
; it is only for a.out or b.out object format. For the sake of compatibility,
as accepts it, but produces no output, when configured for COFF.

7.11 .desc symbol, abs-expression
本命令用一個純粹表達式的低16位的值設置符號symbol的描述符(見5.5[符號屬性],第30頁
)。當as被配置成COFF輸出時,‘.desc’命令無效;它只適用於a.out或b.out目標格式。爲
兼容起見,當配置爲COFF時,as接受此命令,但不產生輸出。


7.12 .dim
This directive is generated by compilers to include auxiliary debugging inform
ation in the symbol table. It is only permitted inside .def/.endef pairs.
‘.dim’ is only meaningful when generating COFF format output; when as is gen
erating b.out, it accepts this directive but ignores it.

7.12 .dim
這條命令由編譯器生成的,以便在符號表中加入輔助調試信息。只可以在.def/.endef對之
間使用此命令。
'.dim'僅僅在生成COFF格式輸出時是有意義的;當生成b.out時,as接受這條命令,但忽略它



7.13 .double flonums
.double expects zero or more flonums, separated by commas. It assembles floati
ng point numbers. The exact kind of floating point numbers emitted depends on
how as is configured. See Chapter 8 [Machine Dependencies], page 61.

7.13 .double flonums
.double後跟着零個或由逗點分開多個的浮點數。本指令彙編出浮點數字。生成的浮點數的
確切類型視as的配置而定。見第8章[機器相關性],第61頁。


7.14 .eject
Force a page break at this point, when generating assembly listings.

7.14 .eject
當生成彙編清單時,強制清單頁在此點中斷。


7.15 .else
.else is part of the as support for conditional assembly; see Section 7.35 [.i
f], page 43. It marks the beginning of a section of code to be assembled if th
e condition for the preceding
.if was false.

7.15 .else
.else 是支持as進行的條件彙編指令之一;見7.35[.if],第43頁。如果前面.if命令的條件
不成立,則表示需要彙編.else後的一段代碼。


7.16 .elseif
.elseif is part of the as support for conditional assembly; see Section 7.35 [
.if],page 43. It is shorthand for beginning a new .if block that would otherwi
se fill the entire .else section.

7.16 .elseif
.elseif 是支持as進行的條件彙編指令之一。見7.35節 [.if],第43頁。它可以在.esle段
中快速產生一個新的.if塊。


7.17 .end
.end marks the end of the assembly file. as does not process anything in the f
ile past the .end directive.

7.17 .end
.end標記着彙編文件的結束。as不處理.end命令後的任何語句。


7.18 .endef
This directive flags the end of a symbol definition begun with .def.
‘.endef’ is only meaningful when generating COFF format output; if as is con
figured to generate b.out, it accepts this directive but ignores it.

7.18 .endef
這條命令標誌着從.def開始的符號定義結束。
‘.endef’命令僅僅在生成COFF格式的輸出有意義;如果as被配置爲生成b.out輸出,雖然a
s接受這條命令,但忽略它。


7.19 .endfunc
.endfunc marks the end of a function specified with .func.

7.19 .endfunc
.endfunc標誌着一個由.func命令定義的函數的結束。


7.20 .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.35 [.if],
page 43.

7.20 .endif
.endif是支持as進行的條件彙編的指令之一.它標誌着條件彙編代碼塊的結束。見7.35節[
.if],第43頁。


7.21 .equ symbol, expression
This directive sets the value of symbol to expression. It is synonymous with ‘
.set’; see Section 7.68 [.set], page 53.
The syntax for equ on the HPPA is ‘symbol .equ expression’.

7.21 .equ symbol, expression
本命令把符號symbol值設置爲expression。它等同與'.set'命令。見7.68[.set],第53頁。

在HPPA上的equ語法是‘symbol .equ expression’。


7.22 .equiv symbol, expression
The .equiv directive is like .equ and .set, except that the assembler will sig
nal an error if symbol is already defined.
Except for the contents of the error message, this is roughly equivalent to

.ifdef SYM
.err
.endif
.equ SYM,VAL

7.22 .equiv symbol, expression
.equiv 類似與.equ & .set命令, 不同之處在於,如果符號已經定義過,as會發出錯誤信
號。
除了錯誤信息的內容之外,它大體上等價與:
.ifdef SYM
.err
.endif
.equ SYM,VAL

7.23 .err
If as assembles a .err directive, it will print an error message and, unless t
he -Z option was used, it will not generate an object file. This can be used t
o signal error an conditionally compiled code.

7.23 .err
如果as彙編一條.err命令, 將打印一條錯誤信息,除非使用了-Z 選項, as不會生成目標文
件。 可以在條件編譯代碼中使用它來發出錯誤信息。


7.24 .exitm
Exit early from the current macro definition. See Section 7.50 [Macro], page 4
7.

7.24 .exitm
從當前宏定義體中提前退出。見7.50 [Macro],第47頁。

7.25 .extern
.extern is accepted in the source program—for compatibility with other assemb
lers—but it is ignored. as treats all undefined symbols as external.

7.25 .extern
.extern可以在源程序中使用--以便兼容其他的彙編器—但會被忽略。as將所有未定義的符
號都當作外部符號處理。


7.26 .fail expression
Generates an error or a warning. If the value of the expression is 500 or more
, as will print a warning message. If the value is less than 500, as will prin
t an error message. The message will include the value of expression. This can
occasionally be useful inside complex nested macros or conditional assembly.


7.26 .fail expression
生成一個錯誤(error)或警告(warning)。如果expression的值大於或等於500,as會打印一
條“警告”消息。如果expression的值小於500,as會打印一條“錯誤”消息。消息中包含
了expression的值。這在複雜的宏嵌套或條件彙編時偶爾用到。


7.27 .file string
.file tells as that we are about to start a new logical file. string is the ne
w file name.
In general, the filename is recognized whether or not it is surrounded by quot
es ‘"’; but if you wish to specify an empty file name, you must give the quo
tes–"". This statement may go away in future: it is only recognized to be com
patible with old as programs. In some configurations of as, .file has already
been removed to avoid conflicts with other assemblers. See Chapter 8 [Machine
Dependencies], page 61.

7.27 .file string
.file 通告as我們準備開啓一個新的邏輯文件。 string 是新文件名。總的來說,文件名
是否使用引號‘"’都可以;但如果您希望規定一個空文件名時,必須使用引號-""。本語
句將來可能不再使用—允許使用它只是爲了與舊版本的as程序兼容。在as的一些配置中,
已經刪除了.file以避免與其它的彙編器衝突。見第8章 [Machine Dependencies], 第61頁



7.28 .fill repeat , size , value
repeat, size and value are absolute expressions. This emits repeat copies of s
ize bytes. Repeat may be zero or more. Size may be zero or more, but if it is
more than 8, then it is deemed to have the value 8, compatible with other peop
le’s assemblers. The contents of each repeat bytes are taken from an 8-byte n
umber. The highest order 4 bytes are zero. The lowest order 4 bytes are value
rendered in the byte-order of an integer on the computer as is assembling for.
Each size bytes in a repetition is taken from the lowest order size bytes of
this number. Again, this bizarre behavior is compatible with other people’s a
ssemblers.
size and value are optional. If the second comma and value are absent, value i
s assumed zero. If the first comma and following tokens are absent, size is as
sumed to be 1.

7.28 .fill repeat , size , value
repeat, size 和value都必須是純粹的表達式。本命令生成size個字節的repeat個副本。
Repeat可以是0或更大的值。Size 可以是0或更大的值, 但即使size大於8,也被視作8,以
兼容其它的彙編器。各個副本中的內容取自一個8字節長的數。最高4個字節爲零,最低的
4個字節是value,它以as正在彙編的目標計算機的整數字節順序排列。每個副本中的size
個字節都取值於這個數最低的size個字節。再次說明,這個古怪的動作只是爲了兼容其他
的彙編器。
size參數和value參數是可選的。如果不存在第2個逗號和value參數,則假定value爲零。
如果不存在第1個逗號和其後的參數,則假定size爲1。


7.29 .float flonums
This directive assembles zero or more flonums, separated by commas. It has the
same effect as .single. The exact kind of floating point numbers emitted depe
nds on how as is configured. See Chapter 8 [Machine Dependencies], page 61.


7.29 .float flonums
本命令彙編0個或多個浮點數,浮點數之間由逗號分隔。它和.single的彙編效果相同。生
成的浮點數的確切類型視as的配置而定。見第8章 [Machine Dependencies], 61頁。


7.30 .func name[,label]
.func emits debugging information to denote function name, and is ignored unle
ss the file is assembled with debugging enabled. Only ‘--gstabs’ is currentl
y supported. Label is the entry point of the function and if omitted name prep
ended with the ‘leading char’ is used. ‘leading char’ is usually _ or noth
ing, depending on the target. All functions are currently defined to have void
return type. The function must be terminated with .endfunc.

7.30 .func name[,label]
.func發出一個調試信息用以指示函數name,這個信息將被忽略,除非文件使用debugging
enabled方式的彙編。目前只支持‘--gstabs’。label是函數的入口點,如果name被省略
則使用預定的‘引導符’。‘引導符’通常可以是 _ 或者什麼也沒有,視目標機型而定。
所有函數現時被定義爲void返回類型,函數體必須使用.endfunc來結束


7.31 .global symbol, .globl symbol
.global makes the symbol visible to ld. If you define symbol in your partial p
rogram, its value is made available to other partial programs that are linked
with it. Otherwise, symbol takes its attributes from a symbol of the same name
from another file linked into the same program.
Both spellings (‘.globl’ and ‘.global’) are accepted, for compatibility wi
th other assemblers.
On the HPPA, .global is not always enough to make it accessible to other parti
al programs. You may need the HPPA-only .EXPORT directive as well. See Section
8.8.5 [HPPA Assembler Directives], page 84.

7.31 .global symbol, .globl symbol
.global 使符號symbol對連接器ld可見。如果您在局部過程中定義符號symbol,其它和此
的局部過程都可以訪問它的值。另外,symbol從連接到本過程的另一個文件中的同名符號
獲取自己的屬性。
兩種寫法都可以(‘.globl’ 和‘.global’),以便兼容多種彙編器。

在HPPA上, .global未必總能夠使符號被其它局部過程訪問。可能同時需要使用HPPA-only
.EXPORT命令。見8.8.5[HPPA Assembler Directives],84頁。


7.32 .hidden names
This one of the ELF visibility directives. The other two are .internal (see Se
ction 7.39 [.internal], page 44) and .protected (see Section 7.58 [.protected]
, page 50).
This directive overrides the named symbols default visibility (which is set by
their binding: local, global or weak). The directive sets the visibility to h
idden which means that the symbols are not visible to other components. Such s
ymbols are always considered to be protected as well.

7.32 .hidden names
這是一條關於ELF可見度的命令。其它兩條是.internal(見7.39[.internal],44頁) 和 .p
rotected (見7.58 [.protected], 50頁)。本命令取消指定符號的缺省可見度(可見度由其
他命令捆綁設定:local,global,weak)。本命令把可見度設置爲hidden,這意味着本符號對
其他部分不可見。這最好是一些需要長期保護的符號。


7.33 .hword expressions
This expects zero or more expressions, and emits a 16 bit number for each.
This directive is a synonym for ‘.short’; depending on the target architectu
re, it may also be a synonym for ‘.word’.

7.33 .hword expressions
本命令後可以不帶或帶多個expressions,並且爲每個參數生成一個16位數。
本命令等同與'.short'命令。在某些架構上,也可能等同與'.word'。


7.34 .ident
This directive is used by some assemblers to place tags in object files. as si
mply accepts the directive for source-file compatibility with such assemblers,
but does not actually emit anything for it.

7.34 .ident
本命令被某些彙編器用來在目標文件中加入標飾。爲了使彙編源碼文件兼容上述的彙編器
,as簡單地接受本命令,但實際上不產生東西。


7.35 .if absolute expression
.if marks the beginning of a section of code which is only considered part of
the source program being assembled if the argument (which must be an absolute
expression) is nonzero. The end of the conditional section of code must be mar
ked by .endif (see Section 7.20 [.endif], page 40); optionally, you may includ
e code for the alternative condition, flagged by .else (see Section 7.15 [.els
e], page 40). If you have several conditions to check, .elseif may be used to
avoid nesting blocks if/else within each subsequent .else block.
The following variants of .if are also supported:
.ifdef symbol
Assembles the following section of code if the specified symbol has been defin
ed.
.ifc string1,string2
Assembles the following section of code if the two strings are the same. The s
trings may be optionally quoted with single quotes. If they are not quoted, th
e first string stops at the first comma, and the second string stops at the en
d of the line. Strings which contain whitespace should be quoted. The string c
omparison 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 equ
al 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.
.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 d
efined. Both spelling variants are equivalent.
.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 followi
ng section of code if the two strings are not the same.

7.35 .if absolute expression
.if 標誌着一段代碼的開始,這段代碼只有在參數absolute experession(必須是一個獨立
的表達式)不爲0時才進行彙編。這段條件彙編代碼必須使用.endif標誌結束。(見7.20[.e
ndif], 40頁);另外,可以使用.esle來標記一個代碼塊(見7.15 [.else],40頁),這個代碼
塊與前面那段代碼只有一個會進行彙編。 如果您需要檢查數個彙編條件,可以在使用.el
seif命令,以避免在.else代碼塊中進行if/else語句塊的嵌套。
同樣可以使用下面.if的變體:
.ifdef symbol
如果指定的符號symbol已經定義過,彙編下面那段代碼。
.ifc string1,string2
如果兩個字符串相同的話,彙編下面那段代碼。 字符串可以可選地使用單引號。如果不使
用引號則第1個字符串在逗號處結束。第2個字符串在本行末結束。包含空白的字符串應該
使用引號標註。字符串比較時是區分大小寫的。

.ifeq absolute expression
如果參數的值爲0,彙編下面那段代碼。

.ifeqs string1,string2
這是.ifc的另一種形式,字符串必須使用雙引號標註。

.ifge absolute expression
如果參數的值大於等於0,彙編下面那段代碼。

.ifgt absolute expression
如果參數的值大於0,彙編下面那段代碼。

.ifle absolute expression
如果參數的值小於等於0,彙編下面那段代碼。

.iflt absolute expression
如果參數的值小於0,彙編下面那段代碼。

.ifnc string1,string2.
類似與.ifc,不過使用反向的測試: 如果兩個字符串不相等的話,彙編下面那段代碼。

.ifndef symbol
.ifnotdef symbol
如果指定的符號symbol不曾被定義過,彙編下面那段代碼。 上面兩種寫法是等效的。


.ifne absolute expression
如果參數的值爲不等於0,彙編下面那段代碼。 (換句話說, 這是.if的另一種寫法).

.ifnes string1,string2
類似與.ifeqs,不過使用反向的測試: 如果兩個字符串不相等的話,彙編下面那段代碼。



7.36 .incbin "file"[,skip[,count]]
The incbin directive includes file verbatim at the current location. You can c
ontrol the search paths used with the ‘-I’ command-line option (see Chapter
2 [Command-Line Options], page 11). Quotation marks are required around file.

The skip argument skips a number of bytes from the start of the file. The coun
t argument indicates the maximum number of bytes to read. Note that the data i
s not aligned in any way, so it is the user’s responsibility to make sure tha
t proper alignment is provided both before and after the incbin directive.

7.36 .incbin "file"[,skip[,count]]
這條incbin命令在當前位置逐字地引入file文件的內容。您可以使用命令行選項參數“-I
”來控制搜索路徑。(見第2章[Command-Line Options], 11頁)。文件名必須使用引號。

參數skip表示需要從文件頭跳過的字節數目。參數count表示讀入的最大字節數目。注意,
數據沒有進行任何方式的對齊操作,所以用戶需要在 .incbin命令的前後進行必要的邊界
對齊。


7.37 .include "file"
This directive provides a way to include supporting files at specified points
in your source program. The code from file is assembled as if it followed the
point of the .include; when the end of the included file is reached, assembly
of the original file continues. You can control the search paths used with the
‘-I’ command-line option (see Chapter 2 [Command-Line Options], page 11). Q
uotation marks are required around file.

7.37 .include "file"
本命令提供在源程序中指定點引入支撐文件的手段。file中的代碼如同緊跟.include後一
樣被彙編。當引入文件彙編結束,繼續彙編原來的文件。您可以使用命令行選項參數“-I
”來控制搜索路徑(見第2章[Command-Line Options], 11頁)。文件名必須使用引號來標註



7.38 .int expressions
Expect zero or more expressions, of any section, separated by commas. For each
expression, emit a number that, at run time, is the value of that expression.
The byte order and bit size of the number depends on what kind of target the
assembly is for.

7.38 .int expressions
可以不帶參數或帶多個expressions,參數之間由逗號分隔。每個expressions都生成一個數
字,這個數字等於表達式在目標機器運行時的值。字節順序和數字的位數視彙編的目標機器
而定。


7.39 .internal names
This one of the ELF visibility directives. The other two are .hidden (see Sect
ion 7.32 [.hidden], page 42) and .protected (see Section 7.58 [.protected], pa
ge 50).
This directive overrides the named symbols default visibility (which is set by
their binding: local, global or weak). The directive sets the visibility to i
nternal which means that the symbols are considered to be hidden (ie not visib
le to other components), and that some extra, processor specific processing mu
st also be performed upon the symbols as well.

7.39 .internal names
這是一條與ELF可見度相關的命令。另外的兩條是.hidden(見7.32[.hidden],42頁) 和 .p
rotected (見7.58 [.protected],50頁)。
本命令取消指定符號的缺省可見度(可見度由其他命令捆綁設定:local,global,weak)。本
命令把指定符號可見度設置爲internal,這意味着此符號需要被隱藏(即對其他部分不可見
),另外,符號還必須經過處理器的特別的處理。




# 回覆:linux下彙編的Directive Operands 2004-09-08 3:24 PM n9871009
定語:發現簡單的把英文直譯成中文有時產生會極大的混亂。向前和向後就是一例,我在
5.3節符號名發現這個問題,當時另選了兩個詞替代了向前和向後。看起來現在必須說明一
下。
向前(移動):向文件頭的方向(移動)。
向後(移動):向文件尾的方向(移動)。
===========================================================
7.40 .irp symbol, values . . .
Evaluate a sequence of statements assigning different values to symbol. The se
quence of statements starts at the .irp directive, and is terminated by an .en
dr directive. For each value, symbol is set to value, and the sequence of stat
ements is assembled. If no value is listed, the sequence of statements is asse
mbled once, with symbol set to the null string. To refer to symbol within the
sequence of statements, use /symbol.
For example, assembling
.irp param,1,2,3
move d/param,sp@-
.endr
is equivalent to assembling
move d1,sp@-
move d2,sp@-
move d3,sp@-

7.40 .irp symbol,values . . .
加工一個需要用values替代symbol的語句序列。語句序列從.irp命令開始,在.endr命令前
結束。對於每個value都進行如下加工:用value替代Symbol,並對此語句序列進行彙編。
如果沒有給出value,則用空字符串(null sting)替代symbol,並將此語句序列彙編一次。
使用/symbol, 把參數symbol提交給語句序列。
例如下列代碼
.irp param,1,2,3
move d/param,sp@-
.endr
等同與
move d1,sp@-
move d2,sp@-
move d3,sp@-


7.41 .irpc symbol,values . . .
Evaluate a sequence of statements assigning different values to symbol. The se
quence of statements starts at the .irpc directive, and is terminated by an .e
ndr directive. For each character in value, symbol is set to the character, an
d the sequence of statements is assembled. If no value is listed, the sequence
of statements is assembled once, with symbol set to the null string. To refer
to symbol within the sequence of statements, use /symbol.
For example, assembling
.irpc param,123
move d/param,sp@-
.endr
is equivalent to assembling
move d1,sp@-
move d2,sp@-
move d3,sp@-

7.41 .irpc symbol,values. . .
加工一個需要用values替代symbol的語句序列。語句序列從.irpc命令開始,在.endr命令
前結束。對於value中的每個字符,都進行如下加工;用此字符替代symbol,並對此語句序
列進行彙編。如果沒有給出value參數,則用空字符串(null sting)替代symbol,並將此語
句序列彙編一次。使用/symbol, 把參數symbol提交給語句序列。
例如下列代碼
.irpc param,123
move d/param,sp@-
.endr
等同與
move d1,sp@-
move d2,sp@-
move d3,sp@-


7.42 .lcomm symbol , length
Reserve length (an absolute expression) bytes for a local common denoted by sy
mbol. The section and value of symbol are those of the new local common. The a
ddresses are allocated in the bss section, so that at run-time the bytes start
off zeroed. Symbol is not declared global (see Section 7.31 [.global], page 4
2), so is normally not visible to ld.
Some targets permit a third argument to be used with .lcomm. This argument spe
cifies the desired alignment of the symbol in the bss section.
The syntax for .lcomm differs slightly on the HPPA. The syntax is ‘symbol .lc
omm, length’; symbol is optional.

7.42 .lcomm symbol , length
爲一個本地通用符號symbol預留length個字節的內存。symbol 的段(屬性)和值(屬性)被設
置爲一個新的本地通用符號應有的屬性:內存是在bss段中分配的,所以在運行時,這些字
節開始都是零。因爲symbol沒有被聲明爲全局性的符號,所以symbol對ld通常不可見。

某些目標格式允許在.lcomm命令中使用第3個參數。這個參數指出這個bss段中的符號對齊
操作所需要的邊界基準。
.lcomm的語法在HPPA上稍有不同。表示爲‘symbol .lcomm, length’; symbol 是可選的



7.43 .lflags
as accepts this directive, for compatibility with other assemblers, but ignore
s it.

7.43 .lflags
as接受本命令,以兼容其他的彙編器,但忽略之。


7.44 .line line-number
Change the logical line number. line-number must be an absolute expression. Th
e next line has that logical line number. Therefore any other statements on th
e current line (after a statement separator character) are reported as on logi
cal line number line-number - 1. One day as will no longer support this direct
ive: it is recognized only for compatibility with existing assembler programs.

Warning: In the AMD29K configuration of as, this command is not available; use
the synonym .ln in that context.
Even though this is a directive associated with the a.out or b.out object-code
formats, as still recognizes it when producing COFF output, and treats ‘.lin
e’ as though it were the COFF ‘.ln’ if it is found outside a .def/.endef pa
ir.
Inside a .def, ‘.line’ is, instead, one of the directives used by compilers
to generate auxiliary symbol information for debugging.

7.44 .line line-number
更改邏輯行號,參數line-number必須是個純粹的表達式。本命令後的下一行將被賦予此邏
輯行號。因此在當前行之前任何其他的語句(在語句分隔符後)的邏輯行號將被視作line
-number - 1。以後 as將不在支持這條命令:只是爲了兼容現存的彙編器而接受本命令。

Warning: 在爲AMD29K目標機器配置的as中,不能使用本指令。在這種場合可以使用.ln命令

儘管這是與a. out或b. out目標代碼格式相關的命令,在生成COFF輸出時as仍然接受它,
並且如果‘.line’出現在.def/endef之外的話,就把它視爲‘.ln’命令。
如果‘.line’在.def語句塊中的話,.line命令則是一條編譯器使用的命令,用來爲調式
生成輔助符號信息。


7.45 .linkonce [type]
Mark the current section so that the linker only includes a single copy of it.
This may be used to include the same section in several different object file
s, but ensure that the linker will only include it once in the final output fi
le. The .linkonce pseudo-op must be used for each instance of the section. Dup
licate sections are detected based on the section name, so it should be unique
.
This directive is only supported by a few object file formats; as of this writ
ing, the only object file format that supports it is the Portable Executable f
ormat used on Windows NT.
The type argument is optional. If specified, it must be one of the following s
trings. 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.45 .linkonce [type]
給當前段做一個標誌,以便連接器只包含它的一個拷貝。這個命令可以用於幾個不同的目標
文件中包含同樣的段,但需要連接器在最終的輸出文件中只包含一個這樣的段。. linkou
ce僞操作必須在每個段的實例都中使用。對重複段的探測基於段名來進行,因此這個段將
是唯一的。
本命令只在少數目標格式文件中有效,到寫本文爲止,只有基於Windows NT的PE (Portab
le Executable)格式的目標文件支持本命令,
參數type是可選的,如果指定了此參數,它必須是下列字符串之一。例如
. Linkonce same_size
不是在所有的格式目標文件都可以使用所有類型的參數。
discard 靜靜地捨棄重複的段,這也是默認值。
one_only 如果存在重複的段則發出警告,但只保存一個拷貝。
same_size 如果重複的段有不同的大小則發出警告。
same_contents 如果重複段的內容不是精確的相符則發出警告。


7.46 .ln line-number
‘.ln’ is a synonym for ‘.line’.

7.46 .ln line-number
‘.ln’命令等同與‘.line’.


7.47 .mri val
If val is non-zero, this tells as to enter MRI mode. If val is zero, this tell
s as to exit MRI mode. This change affects code assembled until the next .mri
directive, or until the end of the file. See Section 2.8 [MRI mode], page 13.


7.47 .mri val
如果參數val是非零值,這將通知as進入MRI模式。如果參數val的值是零,這通知as退出M
RI模式。這個變化會影響彙編的結果,直到下個.mri命令,或者直到文件尾。見2.8 [MRI
mode], 13頁。


7.48 .list
Control (in conjunction with the .nolist directive) whether or not assembly li
stings 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’ comma
nd line option; see Chapter 2 [Command-Line Options], page 11), the initial va
lue of the listing counter is one.

7.48 .list
控制(和.nolist命令配合)是否生成彙編清單。這兩個命令維護一個內部的計數器(計數
器初始值爲0).list命令增加計數器的值,.nolist減少計數器的值。當計數器的值大與0
時將彙編列表。
缺省狀態彙編列表的生成是關閉的。當您打開它的時候(使用帶-a選項的命令行)第2章
[Command-Line Options], 11頁), 內部計數器的初始值爲1。


7.49 .long expressions
.long is the same as ‘.int’, see Section 7.38 [.int], page 44.

7.49 .long expressions
.long是.int的等價命令,見7.38 [.int], 44頁.

rickxbx 05-09-22 11:56

7.50 .macro
The commands .macro and .endm allow you to define macros that generate assembl
y output. For example, this definition specifies a macro sum that puts a seque
nce of numbers into memory:
.macro sum from=0, to=5
.long /from
.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 requi
res arguments, specify their names after the macro name, separated by commas o
r spaces. You can supply a default value for any macro argument by following t
he name with ‘=deflt’. For example, these are all valid .macro statements:


.macro comm
Begin the definition of a macro called comm, which takes no arguments.
.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 t
he arguments.
.macro reserve_str p1=0 p2
Begin the definition of a macro called reserve_str, with two arguments. The fi
rst 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).
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
’.
.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 pseudov-a
riable; you can copy that number to your output with ‘/@’, but only within a
macro definition.


7.50 .macro
本命令.macro和.endm命令允許您定義宏來生成彙編輸出。例如,下面的語句定義了一個宏
sum,這個宏把一個數字序列放入內存。

.macro sum from=0, to=5
.long /from
.if /to-/from
sum "(/from+1)",/to
.endif
.endm
使用上述定義,'SUM 0,5'語句就等於輸入下面的彙編語句:
.long 0
.long 1
.long 2
.long 3
.long 4
.long 5

.macro macname
.macro macname macargs ...
開始定義一個名爲macname的宏。如果您的宏需要使用參數,則在宏的名字後指定他們的名
字,參數之間用逗號或空格分隔。您可以爲任意的參數提供參數的缺省值,只需要在參數
後使用“=deflt”,。例如,下列都是合法的宏定義語句:
.macro comm
定義一個名爲comm宏,不使用參數。
.macro plus1 p, p1
.macro plus1 p p1
兩個語句都聲明要定義一個名爲plus1的宏,這個宏需要兩個參數,在宏定義體內,使用'
/p'或'/p1'來引用參數的值。
.macro reserve_str p1=0 p2
聲明要定義一個名爲reserve_str的宏,使用兩個參數。第一個參數有缺省值,第二個沒有
缺省值。宏定義完成後,您可以通過‘reserve_str a, b’(宏體中‘/p1’引用a的值,‘
/p2’引用b值)或通過‘reserve_str ,b’(‘/p1’使用缺省值,在此爲‘0’,‘/p2’引
用b的值)來調用這個宏。

當調用一個宏時,您既可以通過位置指定參數值,也可以通過關鍵字指定參數值。例如,
‘sum 9,17’和‘sum to=17, from=9’是等價的。
.endm 標誌宏定義體的結束。
.exitm 提前從當前宏定義體中退出。
/@ 這個僞變量其實是as維護的一個計數器,用來統計執行了多少個宏。您可以通過使用/
@把這個數字複製到您的輸出中,但僅限於在宏定義體中使用。


7.51 .nolist
Control (in conjunction with the .list directive) whether or not assembly list
ings are generated. These two directives maintain an internal counter (which i
s zero initially). .list increments the counter, and .nolist decrements it. As
sembly listings are generated whenever the counter is greater than zero.

7.51 .nolist
控制(和.list命令配合)是否生成彙編列表。這兩個命令維護一個內部的計數器(計數器
初始值爲0).list命令增加計數器的值,.nolist減少計數器的值。當計數器的值大與0時
將彙編列表。


7.52 .octa bignums
This directive expects zero or more bignums, separated by commas. For each big
num, it emits a 16-byte integer.
The term “octa” comes from contexts in which a “word” is two bytes; hence
octa-word for 16 bytes.

7.52 .octa bignums
本命令可以不帶參數或多個由逗號分隔開的巨數bignum,針對每個巨數bignum,它生成一個
16個字節的整數。
術語"octa"來源:word爲2個字節,故此octa-word爲16個字節。


7.53 .org new-lc , fill
Advance the location counter of the current section to new-lc. new-lc is eithe
r an absolute expression or an expression with the same section as the current
subsection. That is, you can’t use .org to cross sections: if new-lc has the
wrong section, the .org directive is ignored. To be compatible with former as
semblers, if the section of new-lc is absolute, as issues a warning, then pret
ends the section of new-lc is the same as the current subsection.
.org may only increase the location counter, or leave it unchanged; you cannot
use .org to move the location counter backwards.
Because as tries to assemble programs in one pass, new-lc may not be undefined
. If you really detest this restriction we eagerly await a chance to share you
r improved assembler.
Beware that the origin is relative to the start of the section, not to the sta
rt of the subsection. This is compatible with other people’s assemblers.
When the location counter (of the current subsection) is advanced, the interve
ning bytes are filled with fill which should be an absolute expression. If the
comma and fill are omitted, fill defaults to zero.

7.53 .org new-lc , fill
向後移動當前段的位置計數器至new-lc。new-lc要麼是一個純粹的表達式,要麼這個表達
式與當前子段在同一個段中。換句話說,就是您不能使用.org進行段超越。如果new-lc指
向錯誤的段,則忽略.org命令。爲了兼容以前的彙編器,如果new-lc指向一個地址獨立的
段,as發出一個警告,並假定new-lc指向當前子段。
.org 僅僅可以增大位置計數器,或者保持位置計數器不變;您不能使用.org命令把位置計
數器向回移動。
因爲as儘量一次完成程序彙編,所以不能使用未定義的new-lc。如果您厭惡這個限制,我
們急切期待有機會分享經過您改進的彙編器。
注意起點相對於段的首地址,而不是子段的首地址。這與其他的彙編器相兼容。
當(當前語句塊)位置計數器到達指定位置,用fill填充該字節,fill必須是純粹的表達
式。如果沒有給出逗號和fill,fill值缺省爲0。


7.54 .p2align[wl] abs-expr, abs-expr, abs-expr
Pad the location counter (in the current subsection) to a particular storage b
oundary. The first expression (which must be absolute) is the number of low-or
der zero bits the location counter must have after advancement. For example ‘
.p2align 3’ advances the location counter until it a multiple of 8. If the lo
cation counter is already a multiple of 8, no change is needed.
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 paddi
ng bytes are normally zero. However, on some 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 di
rective. If doing the alignment would require skipping more bytes than the spe
cified maximum, then the alignment is not done at all. You can omit the fill v
alue (the second argument) entirely by simply using two commas after the requi
red 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 directives treats the fill pattern as a four byte longword value. F
or 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 th
e bytes depends upon the endianness of the processor). If it skips 1 or 3 byte
s, the fill value is undefined.

7.54 .p2align[wl] abs-expr, abs-expr, abs-expr
增加位置計數器(在當前的子段)使它指向規定的存儲邊界。第一個表達式參數(結果必須是
純粹的數字) 代表位置計數器移動後,計數器中連續爲0的低序位數量。例如‘.align 3’
向後移動位置指針直至8的倍數(指針的最低的3位爲0)。如果地址已經是8倍數,則無需
移動。
第二個表達式參數(結果必須是純粹的數字)給出填充字節的值。用這個值填充位置計數器
越過的地方。這個參數(和逗點)可以省略。如果省略它,填充字節的值通常默認爲0。但在
某些系統上,如果本段標識爲包含代碼,而填充值被省略,則使用no-op指令填充填充區。

第3個參數表達式的結果也必須是純粹的數字,這個參數是可選的。如果存在第3個參數,
它代表本對齊命令允許越過字節數的最大值。如果完成這個對齊需要跳過的字節比指定的
最大值還多,則根本無法完成對齊。您可以在邊界基準後簡單地使用兩個逗號,以省略填充
值參數(第二參數);如果您想在適當的時候,對齊操作自動使用no-op指令填充,這個方法
將非常奏效。
.p2alignw和.p2alignl是.p2align命令的變化形式。.p2alignw 使用2個字節來填充填充區
。.p2alignl使用4字節來填充。例如,. .p2alignw 2,0x368d將地址對齊到4的倍數,如果
它跳過2個字節,GAS將使用0x368d填充這2個字節(字節的準確的位置視處理器的存儲方式
而定)。如果它跳過1或3個字節,填充值則不明確。


7.55 .previous
This is one of the ELF section stack manipulation directives. The others are .
section (see Section 7.66 [Section], page 52), .subsection (see Section 7.79 [
SubSection], page 56), .pushsection (see Section 7.61 [PushSection], page 50),
and .popsection (see Section 7.56 [PopSection], page 50).
This directive swaps the current section (and subsection) with most recently r
eferenced section (and subsection) prior to this one. Multiple .previous direc
tives in a row will flip between two sections (and their subsections).
In terms of the section stack, this directive swaps the current section with t
he top section on the section stack.

7.55 .previous
這是一個ELF段堆棧操作命令。其他的段堆棧操作命令還有.section (見 7.66 [Section]
, 52頁), .subsection (見 7.79 [SubSection], 56頁),.pushsection (見 7.61 [PushS
ection], 50頁), 和 .popsection (見 7.56 [PopSection], 50頁)。
本命令交換當前段(及其子段)和最近訪問過的段(及其子段)。多個連續的.previous命
令將使當前位置兩個段(及其子段)之間反覆切換。
用段堆棧的術語來說,本命令使當前段和堆頂段交換位置。


7.56 .popsection
This is one of the ELF section stack manipulation directives. The others are .
section (see Section 7.66 [Section], page 52), .subsection (see Section 7.79 [
SubSection], page 56), .pushsection (see Section 7.61 [PushSection], page 50),
and .previous (see Section 7.55 [Previous], page 49).
This directive replaces the current section (and subsection) with the top sect
ion (and subsection) on the section stack. This section is popped off the stac
k.

7.56 .popsection
這是一個ELF段堆棧操作命令。其他的段堆棧操作命令還有.section(見 7.66 [Section],
52頁), .subsection (見 7.79 [SubSection], 56頁),.pushsection (見 7.61 [PushSe
ction], 50頁), 和 .previous (見 7.55 [Previous], 49頁).
本命令用堆棧頂段(及其子段)替代當前段(及其子段)。堆棧頂段出棧。

7.57 .print string
as will print string on the standard output during assembly. You must put stri
ng in double quotes.

7.57 .print string
as會在標準輸出上打印string字符串。String必須使用雙引號。


7.58 .protected names
This one of the ELF visibility directives. The other two are .hidden (see Sect
ion 7.32 [Hidden], page 42) and .internal (see Section 7.39 [Internal], page 4
4).
This directive overrides the named symbols default visibility (which is set by
their binding: local, global or weak). The directive sets the visibility to p
rotected which means that any references to the symbols from within the compon
ents that defines them must be resolved to the definition in that component, e
ven if a definition in another component would normally preempt this.

7.58 .protected names
這是一條ELF可見度的相關命令。其它兩條是.hidden (參見 7.32 [Hidden], 42頁)和 .i
nternal (參見 7.39 [Internal], 44頁)。
本命令將取消指定符號的可見度缺省值(可見度由其他命令捆綁設定:local, global, w
eak)本命令將可見度設置爲protected,這個可見度意味着:在定義此符號的部件內對此符
號的任何訪問,都必須解析到這個部件內的定義體。即使其他部件中存在一個正常情況下
比此優先的定義體。

7.59 .psize lines, columns
Use this directive to declare the number of lines—and, optionally, the number
of columns—to use for each page, when generating listings.
If you do not use .psize, listings use a default line-count of 60. You may omi
t the comma and columns specification; the default width is 200 columns.
as generates formfeeds whenever the specified number of lines is exceeded (or
whenever you explicitly request one, using .eject).
If you specify lines as 0, no formfeeds are generated save those explicitly sp
ecified with .eject.

7.59 .psize lines , columns
當生成清單列表時,使用本命令聲明每頁的行數—還可以可選地聲明列數。
如果您不使用本命令,清單列表的行數爲默認的60行。可以省略逗號和列參數:默認值爲
200列。
當指定的行數過多的話,as會產生進紙操作。(如果您確實需要一個進紙動作,可以使用
.eject命令)
如果您指定行數爲0,則不產生進紙操作,除非您明確地使用了.eject命令。


7.60 .purgem name
Undefine the macro name, so that later uses of the string will not be expanded
. See Section 7.50 [Macro], page 47.

7.60 .purgem name
取消name的宏定義,後面使用字符串name不會被宏擴展。參見 7.50 [Macro], 47頁。


7.61 .pushsection name , subsection
This is one of the ELF section stack manipulation directives. The others are .
section (see Section 7.66 [Section], page 52), .subsection (see Section 7.79 [
SubSection], page 56), .popsection (see Section 7.56 [PopSection], page 50), a
nd .previous (see Section 7.55 [Previous], page 49).
This directive is a synonym for .section. It pushes the current section (and s
ubsection) onto the top of the section stack, and then replaces the current se
ction and subsection with name and subsection.

7.61 .pushsection name , subsection
本命令是一個ELF段堆棧操作命令。其餘的幾個是.section (參見 7.66 [Section], 52頁
) , .subsection (參見7.79 [SubSection], 56頁),.popsection (參見 7.56 [PopSecti
on], 50頁), 和 .previous (參見 7.55 [Previous], 49頁)。
本命令與.section命令是等價的。它將當前段(及子段)推入段堆棧的頂部。並使用name
和subsection來替代當前段和子段。

7.62 .quad bignums
.quad expects zero or more bignums, separated by commas. For each bignum, it e
mits an 8-byte integer. If the bignum won’t fit in 8 bytes, it prints a warni
ng message; and just takes the lowest order 8 bytes of the bignum.
The term “quad” comes from contexts in which a “word” is two bytes; hence
quad-word for 8 bytes.

7.62 .quad bignums
.quad 可帶0或多個bignum參數,每個參數由逗號分隔。對於每個bignum都彙編成一個8字
節的整數。如果某個bignum用8字節無法表示,則給出警告信息;只彙編這個bignum的最低
8字節。
術語“quad”源於一個“word”代表2個字節,所以quad-word代表8個字節。

7.63 .rept count
Repeat the sequence of lines between the .rept directive and the next .endr di
rective count times.
For example, assembling
.rept 3
.long 0
.endr
is equivalent to assembling
.long 0
.long 0
.long 0

7.63 .rept count
彙編.rept和.endr之間的語句count次。
如, 彙編下列語句:
.rept 3
.long 0
.endr
與下列語句是等價的:
.long 0
.long 0
.long 0

7.64 sbttl "subheading"
Use subheading as the title (third line, immediately after the title line) whe
n generating assembly listings.
This directive affects subsequent pages, as well as the current page if it app
ears within ten lines of the top of a page.

7.64 sbttl "subheading"
當生成彙編清單時,使用subheading作爲標題(第3行,緊跟在標題行之後)。
本命令對清單的後續頁起作用,如果它位於當前頁的前10行內,則對當前頁也起作用。



7.65 .scl class
Set the storage-class value for a symbol. This directive may only be used insi
de a .def/.endef pair. Storage class may flag whether a symbol is static or ex
ternal, or it may record further symbolic debugging information.
The ‘.scl’ directive is primarily associated with COFF output; when configur
ed to generate b.out output format, as accepts this directive but ignores it.


7.65 .scl class
設置一個符號的存儲類型值(storage-class value)。本命令只能在.def/.endef之間使
用。符號的存儲類型可以表明符號是static類型或是external類型,或者進一步記錄符號
的調試信息。
‘.scl’命令主要與在COFF輸出有關,當生成b.out輸出格式時,as接受本命令,但忽略本
命令。




7.66 .section name (COFF version)
Use the .section directive to assemble the following code into a section named
name.
This directive is only supported for targets that actually support arbitrarily
named sections; on a.out targets, for example, it is not accepted, even with
a standard a.out section name.
For COFF targets, the .section directive is used in one of the following ways:

.section name [, "flags"]
.section name [, subsegment]
If the optional argument is quoted, it is taken as flags to use for the sectio
n. 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
r read-only section
x executable section
s shared section (meaningful for PE targets)
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 n
o flags had been specified at all.
If the optional argument to the .section directive is not quoted, it is taken
as a subsegment number (see Section 4.4 [Sub-Sections], page 25).

7.66 .section name (COFF 版本)
使用.section命令將後續的代碼彙編進一個定名爲name的段。
本命令只能在目標格式真正支持任意命名段時使用;例如,彙編一個a.out目標格式時,即
使name是一個標準的a.out段名,本命令也不被接受。
當目標格式爲COFF時,.section命令的使用爲下面某一種格式:
.section name[, "flags"]
.section name[, subsegment]
如可選參數使用了引號,它將被視爲該段的標誌(flags)。每個標記是單個的字符。下列是
認可的標誌。
b bss 段 (未初始化的數據)
n 未裝入內存的段
w 可寫的段
d 數據段
r 只讀段
x 代碼段 (executable section)
s 共享段 (目標爲PE格式有意義)
如果本命令沒有指定標誌,則依靠段名來確定標誌缺省值。如果該段名沒有使用標準段名
,則默認該段已裝入內存並且可寫。注意在使用n和w標誌組合時,不是增加這組屬性,而
是刪除該段的屬性。所以如果只存在這兩個標誌,就代表該段沒有指定任何標誌。
如果本命令的可選參數沒有使用引號,參數將被視爲子段的編號。(參見 4.4 [Sub-Secti
ons], 25頁)。



7.67 .section name (ELF 版本)
This is one of the ELF section stack manipulation directives. The others are .
subsection (see Section 7.79 [SubSection], page 56), .pushsection (see Section
7.61 [PushSection], page 50), .popsection (see Section 7.56 [PopSection], pag
e 50), and .previous (see Section 7.55 [Previous], page 49).
For ELF targets, the .section directive is used like this:
.section name [, "flags"[, @type]]
The optional flags argument is a quoted string which may contain any combinati
on of the following characters:
a section is allocatable
w section is writable
x section is executable
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)

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 hav
e none of the above flags: it will not be allocated in memory, nor writable, n
or executable. The section will contain data.
For ELF targets, the assembler supports another type of .section directive for
compatibility with the Solaris assembler:
.section "name"[, flags...]
Note that the section name is quoted. There may be a sequence of comma separat
ed flags:
#alloc section is allocatable
#write section is writable
#execinstr section is executable
This directive replaces the current section and subsection. The replaced secti
on and subsection are pushed onto the section stack. See the contents of the g
as testsuite directory gas/testsuite/gas/elf for some examples of how this dir
ective and the other section stack directives work.

7.67 .section name (ELF 版本)
本命令是ELF的段堆棧操作命令之一,其他的段堆棧命令爲.subsection (見 Section 7.7
9 [SubSection], page 56), .pushsection (見Section 7.61 [PushSection], page 50)
, .popsection (見 Section 7.56 [PopSection], page 50), and .previous (見 Secti
on 7.55 [Previous], page 49).
當目標格式爲ELF時,.section命令應如下使用:
.section name [, "flags"[, @type]]
可選參數flags是被引號包圍的字符串,可以由下列字符的任意組合:
a 可分配的段(allocatable)
w 可寫段
x 代碼段
可選的參數type可以包含下列的任一常量:
@progbits 包含數據的段
@nobits 不包含數據的段(只佔用空間的段)
如果本命令沒有指定標誌,則依靠段名來確定標誌缺省值。如果段名不是標準的段名,則
默認的該段不包含上述標誌:該段不可分配內存,不可寫,不可執行。該段是包含數據的
段。
當目標格式爲ELF時,as還支持另一種形式的.section命令,以便兼容Solaris的彙編器:

.section "name"[, flags...]
注意段名是使用引號包圍的,可能存在一系列由逗號分隔分隔的標誌:
#alloc 可分配的段(section is allocatable)
#write 可寫的段
#execinstr 可執行的段
本命令將(用段名爲name的段)替代當前段和子段。被替換的段將被推入段堆棧。參見ga
s的測試套件目錄gas/testsuite/gas/elf,可以找到一些本命令和其他段堆棧操作命令的
例子。

7.68 .set symbol, expression
Set the value of symbol to expression. This changes symbol’s value and type t
o conform to expression. If symbol was flagged as external, it remains flagged
(see Section 5.5 [Symbol Attributes], page 30).
You may .set a symbol many times in the same assembly.
If you .set a global symbol, the value stored in the object file is the last v
alue stored into it.
The syntax for set on the HPPA is ‘symbol .set expression’.

7.68 .set symbol, expression
設置symbol爲expression。這將改變symbol的值域和類型領域以符合expression參數。如
果symbol已被標誌爲external,則symbol保持它的標誌。(見 5.5 [Symbol Attributes],
30頁)。
您可以在同一個彙編程序中多次使用.set命令來設置同一個符號。
如果設置一個全局符號,該符號在目標文件中值爲最後設定的值。
在HPPA上的語法是‘symbol .set expression’。

7.69 .short expressions
.short is normally the same as ‘.word’. See Section 7.92 [.word], page 59.

In some configurations, however, .short and .word generate numbers of differen
t lengths; see Chapter 8 [Machine Dependencies], page 61.

7.69 .short expressions
本命令通常和’.word’命令一樣,見7.92 [.word], 59頁.
然而在某些配置中,.short和.word命令生成的數字長度卻不相同;見第8章 [Machine De
pendencies], 61頁.



7.70 .single flonums
This directive assembles zero or more flonums, separated by commas. It has the
same effect as .float. The exact kind of floating point numbers emitted depen
ds on how as is configured. See Chapter 8 [Machine Dependencies], page 61.

7.70 .single flonums
本命令可以彙編0個或多個浮點參數,各個參數之間使用逗號分隔。它的作用和.float相同
。生成浮點數的具體類型視as的配置而定。見第8章 [Machine Dependencies], 61頁。






--------------------
一切有爲法 如夢幻泡影




# 回覆:linux下彙編的Directive Operands 2004-09-08 3:25 PM n9871009
Re: 7 彙編器命令(下) [re: amtb]



位組合:bit pattern,想不出有什麼特別的意義,大概指的是有限個數的0和1所有的組合
吧。Fix me.
sleb128/uleb128: 基於128位的低地址結尾帶/無符號的數。您有什麼好建議?
==========================下==================================
7.71 .size (COFF 版本)
This directive is generated by compilers to include auxiliary debugging inform
ation in the symbol table. It is only permitted inside .def/.endef pairs.
‘.size’ is only meaningful when generating COFF format output; when as is ge
nerating b.out, it accepts this directive but ignores it.

7.71 .size (COFF 版本)
本命令一般由編譯器生成,以在符號表中加入輔助調試信息。本命令只能在.def/.endef命
令對之間使用。
本命令只在生成COFF格式的輸出文件有意義。當as生成b.out時,as接受本命令但忽略之。




7.72 .size name , expression (ELF 版本)
This directive is used to set 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.
本命令經常用來設置符號name的內存大小。內存大小的單位是字節, 通過計算參數expres
sion得到,參數expression中可以使用標籤進行計算。本命令常用來設置函數符號的長度


7.73 .sleb128 expressions
sleb128 stands for “signed little endian base 128.” This is a compact, varia
ble length representation of numbers used by the DWARF symbolic debugging form
at. See Section 7.86 [Uleb128], page 58.

7.73 .sleb128 expressions
sleb128代表“signed little endian base 128”(低地址結尾的帶符號128位基數)。這是
一個緊湊的,變長的數字表示方法,當使用DWARF符號調試格式時使用。參見7.86 [Uleb1
28], 58頁。



7.74 .skip size , fill
This directive emits size bytes, each of value fill. Both size and fill are ab
solute expressions. If the comma and fill are omitted, fill is assumed to be z
ero. This is the same as ‘.space’.

7.74 .skip size , fill
本命令生成size個字節,每個字節的值都是fill。參數size和fill都必須是純粹的表達式
。如果省略逗號和fill,則默認fill的值爲0。這與’.space’相同。



7.75 .space size , fill
This directive emits size bytes, each of value fill. Both size and fill are ab
solute expressions. If the comma and fill are omitted, fill is assumed to be z
ero. This is the same as ‘.skip’.
Warning: .space has a completely different meaning for HPPA targets; use .bloc
k as a substitute. See HP9000 Series 800 Assembly Language Reference Manual (H
P 92432-90001) for the meaning of the .space directive. See Section 8.8.5 [HPP
A Assembler Directives], page 84, for a summary.
On the AMD 29K, this directive is ignored; it is accepted for compatibility wi
th other AMD 29K assemblers.
Warning: In most versions of the gnu assembler, the directive .space has the e
ffect of .block See Chapter 8 [Machine Dependencies], page 61.

7.75 .space size , fill
本命令生成size個字節,每個字節的值都是fill。參數size和fill都必須是純粹的表達式
。如果省略了逗號和fill,則默認fill的值爲0。這與’.skip’相同。
警告:在生成HPPA目標格式時,.space的意義完全不同。應該使用.block命令替代本命令
。在HP9000系列800彙編語言參考手冊(HP 92432-90001),可以找到.space命令的用法。參
見 8.8.5 [HPPA Assembler Directives],84頁, 可以找到使用摘要。
在AMD 29K上,本命令將被忽略。出於兼容其它一些AMD 29K彙編器的目的,as接受本命令

警告:在gnu彙編器大多數版本中,這個.space命令和.block命令等效。見第8章 [Machin
e Dependencies], 61頁。

7.76 .stabd, .stabn, .stabs
There are three directives that begin ‘.stab’. All emit symbols (see Chapter
5 [Symbols], page 29), for use by symbolic debuggers. The symbols are not ent
ered in the as hash table:they cannot be referenced elsewhere in the source fi
le. Up to five fields are required:
string This is the symbol’s name. It may contain any character except ‘/000’
, so is more general than ordinary symbol names. Some debuggers used to code a
rbitrarily complex structures into symbol names using this field.
type An absolute expression. The symbol’s type is set to the low 8 bits of th
is expression. Any bit pattern is permitted, but ld and debuggers choke on sil
ly bit patterns.
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 bit
s of this expression.
Value An absolute expression that 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 pro
gram is linked, the value of this symbol is the address of the location counte
r 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.

7.76 .stabd, .stabn, .stabs
有3個以.stab開頭的命令。它們都用來產生符號,(參見第5章 [Symbols], 29頁),供符號
調試器使用。這些符號沒有收入as的散列表中:這些符號不能被源文件其他地方所訪問。
它們至少需要5個屬性域:
string 這是符號的名字。它可以包含除‘/000’之外的任何字符,故此可用名比普通符號
名更廣泛。很多調試器經常利用這個空間,把任意複雜的結構編碼爲符號名。
type 這是一個純粹的表達式。符號的類型屬性由這個表達式的低8位設定。任何的位組合
(bit pattern)都可以,但連接器和調試器會被沒有義的位組合所中斷。
other 這是一個純粹的表達式。由這個表達式的低8位設定此符號的“其它”屬性。
desc 這是一個純粹的表達式。由這個表達式的低16位設定此符號的描述符。
Value 這個純粹的表達式將作爲符號的值。

如果彙編.stabd, .stabn, 或 .stabs語句時引發了一個警告,該符號有可能已經被創建;
在目標文件中存在一個半成品的符號。這樣做兼容於早期的彙編器!

.stabd type , other , desc
生成符號的“名字”甚至不是空字符串,而是一個空指針(null),這樣安排是出於對兼
容性要求。早期的彙編器經常使用空指針,以避免空字符串在目標文件中浪費空間。
這個符號的值(值域)在重定位時設置爲位置計數器的值。當程序連接之後,這個符號的
值是.stabd命令彙編時位置計數器的地址。
.stabn type , other , desc , value
這個符號的名字被設置爲空字符串“”。
.stabs string , type , other , desc , value
5個屬性域全部指定好。



7.77 .string "str"
Copy the characters in str to the object file. You may specify more than one s
tring to copy, separated by commas. Unless otherwise specified for a particula
r machine, the assembler marks the end of each string with a 0 byte. You can u
se any of the escape sequences described in Section 3.6.1.1 [Strings], page 19
.

7.77 .string "str"
將參數str中的字符複製到目標文件中去。您可以指定多個字符串進行復制,之間使用逗號
分隔。除非另外指定了具體的機器,彙編器將在每個字符串後追加一個0字節作爲標記。您
可以使用任意的逃逸序列,參見19頁中3.6.1.1 [Strings]的描述。



7.78 .struct expression
Switch to the absolute section, and set the section offset to expression, whic
h must be an absolute expression. You might use this as follows:
.struct 0
field1:
.struct field1 + 4
field2:
.struct field2 + 4
field3:
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.78 .struct expression
切換到獨立地址段,並用expression設定段的偏移量,expression必須是個純粹的表達式
。您可以如下使用:
.struct 0
field1:
.struct field1 + 4
field2:
.struct field2 + 4
field3:

定義符號field1的值爲0,符號field2的值爲4,符號field3的值爲8。這段彙編程序將保存
在獨立地址段中,在進行下一步彙編前,您需要使用一個某種類型的.section命令,以切
換到相應的段。



7.79 .subsection name
This is one of the ELF section stack manipulation directives. The others are .
section (see Section 7.66 [Section], page 52),.pushsection (see Section 7.61 [
PushSection], page 50), .popsection (see Section 7.56 [PopSection], page 50),
and .previous (see Section 7.55 [Previous], page 49).
This directive replaces the current subsection with name. The current section
is not changed. The replaced subsection is put onto the section stack in place
of the then current top of stack subsection.

7.79 .subsection name
本命令是一個ELF段堆棧操作命令。其它的幾個命令是(參見 7.66 [Section], 52頁),
.pushsection (參見 7.61 [PushSection],50頁), .popsection (參見 7.56 [PopSectio
n], 50頁), and .previous (參見7.55 [Previous], 49頁)。
本命令用name子段替換當前子段。當前段並不改變。被替換的子段入段堆棧,成爲段堆棧
的新棧頂。



7.80 .symver
Use the .symver directive to bind symbols to specific version nodes within a s
ource file. This is only supported on ELF platforms, and is typically used whe
n assembling files to be linked into a shared library. There are cases where i
t 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
If the symbol name is defined within the file being assembled, the .symver dir
ective 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 th
at the @ character isn’t permitted in symbol names. The name2 part of the nam
e 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 i
s possible to have definitions for multiple versions of a function within a si
ngle source file, and so that the compiler can unambiguously know which versio
n of a function is being mentioned. The nodename portion of the alias should b
e the name of a node specified in the version script supplied to the linker wh
en building a shared library. If you are attempting to override a versioned sy
mbol from a shared library, then nodename should correspond to the nodename of
the symbol you are trying to override.
If the symbol name is not defined within the file being assembled, all referen
ces 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
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 nam
e2@nodename. When name is defined within the file being assembled, the symbol
name, name, will be changed to name2@@nodename.

7.80 .symver
使用.symver命令把符號裝訂到在源文件裏指定的節點。本命令只在ELF平臺上可用,如果
當前彙編的文件被連接到一個共享庫中時常常用到。有些情況下應該在目標文件中使用本
命令,把目標文件自我裝訂進某個應用軟件中,從而取代共享庫中舊版本符號。
對於ELF目標,.symver命令可以這樣使用:
.symver name, name2@nodename
如果符號name的定義在當前正在彙編的文件中,這個.symver命令實際用name2@nodename創
建一個符號別名,而且我們不打算創建一個正規的別名,因爲在符號名中是不允許存在‘
@’這個字符的。別名中name2纔是符號的真正名字,外部訪問是通過這個名字進行的。符
號自己的名字name僅僅爲了使用上的方便,這樣在同一個源文件中的一個函數纔可能有多
個定義體;編譯器才能夠清楚當前使用的函數是哪個具體的定義。別名中的nodename部分
應是某個節點的名字,這個節點的名字是在建立共享庫時,提供給連接器的版本腳本中指
定的。如果您想覆蓋共享庫中的舊版本符號,則nodename應該是將被取代符號的節點名。

如果符號name的定義不在當前正在彙編的文件中,則所有對name的訪問都變爲對name2@no
dename的訪問。如果根本沒有對name的訪問,將會把name2@nodename從符號表中刪除。

.symver命令的另一種用法:
.symver name, name2@@nodename
在這種情況下,符號name必須存在,並且它必須在當前正在彙編的文件中被定義。這類似
與name2@nodename。區別是name2@@nodename還被連接器用來解析對name2的訪問。//注:
對name2的訪問被轉向到nodename
.symver命令的第3種用法:
.symver name, name2@@@nodename
如果name不是在當前正在彙編的文件中被定義的時候,對符號的處理就如同name2@nodena
me。如果name是當前正在彙編的文件中定義的,符號的名字name,會被轉換爲name2@@nod
ename。



7.81 .tag structname
This directive is generated by compilers to include auxiliary debugging inform
ation in the symbol table. It is only permitted inside .def/.endef pairs. Tags
are used to link structure definitions in the symbol table with instances of
those structures.
‘.tag’ is only used when generating COFF format output; when as is generatin
g b.out, it accepts this directive but ignores it.

7.81 .tag structname
本命令由編譯器生成,用來在符號表中增加調試輔助的信息。本命令只允許在.def/.ende
f語句對內使用。標飾(tags)常用來連接符號表中的結構定義和該結構實例。
‘.tag’只能在生成COFF格式的輸出文件時使用。當as生成b.out格式的輸出文件時,接受
本命令但忽略之。



7.82 .text subsection
Tells as to assemble the following statements onto the end of the text subsect
ion numbered subsection, which is an absolute expression. If subsection is omi
tted, subsection number zero is used.

7.82 .text subsection
通知as把後續語句彙編到編號爲subsection的正文子段的末尾,subsection是一個純粹的
表達式。如果省略了參數subsection,則使用編號爲0的子段。


7.83 .title "heading"
Use heading as the title (second line, immediately after the source file name
and page number) when generating assembly listings.
This directive affects subsequent pages, as well as the current page if it app
ears within ten lines of the top of a page.

7.83 .title "heading"
當生成彙編清單時,把heading作爲標題使用(標題在第2行,緊跟在源文件名和頁號後)

如果這個命令出現在某頁的前10行中,它不但作用影響到後續的頁,也同樣影響到當前頁



7.84 .type int (COFF version)
This directive, permitted only within .def/.endef pairs, records the integer i
nt as the type attribute of a symbol table entry.
‘.type’ is associated only with COFF format output; when as is configured fo
r b.out output, it accepts this directive but ignores it.

7.84 .type int (COFF 版本)
本命令緊允許在.def/.endef 命令對之間使用,把整數int作爲類型屬性記錄進符號表表項

‘.type’只和COFF格式的輸出有關,當as配置生成b.out輸出格式時,as接受本命令但忽
略之。

7.85 .type name , type description (ELF version)
This directive is used to set the type of symbol name to be either a function
symbol or an object symbol. There are five different syntaxes supported for th
e type description field, in order to provide compatibility with various other
assemblers. The syntaxes supported are:

.type <name>,#function
.type <name>,#object

.type <name>,@function
.type <name>,@object

.type <name>,%function
.type <name>,%object

.type <name>,"function"
.type <name>,"object"

.type <name> STT_FUNCTION
.type <name> STT_OBJECT

7.85 .type name , type description (ELF 版本)
本命令經常用來設置符號name的類型(屬性)爲函數符號或是目標符號兩者之一。type d
escription部分允許使用5種不同的語法,以兼容衆多的彙編器。這些語法是:

.type <name>,#function
.type <name>,#object

.type <name>,@function
.type <name>,@object

.type <name>,%function
.type <name>,%object

.type <name>,"function"
.type <name>,"object"

.type <name> STT_FUNCTION
.type <name> STT_OBJECT


7.86 .uleb128 expressions
uleb128 stands for “unsigned little endian base 128.” This is a compact, var
iable length representation of numbers used by the DWARF symbolic debugging fo
rmat. See Section 7.73 [Sleb128], page 54.

7.86 .uleb128 expressions
uleb128代表“unsigned little endian base 128”(低地址結尾的無符號128位基數)。這
是一個緊湊的,變長的數字表示方法,當使用DWARF符號調試格式時使用。參見7.83 [Sle
b128], 54頁。



7.87 .val addr
This directive, permitted only within .def/.endef pairs, records the address a
ddr as the value attribute of a symbol table entry.
‘.val’ is used only for COFF output; when as is configured for b.out, it acc
epts this directive but ignores it.

7.87 .val addr
本命令只能在.def/.endef命令對之間使用,把addr的地址作爲值屬性存入符號表的表項中

‘.val’命令只能在COFF輸出時使用;當as被配置成生成b.out輸出時,接受本命令但忽略
之。



7.88 .version "string"
This directive creates a .note section and places into it an ELF formatted not
e of type NT VERSION. The note’s name is set to string.

7.88 .version "string"
本命令創建一個.note段,並把一個NT VERSION類型ELF格式的note放入該.note段。Note的
名字被設置爲string。



7.89 .vtable_entry table, offset
This directive finds or creates a symbol table and creates a VTABLE_ENTRY relo
cation for it with an addend of offset.

7.89 .vtable_entry table, offset
本命令尋找或創建一個符號表,並用offset作偏移量的增量,爲此符號表產生一個VTABLE
_ENTRY重定位。



7.90 .vtable_inherit child, parent
This directive finds the symbol child and finds or creates the symbol parent a
nd then creates a VTABLE_INHERIT relocation for the parent whose addend is the
value of the child symbol. As a special case the parent name of 0 is treated
as refering the *ABS* section.

7.90 .vtable_inherit child, parent
本命令尋找符號child, 並尋找或創建符號parent,爲符號parent產生一個VTABLE_INHERI
T重定位,parent的偏移量增量爲符號child的值。一個特例,如果parent的名字爲0,則將
它交給*ABS*段處理。



7.91 .weak names
This directive sets the weak attribute on the comma separated list of symbol n
ames. If the symbols do not already exist, they will be created.

7.91 .weak names
本命令設置names中每個符號(由逗號分隔)的weak屬性。如果這些符號尚不存在,則創建
這些符號。


7.92 .word expressions
This directive expects zero or more expressions, of any section, separated by
commas.
The size of the number emitted, and its byte order, depend on what target comp
uter the assembly is for.
Warning: Special Treatment to support Compilers
Machines with a 32-bit address space, but that do less than 32-bit addressing,
require the following special treatment. If the machine of interest to you do
es 32-bit addressing (or doesn’t require it; see Chapter 8 [Machine Dependenc
ies], page 61), you can ignore this issue.
In order to assemble compiler output into something that works, as occasionall
y does strange things to ‘.word’ directives. Directives of the form ‘.word
sym1-sym2’ are often emitted by compilers as part of jump tables. Therefore,
when as assembles a directive of the form ‘.word sym1-sym2’, and the differe
nce between sym1 and sym2 does not fit in 16 bits, as creates a secondary jump
table, immediately before the next label. This secondary jump table is preced
ed by a short-jump to the first byte after the secondary table. This short-jum
p prevents the flow of control from accidentally falling into the new table. I
nside the table is a long-jump to sym2. The original ‘.word’ contains sym1 m
inus the address of the long-jump to sym2.
If there were several occurrences of ‘.word sym1-sym2’ before the secondary
jump table, all of them are adjusted. If there was a ‘.word sym3-sym4’, that
also did not fit in sixteen bits, a long-jump to sym4 is included in the seco
ndary jump table, and the .word directives are adjusted to contain sym3 minus
the address of the long-jump to sym4; and so on, for as many entries in the or
iginal jump table as necessary.

7.92 .word expressions
本命令可不帶表達式或帶多個表達式,這些表達式可以屬於任意段,每個表達式由逗號分
隔。
彙編生成的數字的大小,字節順序視生成程序運行的目標機器而定。
警告:支持編譯器的特殊處理
有些機器具有32位地址空間,但不能完全進行32位尋址,需要下列的特殊處理。如果您關
心的機器能夠進行32位尋址,(或者根本不需要32位尋址;見第8章[機器相關性],61頁)
則可以忽略這個問題。
爲了使由編譯器產生源碼的彙編結果能夠正確地運行,as偶爾會對'.word'命令進行些奇怪
的操作。編譯器在跳轉表部分經常生成類似'.word sym1-sym2'形式的命令。所以,當as匯
編一條形如'.word sym1-sym2'的命令,且sym1和sym2之間的偏移量大於16位時,as會在下
個標籤前創建一個'次級跳轉表',在'次級跳轉表'前面加插上一個短-跳轉指令,這個短-跳
轉指令的目的地址是'次級跳轉表'之後的第一個字節。 這個短跳轉防止控制流程意外地落
入新的跳轉表(次級跳轉表)。在'次級跳轉表'內是個目的地址爲sym2的長-跳轉指令。原
來的'.word'命令調整爲sym1減去到sym2的長-跳轉指令地址,。
如果在次級跳轉表前出現了幾個'.word sym1-sym2',這些命令都要進行調整。如果存在一
個'.word sym3-sym4',且地址差也大與16位,次級跳轉表中將包含一個至sym4的長-跳轉
指令,且.word命令將被調整爲包含sym3減去到sym4長-跳轉指令的地址; 如是類推,處理
原始跳轉表中的需要處理的各個表項。



7.93 Deprecated Directives
One day these directives won’t work. They are included for compatibility with
older assemblers.
.abort
.line

7.93 不贊成使用的命令
將來下列命令可能不再被支持,它們的存在只是爲了與老版本的彙編器相兼容。
.abort
.line
發佈了13 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章