怎样调用汇编语言。用什么语句。

解决方案 »

  1.   

    上边的傻子。这个问题用你答呀。你看一下代码。在发言吧
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;const
      id_bit = $20000;
    type
      tcpuid = array[1..4] of longint;
      tvendor = array[0..11] of char;function iscpuid_available :boolean; register;
    asm
      pushfd {direct access to flags no possible, only via stack}
      pop  eax
      mov  edx,eax
      xor  eax,id_bit
      push eax
      popfd
      pop eax
      xor eax,edx
      jz  @exit
      mov al,edx
      @exit:
    end;
    function getcpuid :tcpuid; assembler;register;
      asm
       push ebx
       push edi
       mov  edi,eax
       mov eax,1
       dw  $a20f
       stosd
       mov eax,ebx
       stosd
       mov eax,ecx
       stosd
       mov eax,edx
       stosd
       pop edi
       pop ebx
    end;
    function getcpuvendor :tvendor ;assembler;register;
    asm
      push ebx
      push edi
      mov edi,eax
      mov eax,0
      dw $a20f
      mov eax,ebx
      xchg ebx,ecx
      mov ecx,4
    @1:
      stosb
      shr eax,8
      loop @1
      mov eax,edx
      mov ecx,4
    @2:
      stosb
      shr eax,8
      loop @2
      mov eax,ebx
      mov ecx,4
    @3:
      stosb
      shr eax,8
      loop @3
      pop edi
      pop ebx
    edn;
    end.
      

  2.   

    现在一到asm就有错误
    [Error] Unit2.pas(18): Statements not allowed in interface part
    请帮我解决一下。
      

  3.   

    asm
     汇编语句
      ...
    end;
      

  4.   

    函数定义不要在接口部分!
    type
      tcpuid = array[1..4] of longint;
      tvendor = array[0..11] of char;implementationfunction .....
    begin
      asm
        ...
      end;
    end;
    ......
      

  5.   

    编译通过,unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;const
      id_bit = $20000;type
      Tcpuid = array[1..4] of longint;
      Tvendor = array[0..11] of char;implementationfunction iscpuid_available :boolean; register;
    asm
      pushfd {direct access to flags no possible, only via stack}
      pop  eax
      mov  edx,eax
      xor  eax,id_bit
      push eax
      popfd
      pop eax
      xor eax,edx
      jz  @exit
      //mov al,edx 
      mov EAX,edx //<<------
      @exit:
    end;
    function getcpuid :tcpuid; assembler;register;
      asm
       push ebx
       push edi
       mov  edi,eax
       mov eax,1
       dw  $a20f
       stosd
       mov eax,ebx
       stosd
       mov eax,ecx
       stosd
       mov eax,edx
       stosd
       pop edi
       pop ebx
    end;
    function getcpuvendor :tvendor ;assembler;register;
    asm
      push ebx
      push edi
      mov edi,eax
      mov eax,0
      dw $a20f
      mov eax,ebx
      xchg ebx,ecx
      mov ecx,4
    @1:
      stosb
      shr eax,8
      loop @1
      mov eax,edx
      mov ecx,4
    @2:
      stosb
      shr eax,8
      loop @2
      mov eax,ebx
      mov ecx,4
    @3:
      stosb
      shr eax,8
      loop @3
      pop edi
      pop ebx
    end;
    end.
      

  6.   

    to:流水逝光
    现在还有一处错误请看代码
    unit li2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;const
      id_bit = $20000;
    type
      tcpuid = array[1..4] of longint;
      tvendor = array[0..11] of char;
    implementationfunction iscpuid_available :boolean; register;
    asm
      pushfd {direct access to flags no possible, only via stack}
      pop  eax
      mov  edx,eax
      xor  eax,id_bit
      push eax
      popfd
      pop eax
      xor eax,edx
      jz  @exit
      mov al,ture 此处有错误
      @exit:
    end;
    function getcpuid :tcpuid; assembler;register;
      asm
       push ebx
       push edi
       mov  edi,eax
       mov eax,1
       dw  $a20f
       stosd
       mov eax,ebx
       stosd
       mov eax,ecx
       stosd
       mov eax,edx
       stosd
       pop edi
       pop ebx
    end;
    function getcpuvendor :tvendor ;assembler;register;
    asm
      push ebx
      push edi
      mov edi,eax
      mov eax,0
      dw $a20f
      mov eax,ebx
      xchg ebx,ecx
      mov ecx,4
    @1:
      stosb
      shr eax,8
      loop @1
      mov eax,edx
      mov ecx,4
    @2:
      stosb
      shr eax,8
      loop @2
      mov eax,ebx
      mov ecx,4
    @3:
      stosb
      shr eax,8
      loop @3
      pop edi
      pop ebx
    end;
    end.[Error] li2.pas(29): Undeclared identifier: 'ture'
      

  7.   

    mov al,edx
    al是存贮低8位地寄存器,EDX是存储32位地寄存器,因此要改为
    mov EAX,EDX具体调用情况没试过。
    不对之处还请指正!
      

  8.   

    那是我的错误。应是mov al,true
    可现在这里有错误。
      

  9.   

    如果你是
    mov al,True改为
    mov EAX,True
      

  10.   

    其实True就是1
    可以
    mov eax, 1
    就行