x264中的cpu-a.asm

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

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


EAX ValueCPUID Output
0Vendor ID string, and the maximum CPUID option value supported
1Processor type, family, model, and stepping information
2Processor cache configuration
3 Processor serial number
4Cache configuration (number of threads, number of cores, and
physical properties)
5Monitor information
80000000h Extended vendor ID string and supported levels
80000001h Extended processor type, family, model, and stepping information
80000002h 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;

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值