按书上说的,写了个程序,编译时发生“段错误 (核心已转储)”,然后用gdb来调试,发现问题是Program received signal SIGSEGV, Segmentation fault.
gcc的版本是gcc version 9.3.0 (系统是Ubuntu20.04)
文件名cpuid2.s,代码是
#cpuid2.s View the CPUID Vendor ID string using C library calls
.code32
.section .data
output:
.asciz "The processor Vendor ID is '%s'\n"
.section .bss
.lcomm buffer, 12
.section .text
.globl main
main:
movl $0, %eax
cpuid
movl $buffer, %edi
movl %ebx, (%edi)
movl %edx, 4(%edi)
movl %ecx, 8(%edi)
pushl $buffer
pushl $output
call printf
addl $8, %esp
pushl $0
call exit
gdb调试的结果是
求大神帮忙分析!谢谢!