转载自:http://blog.sina.com.cn/s/blog_4e3141320100cufa.html
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 provide 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 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.
7.1 .abort
本命令立即终止汇编过程。这是为了兼容其它的汇编器。早期的想法是汇编语言的源码会被输送进汇编器。如果发送源码的程序要退出,它可以使用本命令通知as退出。将来可能不再支持使用.abort
7.2 .ABORT
When producing COFF output, as accepts this directive as a synonym for ‘.abort’.
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 boundary. The first expression_r(which must be absolute) is the alignment required, as described below.
The second expression_r(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 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 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 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 format, the first expression is the alignment request in bytes. For example ‘.align 8’ advances the location counter until it is a multiple of 8. If the location 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 strongarm, it is the number of low-order zero bits the location counter must have after advancement. For example ‘.align 3’ advances the location counter until it a multiple of 8. If the location counter is already a multiple of 8, no change is needed.
This inconsistency is due to the different behaviors of the various native assemblers for these systems which GAS must emulate. GAS also provides .balign and .p2align directives, described later, which have a consistent behavior across 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], page 19) separated by commas. It assembles each string (with no automatic trailing 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 boundary. The first expression_r(which must be absolute) is the alignment request in bytes. For example ‘.balign 8’ advances the location counter until it is a multiple of 8. If the location counter is already a multiple of 8, no change is needed.
The second expression_r(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 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 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 .balignw and .balignl directives are variants of the .balign directive. The .balignw directive treats the fill pattern as a two byte word value. The .balignl directives treats the fill pattern as a four byte longword value. For example, .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 bytes 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个字节来填充空白区。.balignl使用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 is 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 uninitialized memory. length must be an absolute expression. If ld sees multiple common symbols with the same name, and they do not all have the same size, it will allocate 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 should 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 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.
The syntax for .comm differs slightly on the HPPA. The syntax is ‘symbol .comm, 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 subsection 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 when as is configured for COFF format output; when producing b.out, ‘.def’ is recognized, but ignored.
7.10 .def name
开始定义符号'name'的调试信息;定义区延伸至遇到.endef命令。本命令只在as被配置成COFF格式输出时才使用;当输出为b.out格式时,可以使用‘.def’命令,但被忽略。
7.11 .desc symbol, abs-expression
This directive sets the descriptor of the symbol (see Section 5.5 [Symbol Attributes],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 information in the symbol table. It is only permitted inside .def/.endef pairs.
‘.dim’ is only meaningful when generating COFF format output; when as is generating 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 floating 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 [.if], page 43. It marks the beginning of a section of code to be assembled if the 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 otherwise 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 file 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 configured to generate b.out, it accepts this directive but ignores it.
7.18 .endef
这条命令标志着从.def开始的符号定义结束。
‘.endef’命令仅仅在生成COFF格式的输出有意义;如果as被配置为生成b.out输出,虽然as接受这条命令,但忽略它。
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 signal 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 the -Z option was used, it will not generate an object file. This can be used to 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 47.
7.24 .exitm
从当前宏定义体中提前退出。见7.50 [Macro],第47页。
7.25 .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.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 print 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 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. 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 size 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 people’s assemblers. The contents of each repeat bytes are taken from an 8-byte number. 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 assemblers.
size and value are optional. If the second comma and value are absent, value is assumed zero. If the first comma and following tokens are absent, size is assumed 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 depends 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 unless the file is assembled with debugging enabled. Only ‘--gstabs’ is currently supported. Label is the entry point of the function and if omitted name prepended with the ‘leading char’ is used. ‘leading char’ is usually _ or nothing, 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 program, 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 with other assemblers.
On the HPPA, .global is not always enough to make it accessible to other partial 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 Section 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 hidden which means that the symbols are not visible to other components. Such symbols are always considered to be protected as well.
7.32 .hidden names
这是一条关于ELF可见度的命令。其它两条是.internal(见7.39[.internal],44页) 和 .protected (见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 architecture, 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 simply 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 marked by .endif (see Section 7.20 [.endif], page 40); optionally, you may include code for the alternative condition, flagged by .else (see Section 7.15 [.else], 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 defined.
.ifc string1,string2
Assembles the following section of code if the two strings are the same. The strings may be optionally quoted with single quotes. If they are not quoted, the first string stops at the first comma, and the second string stops at the end 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.
.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.
.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.35 .if absolute expression
.if 标志着一段代码的开始,这段代码只有在参数absolute experession(必须是一个独立的表达式)不为0时才进行汇编。这段条件汇编代码必须使用.endif标志结束。(见7.20[.endif], 40页);另外,可以使用.esle来标记一个代码块(见7.15 [.else],40页),这个代码块与前面那段代码只有一个会进行汇编。 如果您需要检查数个汇编条件,可以在使用.elseif命令,以避免在.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 control 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 count argument indicates the maximum number of bytes to read. Note that the data is not aligned in any way, so it is the user’s responsibility to make sure that 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). Quotation 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 Section 7.32 [.hidden], page 42) 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 internal which means that the symbols are considered to be hidden (ie not visible to other components), and that some extra, processor specific processing must also be performed upon the symbols as well.
7.39 .internal names
这是一条与ELF可见度相关的命令。另外的两条是.hidden(见7.32[.hidden],42页) 和 .protected (见7.58 [.protected],50页)。
本命令取消指定符号的缺省可见度(可见度由其他命令捆绑设定:local,global,weak)。本命令把指定符号可见度设置为internal,这意味着此符号需要被隐藏(即对其他部分不可见),另外,符号还必须经过处理器的特别的处理。