and source, destination
# cpuidtest.s - An example of using the TEST instruction
.section .data
output_cpuid:
.asciz "This processor suports the CPUID instruction\n"
output_nocpuid:
.asciz "This processor does not support the CPUID instruction\n"
.section .text
.global _start
_start:
nop
pushfl
popl %eax
movl %eax, %edx
xor $0x00200000, %eax # change cpuid bit
pushl %eax
popfl # save the change
pushfl
popl %eax
xor %edx, %eax
jnz cpuid
pushl $output_nocpuid # can not change the cpuid bit
call printf
add $4, %esp
pushl $0
call exit
cpuid: # change successfully
pushl $output_cpuid
call printf
add $4, %esp
pushl $0
call exit
as -gstabs -o cpuid.o cpuid.s
ld -dynamic-linker /lib/ld-linux.so.2 -lc -o cpuid cpuid.o
./cpuid
This processor suports the CPUID instruction
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |