x264中的cpu-a.asm

来源:互联网 发布:怎样抢注域名 编辑:程序博客网 时间:2024/04/30 15:28

转自:http://blog.csdn.net/xiaoyi247/article/details/7917537

CPUID指令是用来搜集当前程序正在运行的处理器信息的,包括厂商和信号信息。在IA-32中,CPUID指令使用EAX寄存器作为输入,EAX寄存器用来指定需要查看的信息的类型,根据EAX的数值的不同,CPUID指令会产生不同的信息,存入EBX,ECX,EDX寄存器中。

      下面的表格显示了在指定不同的EAX的值的时候,得到的CPU的信息


EAX ValueCPUID Output0Vendor ID string, and the maximum CPUID option value supported1Processor type, family, model, and stepping information2Processor cache configuration3 Processor serial number4Cache configuration (number of threads, number of cores, and
physical properties)5Monitor information80000000h Extended vendor ID string and supported levels80000001h Extended processor type, family, model, and stepping information80000002h Extended processor name string

        

或者更详细的信息,可以参看INTEL的文档

Intel® Processor Identification and the CPUID Instruction

http://www.intel.com/content/www/us/en/processors/processor-identification-cpuid-instruction-note.html?wapkw=cpuid


     当EAX为0时,CPUID指令产生一个字符串,将存入EBX,EDX和ECX中。其中,EBX包含字符串的后面四个字符,EDX包含中间四个字符,ECX包含前面四个字符。


     

x264中的汇编代码解析

   cglobal x264_cpu_cpuid, 5,7
    push    rbx
    mov     r11,   r1
    mov     r10,   r2
    movifnidn r9,  r3
    movifnidn r8,  r4
    mov     eax,   r0d ;将要指定的参数存入到eax中
    cpuid
    mov     [r11], eax ;将操作结果存入eax,ebx,ecx,edx
    mov     [r10], ebx
    mov     [r9],  ecx
    mov     [r8],  edx
    pop     rbx
    RET


cpu.c中根据的到的数据来判断是否支持某种多媒体指令

  x264_cpu_cpuid( 1, &eax, &ebx, &ecx, &edx );
    if( edx&0x00800000 )
        cpu |= X264_CPU_MMX;
    else
        return 0;
    if( edx&0x02000000 )
        cpu |= X264_CPU_MMXEXT|X264_CPU_SSE;
    if( edx&0x04000000 )
        cpu |= X264_CPU_SSE2;
    if( ecx&0x00000001 )
        cpu |= X264_CPU_SSE3;
    if( ecx&0x00000200 )
        cpu |= X264_CPU_SSSE3;
    if( ecx&0x00080000 )
        cpu |= X264_CPU_SSE4;
    if( ecx&0x00100000 )
        cpu |= X264_CPU_SSE42;

0 0
原创粉丝点击