⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-i386.texi

📁 基于4个mips核的noc设计
💻 TEXI
📖 第 1 页 / 共 2 页
字号:
@c Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001@c Free Software Foundation, Inc.@c This is part of the GAS manual.@c For copying conditions, see the file as.texinfo.@ifset GENERIC@page@node i386-Dependent@chapter 80386 Dependent Features@end ifset@ifclear GENERIC@node Machine Dependencies@chapter 80386 Dependent Features@end ifclear@cindex i386 support@cindex i80306 support@cindex x86-64 supportThe i386 version @code{@value{AS}} supports both the original Intel 386architecture in both 16 and 32-bit mode as well as AMD x86-64 architectureextending the Intel architecture to 64-bits.@menu* i386-Options::                Options* i386-Syntax::                 AT&T Syntax versus Intel Syntax* i386-Mnemonics::              Instruction Naming* i386-Regs::                   Register Naming* i386-Prefixes::               Instruction Prefixes* i386-Memory::                 Memory References* i386-Jumps::                  Handling of Jump Instructions* i386-Float::                  Floating Point* i386-SIMD::                   Intel's MMX and AMD's 3DNow! SIMD Operations* i386-16bit::                  Writing 16-bit Code* i386-Arch::                   Specifying an x86 CPU architecture* i386-Bugs::                   AT&T Syntax bugs* i386-Notes::                  Notes@end menu@node i386-Options@section Options@cindex options for i386@cindex options for x86-64@cindex i386 options@cindex x86-64 options The i386 version of @code{@value{AS}} has a few machinedependent options:@table @code@cindex @samp{--32} option, i386@cindex @samp{--32} option, x86-64@cindex @samp{--64} option, i386@cindex @samp{--64} option, x86-64@item --32 | --64Select the word size, either 32 bits or 64 bits. Selecting 32-bitimplies Intel i386 architecture, while 64-bit implies AMD x86-64architecture.These options are only available with the ELF object file format, andrequire that the necessary BFD support has been included (on a 32-bitplatform you have to add --enable-64-bit-bfd to configure enable 64-bitusage and use x86-64 as target platform).@end table@node i386-Syntax@section AT&T Syntax versus Intel Syntax@cindex i386 intel_syntax pseudo op@cindex intel_syntax pseudo op, i386@cindex i386 att_syntax pseudo op@cindex att_syntax pseudo op, i386@cindex i386 syntax compatibility@cindex syntax compatibility, i386@cindex x86-64 intel_syntax pseudo op@cindex intel_syntax pseudo op, x86-64@cindex x86-64 att_syntax pseudo op@cindex att_syntax pseudo op, x86-64@cindex x86-64 syntax compatibility@cindex syntax compatibility, x86-64@code{@value{AS}} now supports assembly using Intel assembler syntax.@code{.intel_syntax} selects Intel mode, and @code{.att_syntax} switchesback to the usual AT&T mode for compatibility with the output of@code{@value{GCC}}.  Either of these directives may have an optionalargument, @code{prefix}, or @code{noprefix} specifying whether registersrequire a @samp{%} prefix.  AT&T System V/386 assembler syntax is quitedifferent from Intel syntax.  We mention these differences becausealmost all 80386 documents use Intel syntax.  Notable differencesbetween the two syntaxes are:@cindex immediate operands, i386@cindex i386 immediate operands@cindex register operands, i386@cindex i386 register operands@cindex jump/call operands, i386@cindex i386 jump/call operands@cindex operand delimiters, i386@cindex immediate operands, x86-64@cindex x86-64 immediate operands@cindex register operands, x86-64@cindex x86-64 register operands@cindex jump/call operands, x86-64@cindex x86-64 jump/call operands@cindex operand delimiters, x86-64@itemize @bullet@itemAT&T immediate operands are preceded by @samp{$}; Intel immediateoperands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).AT&T register operands are preceded by @samp{%}; Intel register operandsare undelimited.  AT&T absolute (as opposed to PC relative) jump/calloperands are prefixed by @samp{*}; they are undelimited in Intel syntax.@cindex i386 source, destination operands@cindex source, destination operands; i386@cindex x86-64 source, destination operands@cindex source, destination operands; x86-64@itemAT&T and Intel syntax use the opposite order for source and destinationoperands.  Intel @samp{add eax, 4} is @samp{addl $4, %eax}.  The@samp{source, dest} convention is maintained for compatibility withprevious Unix assemblers.  Note that instructions with more than onesource operand, such as the @samp{enter} instruction, do @emph{not} havereversed order.  @ref{i386-Bugs}.@cindex mnemonic suffixes, i386@cindex sizes operands, i386@cindex i386 size suffixes@cindex mnemonic suffixes, x86-64@cindex sizes operands, x86-64@cindex x86-64 size suffixes@itemIn AT&T syntax the size of memory operands is determined from the lastcharacter of the instruction mnemonic.  Mnemonic suffixes of @samp{b},@samp{w}, @samp{l} and @samp{q} specify byte (8-bit), word (16-bit), long(32-bit) and quadruple word (64-bit) memory references.  Intel syntax accomplishesthis by prefixing memory operands (@emph{not} the instruction mnemonics) with@samp{byte ptr}, @samp{word ptr}, @samp{dword ptr} and @samp{qword ptr}.  Thus,Intel @samp{mov al, byte ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&Tsyntax.@cindex return instructions, i386@cindex i386 jump, call, return@cindex return instructions, x86-64@cindex x86-64 jump, call, return@itemImmediate form long jumps and calls are@samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; theIntel syntax is@samp{call/jmp far @var{section}:@var{offset}}.  Also, the far returninstructionis @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is@samp{ret far @var{stack-adjust}}.@cindex sections, i386@cindex i386 sections@cindex sections, x86-64@cindex x86-64 sections@itemThe AT&T assembler does not provide support for multiple sectionprograms.  Unix style systems expect all programs to be single sections.@end itemize@node i386-Mnemonics@section Instruction Naming@cindex i386 instruction naming@cindex instruction naming, i386@cindex x86-64 instruction naming@cindex instruction naming, x86-64Instruction mnemonics are suffixed with one character modifiers whichspecify the size of operands.  The letters @samp{b}, @samp{w}, @samp{l}and @samp{q} specify byte, word, long and quadruple word operands.  Ifno suffix is specified by an instruction then @code{@value{AS}} tries tofill in the missing suffix based on the destination register operand(the last one by convention).  Thus, @samp{mov %ax, %bx} is equivalentto @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to@samp{movw $1, bx}.  Note that this is incompatible with the AT&T Unixassembler which assumes that a missing mnemonic suffix implies longoperand size.  (This incompatibility does not affect compiler outputsince compilers always explicitly specify the mnemonic suffix.)Almost all instructions have the same names in AT&T and Intel format.There are a few exceptions.  The sign extend and zero extendinstructions need two sizes to specify them.  They need a size tosign/zero extend @emph{from} and a size to zero extend @emph{to}.  Thisis accomplished by using two instruction mnemonic suffixes in AT&Tsyntax.  Base names for sign extend and zero extend are@samp{movs@dots{}} and @samp{movz@dots{}} in AT&T syntax (@samp{movsx}and @samp{movzx} in Intel syntax).  The instruction mnemonic suffixesare tacked on to this base name, the @emph{from} suffix before the@emph{to} suffix.  Thus, @samp{movsbl %al, %edx} is AT&T syntax for``move sign extend @emph{from} %al @emph{to} %edx.''  Possible suffixes,thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),@samp{wl} (from word to long), @samp{bq} (from byte to quadruple word),@samp{wq} (from word to quadruple word), and @samp{lq} (from long toquadruple word).@cindex conversion instructions, i386@cindex i386 conversion instructions@cindex conversion instructions, x86-64@cindex x86-64 conversion instructionsThe Intel-syntax conversion instructions@itemize @bullet@item@samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},@item@samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},@item@samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},@item@samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},@item@samp{cdqe} --- sign-extend dword in @samp{%eax} to quad in @samp{%rax}(x86-64 only),@item@samp{cdo} --- sign-extend quad in @samp{%rax} to octuple in@samp{%rdx:%rax} (x86-64 only),@end itemize@noindentare called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, @samp{cltd}, @samp{cltq}, and@samp{cqto} in AT&T naming.  @code{@value{AS}} accepts either naming for theseinstructions.@cindex jump instructions, i386@cindex call instructions, i386@cindex jump instructions, x86-64@cindex call instructions, x86-64Far call/jump instructions are @samp{lcall} and @samp{ljmp} inAT&T syntax, but are @samp{call far} and @samp{jump far} in Intelconvention.@node i386-Regs@section Register Naming@cindex i386 registers@cindex registers, i386@cindex x86-64 registers@cindex registers, x86-64Register operands are always prefixed with @samp{%}.  The 80386 registersconsist of@itemize @bullet@itemthe 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},@samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (theframe pointer), and @samp{%esp} (the stack pointer).@itemthe 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},@samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.@itemthe 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},@samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (Theseare the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},@samp{%cx}, and @samp{%dx})@itemthe 6 section registers @samp{%cs} (code section), @samp{%ds}(data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},and @samp{%gs}.@itemthe 3 processor control registers @samp{%cr0}, @samp{%cr2}, and@samp{%cr3}.@itemthe 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},@samp{%db3}, @samp{%db6}, and @samp{%db7}.@itemthe 2 test registers @samp{%tr6} and @samp{%tr7}.@itemthe 8 floating point register stack @samp{%st} or equivalently@samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},@samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.These registers are overloaded by 8 MMX registers @samp{%mm0},@samp{%mm1}, @samp{%mm2}, @samp{%mm3}, @samp{%mm4}, @samp{%mm5},@samp{%mm6} and @samp{%mm7}.@itemthe 8 SSE registers registers @samp{%xmm0}, @samp{%xmm1}, @samp{%xmm2},@samp{%xmm3}, @samp{%xmm4}, @samp{%xmm5}, @samp{%xmm6} and @samp{%xmm7}.@end itemizeThe AMD x86-64 architecture extends the register set by:@itemize @bullet@itemenhancing the 8 32-bit registers to 64-bit: @samp{%rax} (theaccumulator), @samp{%rbx}, @samp{%rcx}, @samp{%rdx}, @samp{%rdi},@samp{%rsi}, @samp{%rbp} (the frame pointer), @samp{%rsp} (the stackpointer)@itemthe 8 extended registers @samp{%r8}--@samp{%r15}.@itemthe 8 32-bit low ends of the extended registers: @samp{%r8d}--@samp{%r15d}@itemthe 8 16-bit low ends of the extended registers: @samp{%r8w}--@samp{%r15w}@itemthe 8 8-bit low ends of the extended registers: @samp{%r8b}--@samp{%r15b}@itemthe 4 8-bit registers: @samp{%sil}, @samp{%dil}, @samp{%bpl}, @samp{%spl}.@itemthe 8 debug registers: @samp{%db8}--@samp{%db15}.@itemthe 8 SSE registers: @samp{%xmm8}--@samp{%xmm15}.@end itemize@node i386-Prefixes@section Instruction Prefixes@cindex i386 instruction prefixes@cindex instruction prefixes, i386@cindex prefixes, i386Instruction prefixes are used to modify the following instruction.  Theyare used to repeat string instructions, to provide section overrides, toperform bus lock operations, and to change operand and address sizes.(Most instructions that normally operate on 32-bit operands will use16-bit operands if the instruction has an ``operand size'' prefix.)Instruction prefixes are best written on the same line as the instructionthey act upon. For example, the @samp{scas} (scan string) instruction isrepeated with:@smallexample        repne scas %es:(%edi),%al@end smallexampleYou may also place prefixes on the lines immediately preceding theinstruction, but this circumvents checks that @code{@value{AS}} doeswith prefixes, and will not work with all prefixes.Here is a list of instruction prefixes:@cindex section override prefixes, i386@itemize @bullet@itemSection override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},@samp{fs}, @samp{gs}.  These are automatically added by specifyingusing the @var{section}:@var{memory-operand} form for memory references.@cindex size prefixes, i386@itemOperand/Address size prefixes @samp{data16} and @samp{addr16}change 32-bit operands/addresses into 16-bit operands/addresses,while @samp{data32} and @samp{addr32} change 16-bit ones (in a@code{.code16} section) into 32-bit operands/addresses.  These prefixes@emph{must} appear on the same line of code as the instruction theymodify. For example, in a 16-bit @code{.code16} section, you mightwrite:@smallexample        addr32 jmpl *(%ebx)@end smallexample@cindex bus lock prefixes, i386@cindex inhibiting interrupts, i386@item

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -