分类:
2011-03-06 01:38:30
|
movl values(,%edi,4), %eax
表达格式是:base_addr(offset_addr, index, size)
获取的位置等于:
base_addr + offset_addr + index * size
如果其中的任何值为0,就可以忽略他们(但是仍然需要用逗号作为占位符)。offset_addr和index的值必须是寄存器,但size的值可以是数字值。
我们再看另外的例子:
|
[root@localhost assembly_study]# as -o movtest4.o -gstabs movtest4.s [root@localhost assembly_study]# ld -o movtest4 movtest4.o [root@localhost assembly_study]# gdb movtest4 GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"... (gdb) break *_start+1 Breakpoint 1 at 0x8048075: file movtest4.s, line 9. (gdb) list 1 .section .data 2 values: 3 .int 10,15,20,25,30,35,40,45,50,55,60 4 5 .section .text 6 .global _start 7 _start: 8 nop 9 movl values, %eax 10 movl $values, %edi (gdb) list 11 movl $100, 4(%edi) 12 movl $1, %edi 13 movl values(,%edi,4), %ebx 14 movl $1, %eax 15 int $0x80 (gdb) run Starting program: /home/assembly_study/movtest4 Breakpoint 1, Current language: auto; currently asm (gdb) x/d $values Value can't be converted to integer. (gdb) x/4d &values 0x804909c (gdb) s 10 movl $values, %edi (gdb) info registers eax 0xa 10 ecx 0x0 0 edx 0x0 0 ebx 0x0 0 esp 0xbfffdd90 0xbfffdd90 ebp 0x0 0x0 esi 0x0 0 edi 0x0 0 eip 0x804807a 0x804807a eflags 0x306 774 cs 0x23 35 ss 0x2b 43 ds 0x2b 43 es 0x2b 43 fs 0x0 0 gs 0x0 0 (gdb) x &values 0x804909c (gdb) x/4d &values 0x804909c (gdb) x/10d &values 0x804909c 0x80490ac 0x80490bc (gdb) x/20d &values 0x804909c 0x80490ac 0x80490bc 0x80490cc: 0 0 0 0 0x80490dc: 0 0 0 0 (gdb) s 11 movl $100, 4(%edi) (gdb) x/4d &values 0x804909c (gdb) list 6 .global _start 7 _start: 8 nop 9 movl values, %eax 10 movl $values, %edi 11 movl $100, 4(%edi) 12 movl $1, %edi 13 movl values(,%edi,4), %ebx 14 movl $1, %eax 15 int $0x80 (gdb) list Line number 16 out of range; movtest4.s has 15 lines. (gdb) info registers eax 0xa 10 ecx 0x0 0 edx 0x0 0 ebx 0x0 0 esp 0xbfffdd90 0xbfffdd90 ebp 0x0 0x0 esi 0x0 0 edi 0x804909c 134516892 eip 0x804807f 0x804807f eflags 0x306 774 cs 0x23 35 ss 0x2b 43 ds 0x2b 43 es 0x2b 43 fs 0x0 0 gs 0x0 0 (gdb) s 12 movl $1, %edi (gdb) x/4d &values 0x804909c (gdb) s 13 movl values(,%edi,4), %ebx (gdb) info registers eax 0xa 10 ecx 0x0 0 edx 0x0 0 ebx 0x0 0 esp 0xbfffdd90 0xbfffdd90 ebp 0x0 0x0 esi 0x0 0 edi 0x1 1 eip 0x804808b 0x804808b eflags 0x306 774 cs 0x23 35 ss 0x2b 43 ds 0x2b 43 es 0x2b 43 fs 0x0 0 gs 0x0 0 (gdb) s 14 movl $1, %eax (gdb) info resigers Undefined info command: "resigers". Try "help info". (gdb) info registers eax 0xa 10 ecx 0x0 0 edx 0x0 0 ebx 0x64 100 esp 0xbfffdd90 0xbfffdd90 ebp 0x0 0x0 esi 0x0 0 edi 0x1 1 eip 0x8048092 0x8048092 eflags 0x306 774 cs 0x23 35 ss 0x2b 43 ds 0x2b 43 es 0x2b 43 fs 0x0 0 gs 0x0 0 (gdb) print $eax $1 = 10 (gdb) |