在macOS Terminal中输入
cc -arch i386 -Wl,-no_pie cpuid.s
./a.out
输出
The processor Vendor ID is 'GenuineIntel'
代码如下
# cc -arch i386 -Wl,-no_pie cpuid.s
.text
.globl _main
.p2align 2
_main:
pushl %ebp
movl $0, %eax
cpuid
movl $buffer, %edi
movl %ebx, (%edi)
movl %edx, 4(%edi)
movl %ecx, 8(%edi)
pushl $buffer
pushl $output
call _printf
addl $8, %esp
xorl %eax, %eax
popl %ebp
retl
.cstring
output:
.asciz "The processor Vendor ID is '%s'\n"
.lcomm buffer, 13, 2