o CPUID
The CPUID is opcode which provides processor type and features. This instruction is only supported in x86 architecture such as Intel and AMD.
¡ Calling CPUID
In assembly language, it takes no parameter, CPUID implicitly uses EAX register.
[root@tesla-xen nasm]# vi cpuid.s
.data
s0:
.asciz "Largest basic function number supported: %i\n"
s1:
.asciz "Vendor ID: %.12s\n"
.text
.align 32
.globl main
main:
pushq %rbp
pushq %rbx
movq %rsp,%rbp
subq $16,%rsp
xorl %eax,%eax
cpuid
movl %ebx,0(%rsp)
movl %edx,4(%rsp)
movl %ecx,8(%rsp)
movq $s0,%rdi
movl %eax,%esi
xorb %al,%al
call printf
movq $s1,%rdi
movq %rsp,%rsi
xorb %al,%al
call printf
movq %rbp,%rsp
popq %rbx
popq %rbp
movl $1,%eax
int $0x80
[root@tesla-xen nasm]# gcc cpuid.s -o cpuid
[root@tesla-xen nasm]#
[root@tesla-xen nasm]# ls
cpuid cpuid.s
[root@tesla-xen nasm]#
[root@tesla-xen nasm]#
[root@tesla-xen nasm]# ./cpuid
Largest basic function number supported: 13
Vendor ID: GenuineIntel
[root@tesla-xen nasm]#