所以我有以下汇编语言代码,我需要转换成C.我困惑了几行代码。汇编语言到C
我知道这是一个for循环。我在每一行添加了我的评论。
我觉得for循环是这样
for (int i = 1; i > 0; i << what?) {
//Calculate result
}
什么是测试条件?我该如何改变它?
看看汇编代码,变量'n'做什么?
这是英特尔的x86所以格式是MOVL =源,什特
movl 8(%ebp), %esi //Get x
movl 12(%ebp), %ebx //Get n
movl $-1, %edi //This should be result
movl $1, %edx //The i of the loop
.L2:
movl %edx, %eax
andl %esi, %eax
xorl %eax, %edi //result = result^(i & x)
movl %ebx, %ecx //Why do we do this? As we never use $%ebx or %ecx again
sall %cl, %edx //Where did %cl come from?
testl %edx, %edx //Tests if i != what? - condition of the for loop
jne .L2 //Loop again
movl %edi, %eax //Otherwise return result.
2010-10-24
Catie
+1
testl%edx,%edx检查edx是否为0,然后jne - 如果不为零则跳转。 –
2010-10-24 12:20:38
+0
你对哪条线感到困惑?在C中,for循环用于(;;){} –
2010-10-24 12:33:23
+0
为什么要将legacy asm转换为C? –
2010-10-24 12:34:33
本文发布于:2024-02-01 04:29:39,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170673298133861.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |