汇编程序说未设置 ID 标志?

问题描述

我正在尝试检查是否使用 ID 指令设置了 test 标志并打印是否支持 cpuid 指令,但它总是说不支持 cpuid,我不知道为什么。

.section .data
output:
    .asciz "Processor does support cpuid\n"
output2:
    .asciz "Processor does NOT support cpuid\n "
.section .bss
.section .text
.globl main
main:

    nop

    pushfq                           # push rflags
    popq %rdi                        # store rflags in rdi
    test $0x200000,%rdi             # test if ID flag is set
    jz nocpuid                       # print no cpuid if zero flag
    xor %rax,%rax
    movq $output,%rdi               # else print cpuid is supported
    call printf
    movq $0,%rdi
    call exit

    nocpuid:
        xor %rax,%rax
        movq $output2,%rdi
        call printf
        movq $0,%rdi
        call exit

链接和组装为

    gcc -no-pie -gstabs+ test.s -o test

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)