机器级表示

发布于 2024-09-30 15:33:56 字数 2009 浏览 0 评论 0原文

我正在做这个项目,这个特定的部分让我感到困惑。我们得到了这个机器级别的表示,它将读取我必须弄清楚的六个数字。到目前为止,我知道这是一个循环,它将迭代直到到达停止子句。我们不希望它在 0x08048d3a 处调用爆炸:调用 0x80492f3 。有谁知道将生成什么六个数字。非常感谢任何帮助。

0x08048d0b <phase_2+0>:         push   %ebp
0x08048d0c <phase_2+1>:         mov    %esp,%ebp
0x08048d0e <phase_2+3>:         push   %esi
0x08048d0f <phase_2+4>:         push   %ebx
0x08048d10 <phase_2+5>:         sub    $0x30,%esp
0x08048d13 <phase_2+8>:         lea    -0x20(%ebp),%eax
0x08048d16 <phase_2+11>:        mov    %eax,0x4(%esp)
0x08048d1a <phase_2+15>:        mov    0x8(%ebp),%eax
0x08048d1d <phase_2+18>:        mov    %eax,(%esp)
0x08048d20 <phase_2+21>:        call   0x8049335 <read_six_numbers>
0x08048d25 <phase_2+26>:        mov    $0x2,%ebx
0x08048d2a <phase_2+31>:        lea    -0x20(%ebp),%esi
0x08048d2d <phase_2+34>:        mov    -0x8(%esi,%ebx,4),%eax
0x08048d31 <phase_2+38>:        add    $0x5,%eax
0x08048d34 <phase_2+41>:        cmp    %eax,-0x4(%esi,%ebx,4)
0x08048d38 <phase_2+45>:        je     0x8048d3f <phase_2+52>
0x08048d3a <phase_2+47>:        call   0x80492f3 <explode_bomb>
0x08048d3f <phase_2+52>:        add    $0x1,%ebx
0x08048d42 <phase_2+55>:        cmp    $0x7,%ebx
0x08048d45 <phase_2+58>:        jne    0x8048d2d <phase_2+34>
0x08048d47 <phase_2+60>:        add    $0x30,%esp
0x08048d4a <phase_2+63>:        pop    %ebx
0x08048d4b <phase_2+64>:        pop    %esi
0x08048d4c <phase_2+65>:        pop    %ebp
0x08048d4d <phase_2+66>:        ret

你能具体解释一下这些行发生了什么吗?

0x08048d10 <phase_2+5>:         sub    $0x30,%esp
0x08048d13 <phase_2+8>:         lea    -0x20(%ebp),%eax
0x08048d16 <phase_2+11>:        mov    %eax,0x4(%esp)
0x08048d1a <phase_2+15>:        mov    0x8(%ebp),%eax
0x08048d1d <phase_2+18>:        mov    %eax,(%esp)

谢谢!!

I'm doing this project and this particular portion is confusing me. We are given this machine level representation and it will read six numbers that I have to figure out. So far I know that this is a loop and it will iterate until it reaches it's stop clause. We do not want it to ever make the call to explode at 0x08048d3a : call 0x80492f3 . Does anyone know what six numbers are going to be generated. Any help is greatly appreciated.

0x08048d0b <phase_2+0>:         push   %ebp
0x08048d0c <phase_2+1>:         mov    %esp,%ebp
0x08048d0e <phase_2+3>:         push   %esi
0x08048d0f <phase_2+4>:         push   %ebx
0x08048d10 <phase_2+5>:         sub    $0x30,%esp
0x08048d13 <phase_2+8>:         lea    -0x20(%ebp),%eax
0x08048d16 <phase_2+11>:        mov    %eax,0x4(%esp)
0x08048d1a <phase_2+15>:        mov    0x8(%ebp),%eax
0x08048d1d <phase_2+18>:        mov    %eax,(%esp)
0x08048d20 <phase_2+21>:        call   0x8049335 <read_six_numbers>
0x08048d25 <phase_2+26>:        mov    $0x2,%ebx
0x08048d2a <phase_2+31>:        lea    -0x20(%ebp),%esi
0x08048d2d <phase_2+34>:        mov    -0x8(%esi,%ebx,4),%eax
0x08048d31 <phase_2+38>:        add    $0x5,%eax
0x08048d34 <phase_2+41>:        cmp    %eax,-0x4(%esi,%ebx,4)
0x08048d38 <phase_2+45>:        je     0x8048d3f <phase_2+52>
0x08048d3a <phase_2+47>:        call   0x80492f3 <explode_bomb>
0x08048d3f <phase_2+52>:        add    $0x1,%ebx
0x08048d42 <phase_2+55>:        cmp    $0x7,%ebx
0x08048d45 <phase_2+58>:        jne    0x8048d2d <phase_2+34>
0x08048d47 <phase_2+60>:        add    $0x30,%esp
0x08048d4a <phase_2+63>:        pop    %ebx
0x08048d4b <phase_2+64>:        pop    %esi
0x08048d4c <phase_2+65>:        pop    %ebp
0x08048d4d <phase_2+66>:        ret

Specifically can you explain what happens at these lines

0x08048d10 <phase_2+5>:         sub    $0x30,%esp
0x08048d13 <phase_2+8>:         lea    -0x20(%ebp),%eax
0x08048d16 <phase_2+11>:        mov    %eax,0x4(%esp)
0x08048d1a <phase_2+15>:        mov    0x8(%ebp),%eax
0x08048d1d <phase_2+18>:        mov    %eax,(%esp)

Thank you!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩发小公举 2024-10-07 15:33:56

这个 AT&T 语法让我很困惑,但这部分很简单:

0x08048d10 <phase_2+5>:         sub    $0x30,%esp //reserve additional 0x30bytes 12 ints) on the stack
0x08048d13 <phase_2+8>:         lea    -0x20(%ebp),%eax // int vals[6]; eax = vals;
0x08048d16 <phase_2+11>:        mov    %eax,0x4(%esp) // int some_local_var = vals;
0x08048d1a <phase_2+15>:        mov    0x8(%ebp),%eax // first param we received
0x08048d1d <phase_2+18>:        mov    %eax,(%esp) // pass it as param to function
0x08048d20 <phase_2+21>:        call   0x8049335 <read_six_numbers>

This AT&T syntax confuses me, but this part is simple:

0x08048d10 <phase_2+5>:         sub    $0x30,%esp //reserve additional 0x30bytes 12 ints) on the stack
0x08048d13 <phase_2+8>:         lea    -0x20(%ebp),%eax // int vals[6]; eax = vals;
0x08048d16 <phase_2+11>:        mov    %eax,0x4(%esp) // int some_local_var = vals;
0x08048d1a <phase_2+15>:        mov    0x8(%ebp),%eax // first param we received
0x08048d1d <phase_2+18>:        mov    %eax,(%esp) // pass it as param to function
0x08048d20 <phase_2+21>:        call   0x8049335 <read_six_numbers>
童话里做英雄 2024-10-07 15:33:56
char answer[6];
answer[0] = any_char
for n > 0
answer[n] = answer[n-1] + 5;
char answer[6];
answer[0] = any_char
for n > 0
answer[n] = answer[n-1] + 5;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文