因此,我正在尝试从CPUID函数中提取信息。现在,我只需要步进信息,该信息应该在调用cpuid之后包含在%rax的前3位中。但是,当我得到数据时,然后按位加7,就出现了段错误。任何帮助,将不胜感激!
# CPUID
# Command stored in %RAX
# 0. Vendor ID string & max CPUID option value supported
# %RBX contains low 4 bytes of string
# %RDX contains middle 4 bytes of string
# %RCX contains last 4 bytes of string
# 1. Processor type, family, model, and stepping info
# 2. Processor cache config
# 3. Processor serial number
# 4. Cache config (# threads, # cores, physical properties)
# 5. Monitor info
# 80000000h. Extended vendor ID string & supported levels.
# 80000001h. Extended 1.
# 8000000(2-4)h. Extended processor name string
.section .data
#asciz null-terminates the string
out7: .asciz "stepping_id: %x\n"
.section .bss
.lcomm buffer, 4
.section .text
.global _start
_start:
# stack stuff
pushq %rbp
movq %rsp, %rbp
# vendor ID value into rax
movq $1, %rax
cpuid
movq $buffer, %rsi
# Using rcx as a temp register
movq %rax, %rcx
andq 7,%rcx;
movq %rcx, (%rsi)
movq $0, %rax
movq $out7, %rdi
call printf
#exit
movq $0, %rdi
movq $60, %rax
syscall