装配无限循环
我的 x86 汇编传奇还在继续,我进入了这段代码的无限循环,我有点困惑。
movl $1, %ecx
movl $4, %edi
do_loop:
cmpl %edi, %ecx
je do_exit
.........
do_stuff
.........
incl %ecx
jmp do_loop
do_exit:
我期望当 %ecx 达到 4 时跳转到 do_exit: ,因为它在每次迭代中都会递增
My saga with x86 assembly continues, I'm getting into an infinite loop with this piece of code and I'm a bit puzzled.
movl $1, %ecx
movl $4, %edi
do_loop:
cmpl %edi, %ecx
je do_exit
.........
do_stuff
.........
incl %ecx
jmp do_loop
do_exit:
I'm expecting a jump to do_exit: when %ecx reaches 4 since it's incremented in every iteration
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有调试器? do_stuff 是否修改 %edi?尝试注释掉 do_stuff 。
No debugger? Does do_stuff modify %edi? Try commenting do_stuff out.
正如其他人提到的,请小心
do_stuff
中的寄存器使用。您真正要寻找的是调用约定,尤其是这一行:< em>函数中可以使用寄存器 EAX、ECX 和 EDX。
As others have mentioned, be careful with register usage in
do_stuff
. And the real thing that you are looking for are calling conventions, and especially this line:Registers EAX, ECX, and EDX are available for use in the function.
我不知道 do_exit 后面是否有空格,也不知道你如何执行汇编代码......
但尝试在 do_exit 之后添加以下内容:
I dont know if the do_exit is followed by blanks and I have no idea how you are executing the assembly code...
but try to add the following after the do_exit: