zoukankan      html  css  js  c++  java
  • GUN as 使用

    mipsel-linux-as  –target-help 显示指定汇编器的特殊选项并退出。 

      This manual is intended to describe what you need to know to use gnu as. We cover the syntax expected in source files, including notation for symbols, constants, and expressions; the directives that as understands; and of course how to invoke as.

    Dependency Tracking: ‘--MD’  生成makefile 文件

      as can generate a dependency file for the file it creates. This file consists of a single rule suitable for make describing the dependencies of the main source file. The rule is written to the file named in its argument. This feature is used in the automatic updating of makefiles.

    警告:Control Warnings: ‘-W’, ‘--warn’, ‘--no-warn’, ‘--fatal-warnings’

      as should never give a warning or error message when assembling compiler output. But programs written by people often cause as to give a warning that a particular assumption was made. All such warnings are directed to the standard error file. If you use the ‘-W’ and ‘--no-warn’ options, no warnings are issued. This only affects the warning messages: it does not change any particular of how as assembles your file. Errors, which stop the assembly, are still reported. If you use the ‘--fatal-warnings’ option, as considers files that generate warnings to be in error. You can switch these options off again by specifying ‘--warn’, which causes warnings to be output as usual.

    即使在发生错误情况下也进行汇编

      Generate Object File in Spite of Errors: ‘-Z’

      After an error message, as normally produces no output. If for some reason you are interested in object file output even after as gives an error message on your program, use the ‘-Z’ option. If there are any errors, as continues anyways, and writes an object file after a final warning message of the form ‘n errors, m warnings, generating bad object file.’

    关于“#”注释符,该符号可能不再使用

      To be compatible with past assemblers, lines that begin with ‘#’ have a special interpretation. Following the ‘#’ should be an absolute expression : the logical line number of the next line. Then a string is allowed: if present it is a new logical file name. The rest of the line, if any, should be whitespace. If the first non-whitespace characters on the line are not numeric, the line is ignored.

                      #This is an ordinary comment.

      # 42-6 "new_file_name"    # New logical file name

                      # This is logical line # 36.

      This feature is deprecated, and may disappear from future versions of as.

    ld deals with just four kinds of sections, summarized below.

    named sections

    text section

    data section

     bss section

     absolute section

     undefined section

    .section name

      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.

    Sub-Sections关于子区

      Assembled bytes conventionally fall into two sections: text and data. You may have separate groups of data in named sections that you want to end up near to each other in the object file, even though they are not contiguous in the assembler source. as allows you to use subsections for this purpose. Within each section, there can be numbered subsections with values from 0 to 8192. Objects assembled into the same subsection go into the object file together with other objects in the same subsection. For example, a compiler might want to store constants in the text section, but might not want to have them interspersed with the program being assembled. In this case, the compiler could issue a ‘.text 0’ before each section of code being output, and a ‘.text 1’ before each group of constants being output. Subsections are optional. If you do not use subsections, everything goes in subsection number zero. Each subsection is zero-padded up to a multiple of four bytes.Subsections appear in your object file in numeric order, lowest numbered to highest. The object file contains no representation of subsections; ld and other programs that manipulate object files see no trace of them. They just see all your text subsections as a text section, and all your data subsections as a data section. To specify which subsection you want subsequent statements assembled into, use a numeric argument to specify it, in a ‘.text expression’ or a ‘.data expression’ statement. If you just say ‘.text’ then ‘.text 0’ is assumed. Likewise ‘.data’ means ‘.data 0’. Assembly begins in text 0. For instance:

      .text 0 # The default subsection is text 0 anyway.

      .ascii "This lives in the first text subsection. *"

      .text 1

      .ascii "But this lives in the second text subsection."

      .data 0

      .ascii "This lives in the data section,"

      .ascii "in the first data subsection."

      .text 0

      .ascii "This lives in the first text section,"

      .ascii "immediately following the asterisk (*)."

     

     bss Section

    .lcomm symbol , length  相当于局部作用域的static类型

      Reserve length (an absolute expression) bytes for a local common denoted by symbol. The section and value of symbol are those of the new local common. The addresses are allocated in the bss section, so that at run-time the bytes start off zeroed. Symbol is not declared global , so is normally not visible to ld. Some targets permit a third argument to be used with .lcomm. This argument specifies the desired alignment of the symbol in the bss section.

     

    .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.

     

     

    Local Symbol Names 如何生成局部符号

      Local symbols help compilers and programmers use names temporarily. They create symbols which are guaranteed to be unique over the entire scope of the input source code and which can be referred to by a simple notation. To define a local symbol, write a label of the form ‘N:’ (where N represents any positive integer). To refer to the most recent previous definition of that symbol write ‘Nb’, using the same number as when you defined the label. To refer to the next definition of a local label, write ‘Nf’— The ‘b’ stands for“backwards” and the ‘f’ stands for “forwards”.

      It is also worth noting that the first 10 local labels (‘0:’. . . ‘9:’) are implemented in a slightly more efficient manner than the others.

    Here is an example:

      1: branch 1f

      2: branch 1b

      1: branch 2f

      2: branch 1b

    Which is the equivalent of:

      label_1: branch label_3

      label_2: branch label_1

      label_3: branch label_4

      label_4: branch label_3

      Local symbol names are only a notational device. They are immediately transformed into more conventional symbol names before the assembler uses them. The symbol names stored in the symbol table, appearing in error messages and optionally emitted to the object file.

      The names are constructed using these parts:

        L

         All local labels begin with ‘L’. Normally both as and ld forget symbols that start with ‘L’. These labels are used for symbols you are never intended to see. If you use the ‘-L’ option then as retains these symbols in the object file. If you also instruct ld to retain these symbols, you may use them in debugging.

        number

        This is the number that was used in the local label definition. So if the label is written ‘55:’ then the number is ‘55’.

        C-B

        This unusual character is included so you do not accidentally invent a symbol of the same name. The character has ASCII value of ‘\002’ (control-B).

        ordinal number

        This is a serial number to keep the labels distinct. The first definition of ‘0:’ gets the number ‘1’. The 15th definition of ‘0:’ gets the number ‘15’, and so on. Likewise the first definition of ‘1:’ gets the number ‘1’ and its 15th defintion gets ‘15’ as well. So for example, the first 1: is named L1C-B1, the 44th 3: is named L3C-B44.

     Assembler Directives

    .align abs-expr, abs-expr, abs-expr

      第一个abs-expr对于不同的编译环境意义不同,For the a29k, hppa, m68k, m88k, w65, sparc, Xtensa, and Renesas / SuperH SH, and i386 using ELF format, the first expression is the alignment request in bytes.对于其他编译环境,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.第二个是在跳过的byte中填充的值,第三个是最大可跳过的byte(若超过则不会进行align)

     .balign[wl] abs-expr, abs-expr, abs-expr

      Pad the location counter to a particular storage boundary. The first expression (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 (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.

     .p2align[wl] abs-expr, abs-expr, abs-expr

      Pad the location counter (in the current subsection) to a particular storage boundary. The first expression (which must be absolute) is the number of low-order 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 location 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 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 .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. For example, .p2alignw2,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.

    .mask mask, offset

      Indicate which of the integer registers are saved in the current function’s stack frame. mask is interpreted a bit mask in which bit n set indicates that registern is saved. The registers are saved in a block located offset bytes from the canonical frame address (CFA) which is the value of the stack pointer on entry to the function. The registers are saved sequentially, except that the return address register (normally $26) is saved first. This and the other directives that describe the stack frame are currently only used when generating .mdebug information. They may in the future be used to generate DWARF2 .debug_frame unwind information for hand written assembly

     .fmask mask, offset

      Indicate which of the floating-point registers are saved in the current stack frame. The mask and offset parameters are interpreted as with .mask.

     

    .frame framereg, frameoffset, retreg[, argoffset]

      Describes the shape of the stack frame. The frame pointer in use is framereg; normally this is either $fp or $sp. The frame pointer is frameoffset bytes below the CFA. The return address is initially located in retreg until it is saved as indicated in .mask. For compatibility with OSF/1 an optional argoffset parameter is accepted and ignored. It is believed to indicate the offset from the CFA to the saved argument registers.

     .prologue n

      Indicate that the stack frame is set up and all registers have been spilled. The argument n indicates whether and how the function uses the incoming procedure vector (the address of the called function) in $27. 0 indicates that $27 is not used; 1 indicates that the first two instructions of the function use $27 to perform a load of the GP register; 2 indicates that $27 is used in some nonstandard

    way and so the linker cannot elide the load of the procedure vector during relaxation.

     

    .frame reg, size

      This directive tells the assembler to emit information to allow the debugger to locate a function’s stack frame, where reg is the register used to hold the frame pointer (usually the same as the stack pointer) and size is the size in bytes of the stack frame. The .frame directive is typically placed immediately after the ENTRY instruction for a function. In almost all circumstances, this information just duplicates the information given in the function’s ENTRY instruction; however, there are two cases where this is not true:

    1. The size of the stack frame is too big to fit in the immediate field of the ENTRY instruction.

    2. The frame pointer is different than the stack pointer, as with functions that call alloca.

     

    .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

     .end

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

     

    .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; optionally, you may include code for the alternative condition, flagged by .else. 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. Note a symbol which has been referenced but not yet defined is considered to be undefined.

      .ifnotdef symbol

        Assembles the following section of code if the specified symbol has not been defined. Both spelling variants are equivalent. Note a symbol which has been referenced but not yet defined is considered to be undefined.

      .ifeq absolute expression

        Assembles the following section of code if the argument is zero.

      .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).

      .ifeqs string1,string2

        Another form of .ifc. The strings must be quoted using double quotes.

      .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.

      .ifge absolute expression

        Assembles the following section of code if the argument is greater than or equal to zero.

      .ifle absolute expression

        Assembles the following section of code if the argument is less than or equal to zero.

      .ifgt absolute expression

        Assembles the following section of code if the argument is greater than zero.

      .iflt absolute expression

        Assembles the following section of code if the argument is less than zero.

      .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. 48 Using as 

      .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.

      

    .elseif

      .elseif is part of the as support for conditional assembly. It is shorthand for beginning a new .if block that would otherwise fill the entire .else section.

    .else

      .else is part of the as support for conditional assembly. It marks the beginning of a section of code to be assembled if the condition for the preceding .if was false.

     .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.

     .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.

     .endfunc

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

     .equ symbol, expression

      This directive sets the value of symbol to expression. It is synonymous with ‘.set’

     .set symbol, expression

      Set the value of symbol to expression. This changes symbol’s value and type to conform to expression. If symbol was flagged as external, it remains flagged. 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 value stored into it.

     

     .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.

     .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.

     .print string

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

     

     

     .irp symbol,values . . .

      Evaluate a sequence of statements assigning different values to symbol. The sequence of statements starts at the .irp directive, and is terminated by an .endr directive. For each value, symbol is set to value, and 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

          .irp param,1,2,3

          move d\param,sp@-

          .endr

      is equivalent to assembling

          move d1,sp@-

          move d2,sp@-

          move d3,sp@- 

    .irpc symbol,values . . .

      Evaluate a sequence of statements assigning different values to symbol. The sequence of statements starts at the .irpc directive, and is terminated by an .endr directive. For each character in value, symbol is set to the character, and 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@-

     

     

    .macro宏

      The commands .macro and .endm allow you to define macros that generate assembly output. For example, this definition specifies a macro sum that puts a sequence of numbers into memory:

        .macro sum from=0, to=5

        .long \from

        .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 requires arguments, specify their names after the macro name, separated by commas or spaces. You can supply a default value for any macro argument by following the 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 the arguments.

        .macro reserve_str p1=0 p2

          Begin the definition of a macro called reserve_str, with two arguments. The first argument has a default value, but not the second.

    After the definition is complete, you can call the macro either as ‘reserve_str a,b’ (with ‘\p1’ evaluating to a and ‘\p2’ evaluating to b), or as ‘reserve_str ,b’ (with ‘\p1’ evaluating as the default, in this case ‘0’, and ‘\p2’ evaluating to b).

        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 pseudovariable;you can copy that number to your output with ‘\@’, but only within a macro definition.    

     .purgem name取消宏定义

    Undefine the macro name, so that later uses of the string will not be expanded.

     

    .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.

     .type

      This directive is used to set the type of a symbol. For ELF targets, the .type directive is used like this:

      .type name , type description

        This sets the type of symbol name to be either a function symbol or an object symbol. There are five different syntaxes supported for the type description field, in order to provide compatibility with various other assemblers. 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

     .weak names

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

     .extern

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

     .hidden names

      This one of the ELF visibility directives. The other two are .internal and .protected. This directive overrides the named symbols default visibility. 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.

     .internal names

      This one of the ELF visibility directives. The other two are .hidden and .protected. This directive overrides the named symbols default visibility.The directive sets the visibility to internal which means that the symbols are considered to be hidden, and that some extra, processor specific processing must also be performed upon the symbols as well.

    .protected names

      This one of the ELF visibility directives. The other two are .hidden and .internal. This directive overrides the named symbols default visibility. The directive sets the visibility to protected which means that any references to the symbols from within the components that defines them must be resolved to the definition in that component, even if a definition in another component would normally preempt this.

     .fill repeat , size , value

      其中,repeat、size和value都是常量表达式。.fill的含义是反复拷贝size个字节,重复repeat次。repeat次。repeat可以大于或者等于0。size也可以大于等于0,但不能超过8,如果超过8,也只取8。size个字节的内容将填充为value的值,如果size的大小大于value的存储所需的容量,则将高位用0填充。size和value为可选项。如果第二个逗号和value值不存在,则假定value为0。如果第一个逗号和size不存在,则假定size为1。例如:.fill 30,8,0即表示反复30次,每次向8个字节中拷贝0值。

     .org new-lc , fill

      Advance the location counter of the current section to new-lc. new-lc is either 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 assemblers, if the section of new-lc is absolute, as issues a warning, then pretends 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 your improved assembler. Beware that the origin is relative to the start of the section, not to the start of the subsection. This is compatible with other people’s assemblers. When the location counter (of the current subsection) is advanced, the intervening bytes are filled with fill which should be an absolute expression. If the comma and fill are omitted, fill defaults to zero.

     .skip size , fill

      This directive emits size bytes, each of value fill. Both size and fill are absolute expressions. If the comma and fill are omitted, fill is assumed to be zero. This is the same as ‘.space’.

     .space size , fill

      该指示符指示保留size个字节的空间,每个字节的值为fill。size和fill都是常量表达式。如果逗号和fill被省略,则假定fill为0。This is the same as ‘.skip’.

     .ascii "string". . .

      .ascii expects zero or more string literals separated by commas. It assembles each string (with no automatic trailing zero byte) into

    consecutive addresses.

     .asciz "string". . .

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

     .string "str"

      Copy the characters in str to the object file. You may specify more than one string to copy, separated by commas. Unless otherwise specified for a particular machine, the assembler marks the end of each string with a 0 byte.

     .byte expressions

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

     .short expressions

      .short is normally the same as ‘.word’. In some configurations, however, .short and .word generate numbers of different lengths;

     .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.

     .long expressions

      .long is the same as ‘.int’,

     .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 computer the assembly is for. 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 does 32-bit addressing, you can ignore this issue. In order to assemble compiler output into something that works, as occasionally 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 difference 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 preceded by a short-jump to the first byte after the secondary table. This short-jump prevents the flow of control from accidentally falling into the new table. Inside the table is a long-jump to sym2. The original ‘.word’ contains sym1 minus 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 secondary 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 original jump table as necessary.

     .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 depends on how as is configured.

     .double flonums

      .double expects zero or more flonums, separated by commas. It assembles floating point numbers.

     .float flonums

      This directive assembles zero or more flonums, separated by commas. It has the same effect as .single.

     .quad bignums

      .quad expects zero or more bignums, separated by commas. For each bignum, it emits an 8-byte integer. If the bignum won’t fit in 8 bytes, it prints a warning 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.

     .octa bignums

      This directive expects zero or more bignums, separated by commas. For each bignum, 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.

     .struct expression

      Switch to the absolute section, and set the section offset to expression, which 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.

     

    MIPS Dependent Features

    The mips configurations of gnu as support these special options:

    -G num

      This option sets the largest size of an object that can be referenced implicitly with the gp register. It is only accepted for targets that use ecoff format. The default value is 8.

    -EB

    -EL

       Any mips configuration of as can select big-endian or little-endian output at run time (unlike the other gnu development tools, which must be configured for one or the other). Use ‘-EB’ to select big-endian output, and ‘-EL’ for little-endian.

    -mips1

    -mips2

    -mips3

    -mips4

    -mips5

    -mips32

    -mips32r2

    -mips64

       Generate code for a particular MIPS Instruction Set Architecture level. ‘-mips1’ corresponds to the r2000 and r3000 processors, ‘-mips2’ to the r6000 processor, ‘-mips3’ to the r4000 processor, and ‘-mips4’ to the r8000 and r10000 processors. ‘-mips5’, ‘-mips32’, ‘-mips32r2’, and ‘-mips64’ correspond to generic MIPS V, MIPS32, MIPS32 Release 2, and MIPS64 ISA processors, respectively. You can also switch instruction sets during the assembly;

       附:gnu as supports an additional directive to change the mips Instruction Set Architecture level on the fly: .set mipsn. n should be a number from 0 to 5, or 32, 32r2, or 64. The values other than 0 make the assembler accept instructions for the corresponding isa level, from that point on in the assembly. .set mipsn affects not only which instructions are permitted, but also how certain macros are expanded. .set mips0 restores the isa level to its original level: either the level you selected with command line options, or the default for your configuration.

     

    -mgp32

    -mfp32

      Some macros have different expansions for 32-bit and 64-bit registers. The register sizes are normally inferred from the ISA and ABI, but these flags force a certain group of registers to be treated as 32 bits wide at all times. ‘-mgp32’ controls the size of general-purpose registers and ‘-mfp32’ controls the size of floating-point registers. On some MIPS variants there is a 32-bit mode flag; when this flag is set, 64-bit instructions generate a trap. Also, some 32-bit OSes only save the 32-bit registers on a context switch, so it is essential never to use the 64-bit registers.

    -mgp64

      Assume that 64-bit general purpose registers are available. This is provided in the interests of symmetry with -gp32.

    -mips3d

    -no-mips3d

      Generate code for the MIPS-3D Application Specific Extension. This tells the assembler to accept MIPS-3D instructions. ‘-no-mips3d’ turns off this option.

    -mdmx

    -no-mdmx

      Generate code for the MDMX Application Specific Extension. This tells the assembler to accept MDMX instructions. ‘-no-mdmx’ turns off this option.

    -mfix7000

    -mno-fix7000

      Cause nops to be inserted if the read of the destination register of an mfhi or mflo instruction occurs in the following two instructions.

     -mabi=abi

      Record which ABI the source code uses. The recognized arguments are: ‘32’, ‘n32’, ‘o64’, ‘64’ and ‘eabi’.

     --construct-floats

    --no-construct-floats

      The --no-construct-floats option disables the construction of double width floating point constants by loading the two halves of the value into the two single width floating point registers that make up the double width register. This feature is useful if the processor support the FR bit in its status register, and this bit is known (by the programmer) to be set. This bit prevents the aliasing of the double width register by the single width registers. By default --construct-floats is selected, allowing construction of these floating point constants.

    --trap

    --no-break

      as automatically macro expands certain division and multiplication instructions to check for overflow and division by zero. This option causes as to generate code to take a trap exception rather than a break exception when an error is detected. The trap instructions are only supported at Instruction Set Architecture level 2 and higher.

    --break

    --no-trap

      Generate code to take a break exception rather than a trap exception when an error is detected. This is the default.

    -n

      When this option is used, as will issue a warning every time it generates a nop

    instruction from a macro.

     

    Directive to mark data as an instruction指示数据为指令

      The .insn directive tells as that the following data is actually instructions. This makes a difference in MIPS 16 mode: when loading the address of a label which precedes instructions, as automatically adds 1 to the value, so that jumping to the loaded address will do the right thing.

     Directives to save and restore options

      The directives .set push and .set pop may be used to save and restore the current settings for all the options which are controlled by .set. The .set push directive saves the current settings on a stack. The .set pop directive pops the stack and restores the settings. These directives can be useful inside an macro which must change an option such as the ISA level or instruction reordering but does not want to change the state of the code which invoked the macro.

     

    Directives to control generation of MIPS ASE instructions

      The directive .set mips3d makes the assembler accept instructions from the MIPS-3D Application Specific Extension from that point on in the assembly. The .set nomips3d directive prevents MIPS-3D instructions from being accepted. The directive .set mdmx makes the assembler accept instructions from the MDMX Application Specific Extension from that point on in the assembly. The .set nomdmx directive prevents MDMX. instructions from being accepted.

  • 相关阅读:
    Android的activity的生命周期
    COCOS学习笔记--重力感应Acceleration
    【深入了解cocos2d-x 3.x】定时器(scheduler)的使用和原理探究(2)
    cocos2d-x改底层之获取UIListView的实际内容大小
    Android 使用ListView的A-Z字母排序功能实现联系人模块
    Netty3 源代码分析
    A002-开发工具介绍
    数据结构:二叉树(前,中,后,层次)非递归遍历。
    jQuery开发之Ajax
    cocos2d-x-3.6 引擎概述
  • 原文地址:https://www.cnblogs.com/openix/p/2438976.html
Copyright © 2011-2022 走看看