天天看點

第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
           

繼續閱讀