博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
x264中的cpu-a.asm
阅读量:2379 次
发布时间:2019-05-10

本文共 1512 字,大约阅读时间需要 5 分钟。

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

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

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

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

     当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;

你可能感兴趣的文章
SpringCloud Zuul 网关
查看>>
SpringCloud 分布式链路追踪、分布式日志系统
查看>>
SpringCloud Config 配置管理
查看>>
富文本编辑器wangEditor
查看>>
一种适合中小团队的的Android自动化压力测试方案
查看>>
CNNs在图像压缩领域的运用——An End-to-End Compression Framework Based on Convolutional Neural Networks
查看>>
Win7下的一些EXE文件图标莫名奇妙丢失
查看>>
[ZZ]变速齿轮作者的文章--绝杀反外挂方案
查看>>
了解内核的装入地址和入口地址,vmlinux.bin与vmlinux
查看>>
内核里面对大小写字符的转换
查看>>
在svn和git之间选择
查看>>
龙星课程: 局部性原理在计算机和分布式系统中的应用
查看>>
eclipse的奇怪的更新方式
查看>>
MIPS技术公司官方对linux的支持信息
查看>>
openflow简介
查看>>
windows7配置虚拟AP的脚本
查看>>
ARM流水线结构的发展(ARM7~ARM11)
查看>>
Dalvik: 从makefile入门
查看>>
常用浮点数常量
查看>>
三角函数的特殊值的结果
查看>>