linux下Intel汇编使用pushl和movq指令的问题
这是我的操作平台:$ uname -a
Linux ------ 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
一、movq指令加载内存中的数据到mmx寄存器后,在gdb中使用print命令查看mmx寄存器显示为void
汇编程序:
程序代码:
.section .data intv: .int 1, -1 bytev: .byte 0x10, 0x05, 0xff, 0x32, 0x47, 0xe5, 0x23, 0x12 quadv: .quad 123456 .section .text .globl _start _start: nop movq intv, %mm0 movq bytev, %mm1 movq quadv, %mm2 movl $1, %eax movl $0, %ebx int $0x80
编译链接:
$ as -gstabs -o mmx.o mmx.s
$ ld -o mmx mmx.o
查看
(gdb)print $mm0
$1 = void
(gdb)print $mm1
$2 = void
(gdb)print $mm2
$3 = void
为什么显示的是void而不是加载进去的值???
二、使用pushl指令出错
程序代码:
.section .data value: .int 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 output: .asciz "The value is %d\n" .section .text .globl _start _start: nop movl $0, %edi loop: movl value(, %edi, 4), %eax pushl %eax pushl $output call printf addl $8, %esp inc %edi cmpl $11, %edi jne loop movl $0, %ebx movl $1, %eax int $0x80
编译出错:
$ as -gstabs -o loop.o loop.s
loop.s: Assembler messages:
loop.s:13: Error: suffix or operands invalid for `push'
loop.s:14: Error: suffix or operands invalid for `push'
网上查说加--32参数:
$ as -gstabs -o loop.o loop.s
试了下,编译通过了。
链接出错:
$ ld -o loop loop.o
loop.o: could not read symbols: File in wrong format
$ file loop.o
loop.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
请问造成上述2个问题的原因什么?该如何解
[ 本帖最后由 锋了 于 2014-4-14 22:17 编辑 ]