【发布时间】:2013-12-29 13:13:33
【问题描述】:
我正在尝试找到与以下程序集等效的 C 语言:
.section .text
.globl mystery
.type mystery, @function
mystery:
pushl %ebp
movl %esp, %ebp
xorl %eax, %eax
xorl %exc, %ecx
movl 8(%ebp), %edx
begin:
cmpl 12(%ebp), %ecx
jge done
addl (%edx, %ecx, 4), %eax
incl %ecx
jump begin
done:
movl %ebp, %esp
popl %ebp
ret
我得到“开始”部分。它看起来像是一个循环,它从函数中获取参数并将其与 %ecx 中的任何内容进行比较。如果满足 jge 条件,则函数返回,如果不满足,则将 %edx 添加 4%ecx,将其移至 %eax,增加 %ecx,然后再次循环。
我真的不明白“神秘”部分。特别是 xorls 和 movl 语句。如果 %eax 或 %ecx 中什么都没有,那么 xorl 在做什么。我猜的 movl 是从函数中获取一个参数并将其移动到 %edx?
任何见解都是有帮助和赞赏的。
【问题讨论】:
-
你在哪里找到这个代码?
-
@unwind 我闻到了作业的味道。
-
单独异或意味着将其设置为零。
-
%exc 是 %ecx,不是吗?