天天看点

第76部分- Linux x86 64位汇编 CPUID第76部分- Linux x86 64位汇编 CPUID

第76部分- Linux x86 64位汇编 CPUID

CPUID指令是一条汇编语言指令。

第76部分- Linux x86 64位汇编 CPUID第76部分- Linux x86 64位汇编 CPUID

处理器把厂商字符串返回到ebx,edx和ecx寄存器中。

示例

如下:

#cpuid.s Sample program to extract the processor Vendor ID
.section .data
output:
   .ascii "The processor Vendor ID is 'xxxxxxxxxxxx'\n"
.section .text
.globl _start
_start:
   movl $0, %eax;//选择功能0
   cpuid
   movl $output, %edi;//写地址到edi寄存器
   movl %ebx, 28(%edi) ;//从ebx读结果出来
   movl %edx, 32(%edi) ;//从edx读结果出来
   movl %ecx, 36(%edi) ;//从ecx读结果出来
   movl $4, %eax;//系统调用写到控制台上
   movl $1, %ebx
   movl $output, %ecx
   movl $42, %edx
   int $0x80
   movl $60, %eax
   syscall
           

继续阅读