简体   繁体   English

GDB汇编语言指令添加

[英]Gdb assembly language instruction add

I need to understand the add instruction in assembly code: 我需要了解汇编代码中的添加指令:

=> 0x08048bff <+43>:    add    0x14(%esp,%ebx,4),%eax
(gdb) i r
eax            0x1      1
ecx            0x0      0
edx            0x0      0
ebx            0x1      1
esp            0xffffcd70       0xffffcd70
ebp            0xffffcdc8       0xffffcdc8
esi            0x0      0
edi            0x0      0
eip            0x8048bff        0x8048bff <phase_2+43>
eflags         0x202    [ IF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x0      0
gs             0x63     99

I think the answer for 0x14(%esp,%ebx,4) is (%ebx*4)+%esp+0x14 but what I got was 0xffffcd82 and I don't know what address that is from the registers. 我认为0x14(%esp,%ebx,4)的答案是(%ebx*4)+%esp+0x14但是我得到的是0xffffcd82 ,我不知道寄存器中的地址是什么。 Can someone explain to be what value I'm supposed to put in %eax ? 有人可以解释一下我应该在%eax赋予什么价值吗?

Yes, you are right that 0x14(%esp,%ebx,4) is at&t syntax for (%ebx*4)+%esp+0x14 . 是的,您说对了, 0x14(%esp,%ebx,4)(%ebx*4)+%esp+0x14 at&t语法。 As such, the address is 0xffffcd88 . 这样,地址是0xffffcd88 You can have gdb calculate that for you using p/x $ebx*4+$esp+0x14 . 您可以让gdb使用p/x $ebx*4+$esp+0x14为您计算。 The add instruction will fetch the 4 byte integer in memory at that address and add it to whatever is already in %eax . add指令将在该地址获取内存中的4字节整数,并将其添加到%eax已存在的任何内容中。 You can check the memory contents in gdb using for example x/d 0xffffcd88 . 您可以使用例如x/d 0xffffcd88来检查gdb中的内存内容。

PS: you can switch gdb to use intel syntax which should be easier to read using set disassembly-flavor intel . PS:您可以将gdb切换为使用intel语法,使用set disassembly-flavor intel可以更轻松地阅读它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM