本文介绍了如何IA32'CMP'指令转换为Y86?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
IA32 为 Y86
ATT大会
我有以下IA32组装code:
I have the following IA32 assembly code:
Bubble:
.LFB0:
pushl %esi
pushl %ebx
movl 16(%esp), %esi
movl 12(%esp), %edx
subl $1, %esi
andl %esi, %esi
jle .L1
.L7:
xorl %eax, %eax
.L5:
movl 4(%edx,%eax,4), %ecx
movl (%edx,%eax,4), %ebx
cmpl %ebx, %ecx
jge .L4
movl %ebx, 4(%edx,%eax,4)
movl %ecx, (%edx,%eax,4)
.L4:
addl $1, %eax
cmpl %eax, %esi
jg .L5
subl $1, %esi
jne .L7
.L1:
popl %ebx
popl %esi
ret
我试图将其转换为Y86组装code。我无法翻译的比较指令:
I'm trying to convert it to Y86 assembly code. I'm having trouble translating the compare instruction:
cmpl %ebx, %ecx
感谢。
推荐答案
看来,Y86没有 CMP
指令。但是,它有分
,推
和弹出
。
It seems that Y86 does not have cmp
instruction. However, it has sub
, push
and pop
.
所以 CMPL%EBX,ECX%
可转换为以下code:
So cmpl %ebx, %ecx
can be converted to the following code:
pushl %ecx
subl %ebx, %ecx
popl %ecx
CMP
是完全一样的分
与 CMP 区别code>不存储结果,只更新标志。因此,
CMP
总是可以用推
,分
取代, 弹出
(如果在堆栈中的足够的空间)。
cmp
is exactly the same as sub
, with the difference that cmp
does not store the result, it only updates the flags. So cmp
can always be replaced with push
, sub
, pop
(if there's enough space in the stack).
这篇关于如何IA32'CMP'指令转换为Y86?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!