Получение CPUID Into в 64-битной сборке? - PullRequest
0 голосов
/ 05 ноября 2018

Итак, я пытаюсь получить информацию из функции CPUID. Сейчас я просто хочу информацию о шаге, которая должна содержаться в первых 3 битах в% rax после вызова cpuid. Тем не менее, когда я получаю данные, затем поразрядно и с 7, я получаю segfault. Любая помощь будет оценена!

#   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
...