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

📄 basm.doc

📁 该包是数据结构的实验软件,来源于合肥工业大学人工智能与数据挖掘实验室,用来实现数据结构.
💻 DOC
📖 第 1 页 / 共 3 页
字号:
                    assembler. The exact format of the operands is not
                    enforced by the compiler.


                    -------------------------------------------------------

Opcode mnemonics    aaa            fclex          fldenv         fstenv
                    aad            fcom           fldl2e         fstp
                    aam            fcomp          fldl2t         fstsw
                    aas            fcompp         fldlg2         fsub
                    adc            fdecstp**      fldln2         fsubp
  This table lists  add            fdisi          fldpi          fsubr
        the opcode  and            fdiv           fldz           fsubrp
mnemonics that can  bound          fdivp          fmul           ftst
 be used in inline  call           fdivr          fmulp          fwait
        assembler.  cbw            fdivrp         fnclex         fxam
                    clc            feni           fndisi         fxch
                    cld            ffree**        fneni          fxtract
Inline assembly in  cli            fiadd          fninit         fyl2x
 routines that use  cmc            ficom          fnop           fyl2xp1
    floating-point  cmp            ficomp         fnsave         hlt
 emulation doesn't  cwd            fidiv          fnstcw         idiv
       support the  daa            fidivr         fnstenv        imul
    opcodes marked  das            fild           fnstsw         in
          with **.  dec            fimul          fpatan         inc
                    div            fincstp**      fprem          int
                    enter          finit          fptan          into
                    f2xm1          fist           frndint        iret
                    fabs           fistp          frstor         lahf
                    fadd           fisub          fsave          lds
                    faddp          fisubr         fscale         lea
                    fbld           fld            fsqrt          leave
                    fbstp          fld1           fst            les
                    fchs           fldcw          fstcw          lsl



                                   - 4 -






                    mul            or             ret            stc
                    neg            out            rol            std
                    nop            pop            ror            sti
                    not            popa           sahf           sub
                                   popf           sal            test
                                   push           sar            verr
                                   pusha          sbb            verw
                                   pushf          shl            wait
                                   rcl            shr            xchg
                                   rcr            smsw           xlat
                                                                 xor
                    -------------------------------------------------------


                    String instructions
                    =======================================================

                    In addition to the listed opcodes, the string
                    instructions given in the following table can be used
                    alone or with repeat prefixes.
          String
    instructions    -------------------------------------------------------
                       cmps          insw           movsb          outsw          stos
                       cmpsb         lods           movsw          scas           stosb
                       cmpsw         lodsb          outs           scasb          stosw
                       ins           lodsw          outsb          scasw
                       insb          movs

                    -------------------------------------------------------


                    Prefixes
                    =======================================================

                    The following prefixes can be used:

                     lock   rep   repe   repne   repnz   repz


                    Jump instructions
                    =======================================================

                    Jump instructions are treated specially. Since a label
                    cannot be included on the instruction itself, jumps
                    must go to C labels (discussed in "Using jump
                    instructions and labels" on page 8). The allowed jump
                    instructions are given in the next table.



                                   - 5 -






                    Table 1.3: Jump instructions (continued)_______________

            Jump    -------------------------------------------------------
    instructions      ja      jge     jnc      jns     loop
                      jae     jl      jne      jnz     loope
                      jb      jle     jng      jo      loopne
                      jbe     jmp     jnge     jp      loopnz
                      jc      jna     jnl      jpe     loopz
                      jcxz    jnae    jnle     jpo
                      je      jnb     jno      js
                      jg      jnbe    jnp      jz

                    -----------------------------------------


                    Assembly directives
                    =======================================================

                    The following assembly directives are allowed in Turbo
                    C++ inline assembly statements:

                      db      dd      dw       extrn


------------------  You can use C symbols in your asm statements; Turbo C++
   Inline assembly  automatically converts them to appropriate assembly
references to data  language operands and appends underscores onto
     and functions  identifier names. You can use any symbol, including
------------------  automatic (local) variables, register variables, and
                    function parameters.

                    In general, you can use a C symbol in any position
                    where an address operand would be legal. Of course, you
                    can use a register variable wherever a register would
                    be a legal operand.

                    If the assembler encounters an identifier while parsing
                    the operands of an inline assembly instruction, it
                    searches for the identifier in the C symbol table. The
                    names of the 80x86 registers are excluded from this
                    search. Either uppercase or lowercase forms of the
                    register names can be used.









                                   - 6 -






                    Inline assembly and register variables
                    =======================================================

                    Inline assembly code can freely use SI or DI as scratch
                    registers. If you use SI or DI in inline assembly code,
                    the compiler won't use these registers for register
                    variables.


                    Inline assembly, offsets, and size overrides
                    =======================================================

                    When programming, you don't need to be concerned with
                    the exact offsets of local variables. Simply using the
                    name will include the correct offsets.

                    However, it may be necessary to include appropriate
                    WORD PTR, BYTE PTR, or other size overrides on assembly
                    instruction. A DWORD PTR override is needed on LES or
                    indirect far call instructions.


------------------  You can reference structure members in an inline
 Using C structure  assembly statement in the usual fashion (that is,
           members  variable.member). In such a case, you are dealing with
------------------  a variable, and you can store or retrieve values.
                    However, you can also directly reference the member
                    name (without the variable name) as a form of numeric
                    constant. In this situation, the constant equals the
                    offset (in bytes) from the start of the structure
                    containing that member. Consider the following program
                    fragment:

                     struct myStruct {
                        int a_a;
                        int a_b;
                        int a_c;
                     } myA ;

                     myfunc()
                     {
                        ...
                        asm  {mov  ax, myA.a_b
                              mov  bx, [di].a_c
                             }
                        ...
                     }




                                   - 7 -






                    We've declared a structure type named myStruct with
                    three members, a_a, a_b, and a_c; we've also declared a
                    variable myA of type myStruct. The first inline
                    assembly statement moves the value contained in myA.a_b
                    into the register AX. The second moves the value at the
                    address [di] + offset(a_c) into the register BX (it
                    takes the address stored in DI and adds to it the
                    offset of a_c from the start of myStruct). In this
                    sequence, these assembler statements produce the
                    following code:

                     mov  ax, DGROUP : myA+2
                     mov  bx, [di+4]

                    Why would you even want to do this? If you load a
                    register (such as DI) with the address of a structure
                    of type myStruct, you can use the member names to
                    directly reference the members. The member name
                    actually can be used in any position where a numeric
                    constant is allowed in an assembly statement operand.

                    The structure member must be preceded by a dot (.) to
                    signal that a member name, rather than a normal C
                    symbol, is being used. Member names are replaced in the
                    assembly output by the numeric offset of the structure
                    member (the numeric offset of a_c is 4), but no type
                    information is retained. Thus members can be used as
                    compile-time constants in assembly statements.

                    However, there is one restriction. If two structures
                    that you are using in inline assembly have the same
                    member name, you must distinguish between them. Insert
                    the structure type (in parentheses) between the dot and
                    the member name, as if it were a cast. For example,

                       asm   mov    bx,[di].(struct tm)tm_hour


------------------  You can use any of the conditional and unconditional
        Using jump  jump instructions, plus the loop instructions, in
  instructions and  inline assembly. They are only valid inside a function.
            labels  Since no labels can be defined in the asm statements,
------------------  jump instructions must use C goto labels as the object
                    of the jump. If the label is too far away, the jump
                    will be automatically converted to a long-distance
                    jump. Direct far jumps cannot be generated.





                                   - 8 -






                    In the following code, the jump goes to the C goto
                    label a.

                     int     x()
                     {
                     a:                /* This is the goto label "a" */
                        ...
                        asm  jmp  a    /* Goes to label "a" */
                        ...
                     }

                    Indirect jumps are also allowed. To use an indirect
                    jump, you can use a register name as the operand of the
                    jump instruction.


   Interrupt func-  =======================================================
             tions
                    The 80x86 reserves the first 1024 bytes of memory for a
                    set of 256 far pointers--known as interrupt vectors--to
                    special system routines known as interrupt handlers.
                    These routines are called by executing the 80x86
                    instruction

                      int  int#

                    where int# goes from 0h to FFh. When this happens, the
                    computer saves the code segment (CS), instruction
                    pointer (IP), and status flags, disables the
                    interrupts, then does a far jump to the location
                    pointed to by the corresponding interrupt vector. For
                    example, one interrupt call you're likely to see is

                      int  21h

⌨️ 快捷键说明

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