cpuid instruction

The cpuid assembler instruction can be used to determine the CPU manufacturer:


.section .data
	message: .ascii "The processor Vendor ID is 'xxxxxxxxxxxx'\n"

.section .text
.globl _start
_start:

	movl $0, %eax
	cpuid
	movl $message, %edi
	movl %ebx, 28(%edi)
	movl %edx, 32(%edi)
	movl %ecx, 36(%edi)

	movl $4, %eax			# 32-bit write system call
	movl $1, %ebx			# arg1
	movl $message, %ecx		# arg2
	movl $42, %edx			# arg3
	int $0x80

	movl $1, %eax			# 32-bit exit system call
	movl $0, %ebx			# 1st argument: exit status
	int $0x80

Compile and link with the following commands:


as cpuid.s -o cpuid.o
ld cpuid.o -o cpuid

And run it with:


./cpuid

To generate the following output for an Intel cpu:


The processor Vendor ID is 'GenuineIntel'