Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2116723
  • 博文数量: 438
  • 博客积分: 3871
  • 博客等级: 中校
  • 技术积分: 6075
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-10 00:11
个人简介

邮箱: wangcong02345@163.com

文章分类

全部博文(438)

文章存档

2017年(15)

2016年(119)

2015年(91)

2014年(62)

2013年(56)

2012年(79)

2011年(16)

分类: LINUX

2014-03-31 11:21:39

上面有一个小的demo
  1. .section .data
  2. output:
  3.     .asciz "The processor Vendor ID is '%s'\n"
  4. .section .bss
  5. .lcomm buffer, 14
  6. .section .text
  7. .code32
  8. .globl main
  9. main:
  10.     movl $0, %eax
  11.     cpuid
  12.     movl $buffer, %edi
  13.     movl %ebx, (%edi)
  14.     movl %edx, 4(%edi)
  15.     movl %ecx, 8(%edi)
  16.     push $buffer
  17.     push $output
  18.     call printf
  19.     addl $8, %esp
  20.     push $0
  21.     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




阅读(1893) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~