# An example of using the TEST instruction
#
.section .data
output_cpuid:
.asciz "This processor supports the CPUID instruction.\n"
output_nocpuid:
.asciz "This processor does not support the CPUID instruction.\n"
.section .text
.globl main
main:
nop
pushfl # 把EFLAGS的值保存到堆栈顶部
popl %eax # 把EFLAGS值读取到EAX中
movl %eax, %edx
xor $0x00200000, %eax
push %eax
popfl # 把它存储在EFLAGS中
pushfl # 再次EFLAGS入堆栈
popl %eax
xor %edx, %eax
test $0x00200000, %eax
jnz cpuid
push $output_nocpuid
call printf
add $4, %esp
push $0
call exit
cpuid:
push $output_cpuid
call printf
add $4, %esp
push $0
call exit