上面有一个小的demo
-
.section .data
-
output:
-
.asciz "The processor Vendor ID is '%s'\n"
-
.section .bss
-
.lcomm buffer, 14
-
.section .text
-
.code32
-
.globl main
-
main:
-
movl $0, %eax
-
cpuid
-
movl $buffer, %edi
-
movl %ebx, (%edi)
-
movl %edx, 4(%edi)
-
movl %ecx, 8(%edi)
-
push $buffer
-
push $output
-
call printf
-
addl $8, %esp
-
push $0
-
call exit
cong@dell:/work/code/cpuid$ gcc -g -o cpu cpu.s
cong@dell:/work/code/cpuid$ ./cpu
Segmentation fault (core dumped)
找了好久都不知道问题在哪儿,在以前的系统上是可以运行的,但现在怎么不能运行了呢?
突然想起自己的机子为了编译android改成了64位的,难道?
cong@dell:/work/code/cpuid$ gcc -g -o cpu cpu.s -m32
cong@dell:/work/code/cpuid$ ./cpu
The processor Vendor ID is 'GenuineIntel
原来真的是: 64位编译32位的汇编时需要加上 -m32
阅读(1995) | 评论(0) | 转发(0) |