gas的汇编问题

软件和网站开发以及相关技术探讨
回复
头像
Chine
帖子: 204
注册时间: 2006-12-22 21:50
送出感谢: 0
接收感谢: 0
联系:

gas的汇编问题

#1

帖子 Chine » 2008-05-16 23:01

下面这段是来自<<Professional Assembly Language>>(汇编语言程序设计)的测试列出在处理器上找到SIMD特性的汇编代码:

# features.s -Determin MMX SSE SSE2 and SSE3 capabilites
.section .data
gotmmx:
.asciz "Supperts MMX"
gotsse:
.asciz "Supperts SSE"
gotsse2:
.asciz "Supperts SSE2"
gotsse3:
.asciz "Supperts SSE3"
output:
.asciz "%s\n"

.section .bss
.lcomm ecxdata,4
.lcomm edxdata,4

.section .text
.global _start
_start:
nop
movl $1,%eax
cpuid
movl %ecx,ecxdata
movl %edx,edxdata

test $0x00800000,%edx
jz done
pushl $gotmmx
pushl $output
call printf
addl $8,%edx

movl edxdata,%edx
test $0x02000000, %edx
jz done
pushl $gotsse
pushl $output
call printf
addl $8,%esp

movl edxdata,%edx
test $0x04000000, %edx
jz done
pushl $gotsse2
pushl $output
call printf
addl $8,%esp

movl edxdata,%edx
test $0x00000001, %edx
jz done
pushl $gotsse3
pushl $output
call printf
addl $8,%esp

done:
pushl $0
call exit

汇编后显示下面错误:
$as -o features.o features.s
features.s: Assembler messages:
features.s:0: Warning: end of file not at end of a line; newline inserted
features.s:28: Error: suffix or operands invalid for `push'
features.s:29: Error: suffix or operands invalid for `push'
features.s:36: Error: suffix or operands invalid for `push'
features.s:37: Error: suffix or operands invalid for `push'
features.s:44: Error: suffix or operands invalid for `push'
features.s:45: Error: suffix or operands invalid for `push'
features.s:52: Error: suffix or operands invalid for `push'
features.s:53: Error: suffix or operands invalid for `push'
features.s:58: Error: suffix or operands invalid for `push'

将pushl改为push后可以顺利汇编,但连接运行时显示:
$./features
段错误

还有Google上的都是pushl啊,求大侠解答.
回复

回到 “软件/网站开发”